Skip to main content

jittered_interval_stream

Function jittered_interval_stream 

Source
pub fn jittered_interval_stream(
    base: Duration,
    jitter: Duration,
) -> impl Stream<Item = Instant> + Unpin
Expand description

Like interval_stream, but de-synchronizes fleets of clients that boot together:

  • a one-time startup offset in [0, jitter] is awaited before the first tick, so clients booted at the same time don’t tick in lockstep;
  • each subsequent tick adds a fresh random delay in [0, jitter], so they don’t re-converge over time.

jitter == Duration::ZERO degenerates to interval_stream and pulls no randomness — the zero-jitter path is byte-for-byte the old behavior.