Skip to main content

Module backoff

Module backoff 

Source
Expand description

Exponential backoff retry strategy

Provides configurable exponential backoff for connection retries and other network operations that may fail transiently.

§Features

  • Configurable initial delay, maximum delay, and retry limit
  • Optional jitter (±30%) to prevent thundering herd
  • Optional total duration limit (time-boxed retries)
  • Custom multiplier support (default: 2.0)
  • Iterator-based API for composability with async code

§Example

use std::time::Duration;
use actr_framework::ExponentialBackoff;

// Basic usage — 5 retries with jitter
let backoff = ExponentialBackoff::builder()
    .initial_delay(Duration::from_millis(100))
    .max_delay(Duration::from_secs(30))
    .max_retries(5)
    .with_jitter()
    .build();

for delay in backoff {
    println!("waiting {:?}", delay);
}

Structs§

BackoffBuilder
Builder for ExponentialBackoff
ExponentialBackoff
Exponential backoff iterator