Backoff.Linear: panic when InitialBackoff > MaxBackoff

this probably means there's a configuration issue.

Since this struct is mainly set manually from code, I think it is okay to panic here.
This commit is contained in:
Adrien Delorme 2019-06-11 12:41:21 +02:00
parent 98206d59d7
commit 39cfacd5fa
1 changed files with 3 additions and 0 deletions

View File

@ -94,6 +94,9 @@ type Backoff struct {
// n = n * Multiplier.
// the first value of n is InitialBackoff. n is maxed by MaxBackoff.
func (lb *Backoff) Linear() time.Duration {
if lb.InitialBackoff > lb.MaxBackoff {
panic("InitialBackoff > MaxBackoff, did you forgot setting the seconds ?")
}
wait := lb.InitialBackoff
lb.InitialBackoff = time.Duration(lb.Multiplier * float64(lb.InitialBackoff))
if lb.MaxBackoff != 0 && lb.InitialBackoff > lb.MaxBackoff {