pub fn backoff_delay(attempt: u32, retry_after: Option<Duration>) -> DurationExpand description
Computes the delay to wait before the next retry attempt.
Uses exponential backoff (BASE_DELAY_MS * 2^attempt, capped at
MAX_DELAY_MS) combined with full jitter: the returned delay is a value in
[0, backoff], which decorrelates retries across concurrent clients.
When the server supplied a Retry-After value, that instruction wins — the
delay is at least retry_after (clamped to MAX_DELAY_MS, the same ceiling
the exponential branch respects, so a hostile or buggy server cannot make us
sleep for hours), with a small jittered margin added so a fleet of clients
that all received the same Retry-After do not retry in lockstep.