Delay returns the backoff duration for the given 0-indexed attempt. Uses exponential backoff: min(InitialDelay * 2^attempt, MaxDelay). Matches the backoff curve used in coder/mux.
(attempt int)
| 40 | // Uses exponential backoff: min(InitialDelay * 2^attempt, MaxDelay). |
| 41 | // Matches the backoff curve used in coder/mux. |
| 42 | func Delay(attempt int) time.Duration { |
| 43 | d := InitialDelay |
| 44 | for range attempt { |
| 45 | d *= 2 |
| 46 | if d >= MaxDelay { |
| 47 | return MaxDelay |
| 48 | } |
| 49 | } |
| 50 | return d |
| 51 | } |
| 52 | |
| 53 | // effectiveDelay returns the delay for the given 0-indexed attempt |
| 54 | // while honoring any provider-supplied minimum retry delay. |
no outgoing calls