Crates.io | backoff-rs |
lib.rs | backoff-rs |
version | 0.1.0 |
source | src |
created_at | 2021-08-19 05:00:09.43562 |
updated_at | 2021-08-19 05:00:09.43562 |
description | Backoff provides the base components for implementing backoff and retry operations. |
homepage | |
repository | https://github.com/rust-playground/backoff-rs |
max_upload_size | |
id | 439479 |
size | 20,207 |
Backoff provides the base components for implementing backoff and retry operations.
use backoff_rs::ExponentialBackoffBuilder;
use std::time::Duration;
fn main() {
let bo = ExponentialBackoffBuilder::default()
.factor(1.75)
.interval(Duration::from_millis(500))
.jitter(Duration::from_millis(150))
.max(Duration::from_secs(5))
.build();
for attempt in 0..=5 {
println!("{:?}", bo.duration(attempt));
}
}