Give reason for Stop
hugelgupf opened this issue · 4 comments
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
I'm sorry, I can't think of a solution without changing the API.
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.
@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?
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.