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

Provide a sensible way to retry indefinitely #43

Closed
edigaryev opened this issue May 11, 2021 · 3 comments
Closed

Provide a sensible way to retry indefinitely #43

edigaryev opened this issue May 11, 2021 · 3 comments

Comments

@edigaryev
Copy link
Contributor

Imagine a Go server that is dependent on some bootstrap data and there's little sense in continuing the execution unless that data is retrieved.

With all the perks this package gives (precise delay control, exponential backoff, context support) it would be nice to use it for this case, however, it's currently not possible to do this cleanly:

It would be nice if retry.Attempts(0) could be used for this case, as retry.Attempts(0) is kinda useless in the current implementation: it always results in All attempts fail: ... error.

@edigaryev
Copy link
Contributor Author

Just realized that we've still bounded by the uint counter value passed into the OnRetryFunc.

Looks like in this case this can be fixed by not allocating config.attempts straight away (see above).

...or worked around by specifying LastErrorOnly(true) in each retry.Do() invocation. Perhaps, a global variable like some packages do to configure them once before using?

@JaSei
Copy link
Collaborator

JaSei commented May 12, 2021

Hi, @edigaryev. I take the point. I feel Attempts(0) could be like infinite attempts, probably it's more logical than current behavior #41.
I will look at it, or PR is welcome.

@JaSei
Copy link
Collaborator

JaSei commented Nov 8, 2021

v4 released #49

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

No branches or pull requests

2 participants