Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants