Something went wrong. Try again.
wip outbox library design
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829package outpost
import "time"
// Backoff maps a failure count to a retry delay. It is called with the number// of failures recorded so far, starting at 1.type Backoff func(failures int) time.Duration
// ExponentialBackoff returns base * 2^(failures-1), capped at max. base must be// positive.func ExponentialBackoff(base, max time.Duration) Backoff { return func(failures int) time.Duration { if failures < 1 { failures = 1 } d := base for i := 1; i < failures; i++ { if d >= max { break } d *= 2 } if d > max { d = max } return d }}