Skip to content

Handle context cancellations in retry middleware#32

Open
csueiras wants to merge 1 commit intoslok:masterfrom
csueiras:csueiras/fix-context-cancellation-handling
Open

Handle context cancellations in retry middleware#32
csueiras wants to merge 1 commit intoslok:masterfrom
csueiras:csueiras/fix-context-cancellation-handling

Conversation

@csueiras
Copy link
Copy Markdown

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
Copy Markdown

@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?

@StevenACoffman
Copy link
Copy Markdown

You should also be aware of this basgys@77178d8

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

3 participants