Thanks to visit codestin.com
Credit goes to lib.rs

#exponential-backoff #retry #future

tokio-retry

Extensible, asynchronous retry behaviours for futures/tokio

10 releases

0.3.1 Apr 15, 2026
0.3.0 Mar 6, 2021
0.2.0 Apr 7, 2018
0.1.1 Oct 27, 2017
0.0.5 Mar 11, 2017

#21 in Asynchronous

Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App

11,658,134 downloads per month
Used in 427 crates (114 directly)

MIT license

21KB
402 lines

tokio-retry

Extensible, asynchronous retry behaviours for the ecosystem of tokio libraries.

Documentation Crates.io Build status

Features

  • Multiple retry strategies:
    • Exponential backoff
    • Fibonacci backoff
    • Fixed interval
  • no_std support
  • Optional support for random jitter (requires the rand feature)

Example

use tokio_retry::Retry;
use tokio_retry::strategy::{ExponentialBackoff, jitter};

async fn action() -> Result<u64, ()> {
    // do some real-world stuff here...
    Err(())
}

#[tokio::main]
async fn main() -> Result<(), ()> {
    let retry_strategy = ExponentialBackoff::from_millis(10)
        .map(jitter) // add jitter to delays
        .take(3);    // limit to 3 retries

    let result = Retry::spawn(retry_strategy, action).await?;

    Ok(())
}

Dependencies

~2–2.8MB
~40K SLoC