Skip to content

Commit

Permalink
Prevent exponential backoff delay from overflowing
Browse files Browse the repository at this point in the history
  • Loading branch information
skateinmars committed Oct 16, 2023
1 parent 2956d04 commit 8f03fe4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -941,11 +941,11 @@ func exponentialBackoff(min, max time.Duration, retry int) time.Duration {
if retry > 0 {
d = min << uint(retry-1)
}
if (retry > 0 && d <= 0) || d > max {
return max
}
if d < min {
return min
}
if d > max {
return max
}
return d
}

0 comments on commit 8f03fe4

Please sign in to comment.