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

Give reason for Stop #97

Open
hugelgupf opened this issue Apr 10, 2020 · 4 comments
Open

Give reason for Stop #97

hugelgupf opened this issue Apr 10, 2020 · 4 comments

Comments

@hugelgupf
Copy link

Hey,

I just pulled a newer version of backoff into some internal things, importing among others this patch: 62661b4

Problem is that now it's impossible for the user to tell if we stopped because of a DeadlineExceeded versus other reasons. Got any ideas how to deal with that? I don't like changing the API, because most people probably compare against backoff.Stop, but I'm not sure what else to do.

Perhaps an alternative NextBackOff method that can return Stop or DeadlineStop?

Or NextBackOffError() (time.Duration, error) that can return a context.DeadlineExceeded?

Any ideas?

Thanks

@cenkalti
Copy link
Owner

I'm sorry, I can't think of a solution without changing the API.

@praran26
Copy link

praran26 commented Apr 12, 2020

We just reverted NextBackOff function so that it does not "predict" if there are no more retries and returns Stop only after ctx.Err is set to DeadlineExceeded. I agree having NextBackoffError() might be a good option.

@hugelgupf
Copy link
Author

hugelgupf commented Apr 12, 2020

@praran26 Sure, but I don't think that's a good long-term solution. It's a good feature to have.

How do you think we can square NextBackOffError with the interface?

@seiyab
Copy link

seiyab commented Mar 18, 2024

Just an idea: Backoff can optionally implement type Reasoner interface { Reason() error } and return the reason. Clients can try r, ok := backoff.(Reasoner) so that retrieve the reason.

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

4 participants