expression

Equal jitter: retain a minimum delay

A policy can keep half of a backoff interval and sample uniformly from the remaining half. Integer rounding is explicit here. Validate the injected sample before adding; a real sampler is outside this fixture. Expected stdout (not executed): Some(50) Some(75) Some(100) None Common mistake: Adding an unrestricted random number to the full cap.

Formal Syntax & Structure

rust syntaxrust
floor = cap / 2; floor + sample

Working Example

Example Snippetrust
fn main() {    fn delay(cap: u64, draw: u64) -> Option<u64> {        let floor = cap / 2;        if draw > cap - floor { return None; }        Some(floor + draw)    }    for draw in [0, 25, 50, 51] {        println!("{:?}", delay(100, draw));    }}
Rust Reference