Skip to main content

next_delay

Function next_delay 

pub(super) fn next_delay(
    prev: Option<Duration>,
    opts: &ReconnectOptions,
    rng: &mut XorShift32,
) -> Duration
Available on crate feature tokio only.
Expand description

Computes the next reconnect delay from the previous one.

None yields the initial delay. Otherwise the previous delay is grown by the multiplier, capped at max_delay, and reduced by random jitter. The BackoffMultiplier (finite, >= 1.0) and Jitter (0.0..=1.0) newtypes guarantee the inputs are in range, so the result is always a non-negative, finite duration and this never has to be defensive.