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

Handle context cancellations in retry middleware #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

csueiras
Copy link

Fixes #31

@slok this changeset just handles the context cancellation within the retry middleware as there's no current way for client code to exit out until the retry attempts are met. I have a use case where I basically want to retry until:

  • Context is cancelled (thus this changeset)
  • A non-retriable error occurs

If the context is cancelled pre-execution of the retry middleware the middleware will just continuously retry until the attempts are met (in my use case I basically want to retry forever (math.MaxInt). If the context gets cancelled through a deadline the retrier is unaware of the context cancellation so again it will continue to retry.

@csueiras csueiras requested a review from slok as a code owner April 11, 2021 15:16
@csueiras csueiras force-pushed the csueiras/fix-context-cancellation-handling branch from af3cbf3 to f763913 Compare April 11, 2021 15:21
Copy link

@muzavan muzavan left a comment

Choose a reason for hiding this comment

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

If the feature ended up merged, the behavior upon context.Canceled should be specifically mentioned in the comment (probably on New, or maybe using a flag as part of config).

What do you think?

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.

Retries with context cancelled will continue to retry without calling user's function
2 participants