Function getDelay
Get the delay to apply before retrying
uint getDelay(alias JitterFunc)
(
uint attempt,
uint base,
uint max_delay
);
The unit is purposely left unspecified: Calling code can use
,
, or whichever unit is deemed appropriate.
The algorithm is simply:
`
base_sleep = random(0, min(max_delay, base * (2 ^^ attempt));
sleep_time = base_sleep + random(0, base_sleep / 20)
`
Parameters
Name | Description |
---|---|
RandomFunc | A function that takes a uint as an input and returns a
value between 0 and the provided value, uniformly |
attempt | the attempt number (can be 0, which will result in 0) |
base | The base multiplier |
max_delay | Maximum possible delay this function may return |
Returns
the delay which should be used given the attempt number and the provided base multiplier.