RetryNotify does not cancel the backoff via Context Cancel if wrapped in WithMaxTries
23caterpie opened this issue · 0 comments
23caterpie commented
Currently RetryNotify
will not wait a full backoff period if using a backoff WithContext
when the context is canceled while it is "backing off." This is good. However, if backoff with context is wrapped in a backoff WithMaxTries
, then the context is not used for this anymore. Having a backoff WithMaxTries
wrapped in WithContext
, however does work as expected.
In order to get the context for use in RetryNotify
I propose adding a type check in ensureContext
to check for this case. The function would look like such after the edit:
func ensureContext(b BackOff) BackOffContext {
if cb, ok := b.(BackOffContext); ok {
return cb
}
if tb, ok := b.(*backOffTries); ok {
return ensureContext(tb.delegate)
}
return WithContext(b, context.Background())
}