named-retry

Crates.ionamed-retry
lib.rsnamed-retry
version0.3.0
sourcesrc
created_at2022-07-26 21:00:17.966673
updated_at2024-11-14 19:18:07.672988
descriptionA simple utility for retrying fallible asynchronous operations.
homepage
repositoryhttps://github.com/modal-labs/named-retry
max_upload_size
id633403
size9,014
Eric Zhang (ekzhang)

documentation

https://docs.rs/named-retry

README

named-retry

This is a simple, impl Copy utility for retrying fallible asynchronous operations, with helpful log messages through tracing.

use std::time::Duration;
use named_retry::Retry;

let retry = Retry::new("test")
    .attempts(5)
    .base_delay(Duration::from_secs(1))
    .delay_factor(2.0)
    .jitter(true);

let result = retry.run(|| async { Ok::<_, ()>("done!") }).await;
assert_eq!(result, Ok("done!"));
Commit count: 8

cargo fmt