exponential_backoff

Function exponential_backoff 

Source
pub fn exponential_backoff(
    attempt: u32,
    base_delay_ms: u64,
    max_delay_ms: u64,
    jitter: bool,
) -> Duration
Expand description

Calculate exponential backoff delay with optional jitter.

§Arguments

  • attempt - The retry attempt number (0-indexed)
  • base_delay_ms - The base delay in milliseconds
  • max_delay_ms - The maximum delay in milliseconds
  • jitter - Whether to add random jitter (0-100% of calculated delay)

§Returns

The delay duration to wait before the next retry