Skip to content

Commit

Permalink
rename RetryTx to RetryTxConflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
guregu committed Jun 15, 2024
1 parent 840a2a6 commit 756ca4a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ This creates a table with the primary hash key ID and range key Time. It creates

As of v2, dynamo relies on the AWS SDK for retrying. See: [**Retries and Timeouts documentation**](https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/retries-timeouts/) for information about how to configure its behavior.

By default, canceled transactions (i.e. errors from conflicting transactions) will not be retried. To get automatic retrying behavior like in v1, use [`dynamo.RetryTx`](https://godoc.org/github.com/guregu/dynamo/v2#RetryTx).
By default, canceled transactions (i.e. errors from conflicting transactions) will not be retried. To get automatic retrying behavior like in v1, use [`dynamo.RetryTxConflicts`](https://godoc.org/github.com/guregu/dynamo/v2#RetryTxConflicts).

```go
import (
Expand All @@ -204,7 +204,7 @@ import (

func main() {
cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRetryer(func() aws.Retryer {
return retry.NewStandard(dynamo.RetryTx)
return retry.NewStandard(dynamo.RetryTxConflicts)
}))
if err != nil {
log.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestMain(m *testing.M) {
config.WithRegion(*region),
config.WithEndpointResolverWithOptions(resolv),
config.WithRetryer(func() aws.Retryer {
return retry.NewStandard(RetryTx)
return retry.NewStandard(RetryTxConflicts)
}),
)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ func ExampleNew_local_endpoint() {
_ = db
}

func ExampleRetryTx() {
// `dynamo.RetryTx` is an option you can pass to retry.NewStandard.
func ExampleRetryTxConflicts() {
// `dynamo.RetryTxConflicts` is an option you can pass to retry.NewStandard.
// It will automatically retry canceled transactions.
cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRetryer(func() aws.Retryer {
return retry.NewStandard(dynamo.RetryTx)
return retry.NewStandard(dynamo.RetryTxConflicts)
}))
if err != nil {
log.Fatal(err)
Expand Down
6 changes: 3 additions & 3 deletions retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ func (db *DB) retry(_ context.Context, f func() error) error {
return f()
}

// RetryTx is an option for [github.com/aws/aws-sdk-go-v2/aws/retry.NewStandard]
// that adds retrying behavior for TransactionCanceledException errors.
// RetryTxConflicts is an option for [github.com/aws/aws-sdk-go-v2/aws/retry.NewStandard]
// that adds retrying behavior for TransactionConflict within TransactionCanceledException errors.
// See also: [github.com/aws/aws-sdk-go-v2/config.WithRetryer].
func RetryTx(opts *retry.StandardOptions) {
func RetryTxConflicts(opts *retry.StandardOptions) {
opts.Retryables = append(opts.Retryables, retry.IsErrorRetryableFunc(shouldRetryTx))
}

Expand Down

0 comments on commit 756ca4a

Please sign in to comment.