(min, max time.Duration)
| 22 | type GetRetryIntervalFunc func(resp *Response, attempt int) time.Duration |
| 23 | |
| 24 | func backoffInterval(min, max time.Duration) GetRetryIntervalFunc { |
| 25 | base := float64(min) |
| 26 | capLevel := float64(max) |
| 27 | return func(resp *Response, attempt int) time.Duration { |
| 28 | temp := math.Min(capLevel, base*math.Exp2(float64(attempt))) |
| 29 | halfTemp := int64(temp / 2) |
| 30 | sleep := halfTemp + rand.Int63n(halfTemp) |
| 31 | return time.Duration(sleep) |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | func newDefaultRetryOption() *retryOption { |
| 36 | return &retryOption{ |
no outgoing calls
no test coverage detected
searching dependent graphs…