Fix zero backoff

This commit is contained in:
Vladimir Mihailenco 2020-07-28 16:14:54 +03:00
parent 6e3d4a53c6
commit 0f5d67c102
1 changed files with 3 additions and 0 deletions

View File

@ -10,6 +10,9 @@ func RetryBackoff(retry int, minBackoff, maxBackoff time.Duration) time.Duration
if retry < 0 { if retry < 0 {
panic("not reached") panic("not reached")
} }
if minBackoff == 0 {
return 0
}
d := minBackoff << uint(retry) d := minBackoff << uint(retry)
d = minBackoff + time.Duration(rand.Int63n(int64(d))) d = minBackoff + time.Duration(rand.Int63n(int64(d)))