Documentation
¶
Index ¶
Constants ¶
const MaxAttemptsBeforeResetDefault = 10
MaxAttemptsBeforeResetDefault is the number of attempts during exponential backoff after which attempts is reset so that sleep durations aren't flung into a ridiculously distant future. This constant is typically injected into the CancellableSleepExponentialBackoff function. It could technically take another value instead, but shouldn't unless there's a good reason to do so.
Variables ¶
This section is empty.
Functions ¶
func CancellableSleep ¶
CancellableSleep sleeps for the given duration, but returns early if context has been cancelled.
func CancellableSleepC ¶
CancellableSleep sleeps for the given duration, but returns early if context has been cancelled.
This variant returns a channel that should be waited on and which will be closed when either the sleep or context is done.
func ExponentialBackoff ¶
ExponentialBackoff returns a duration for a reasonable exponential backoff interval for a service based on the given attempt number, which can then be fed into CancellableSleep to perform the sleep. Uses a 2**N second algorithm, +/- 10% random jitter. Sleep is cancelled if the given context is cancelled.
Attempt should start at one for the first backoff/failure.
Types ¶
This section is empty.