-
Notifications
You must be signed in to change notification settings - Fork 145
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
Add WithTimeout opt to retrier #40
Conversation
Hi, thanks for the suggestion and code. I have a few thoughts / questions:
|
I suppose also that someone could argue this is behaviour as-designed? That the package should only bubble up the “final” error, and that since this error was still being retried when the context expired, it does not count as final? That said, I can also see why it’s inconvenient to lose the underlying error when the context expires. I suppose the same thing would happen if the |
@eapache Yes, the actual timeout option is mostly a convenience. I'm primarily interested in getting the last returned error to bubble up. You could argue that swallowing that error and simply reporting If we could add an option to allow supporting of bubbling up the actual last error when |
Alternatively, if you are okay with the
Then the existing default error-handling behavior remains as is, but the error is bubbled up if you've configured a timeout within the retrier, not just on the context. |
This is my preference, as it's fully backwards compatible and avoids proxying methods that can be called on other packages. I'm not sure exactly what to call the option though... maybe |
I believe the overall timeout should be specified in context.WithTimeout. On the issue of errors being bubbled up, I agree with @eapache that it should be provided as an option. However, while
|
Closing as stale, but I'm still happy to take a PR for the error-handling portion of this change. |
Users of the
retrier
package may wish to configure a retrier with a global timeout that applies across all retries. This differs from thebackoffs
configuration because each individual backoff only applies between successive calls towork()
. Without configuring a timeout to encapsulate the entireRunFn
call, a single call towork()
is time-wise unbounded.A caller could set a timeout on the context passed into
RunFn()
, but this means that the last error received,ret
is not bubbled up. This PR ensures that the last error encountered is bubbled up to the caller, even when the timeout is hit.