Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to configure maximum retry count #126

Merged
merged 1 commit into from Feb 8, 2022
Merged

Conversation

miretskiy
Copy link
Contributor

Make it possible to configure maximum retry count when executing transactions.

@miretskiy miretskiy requested a review from rafiss February 4, 2022 21:49
@cockroach-teamcity
Copy link
Member

This change is Reviewable

// WithMaxRetries configures context so that ExecuteTx retries tx specified
// number of times when encountering retryable errors.
// Setting retries to 0 will retry indefinitely.
func WithMaxRetries(ctx context.Context, retries int) context.Context {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a basic test to verify something like

ctx = WithMaxRetries(ctx, n)
require.Equal(t, n, numRetriesFromContext(ctx)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@miretskiy miretskiy merged commit e1659d1 into master Feb 8, 2022
@rafiss rafiss deleted the retries branch February 9, 2022 03:39
@rafiss
Copy link
Contributor

rafiss commented Feb 9, 2022

i've tagged this in release v2.2.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants