#exponential-backoff #retry #tokio #future

tokio-retry

Extensible, asynchronous retry behaviours for futures/tokio

9 releases

0.3.0 Mar 6, 2021
0.2.0 Apr 7, 2018
0.1.1 Oct 27, 2017
0.1.0 Apr 17, 2017
0.0.5 Mar 11, 2017

#51 in Asynchronous

Download history 560515/week @ 2025-11-11 621701/week @ 2025-11-18 348427/week @ 2025-11-25 455342/week @ 2025-12-02 1218399/week @ 2025-12-09 1346067/week @ 2025-12-16 611093/week @ 2025-12-23 658460/week @ 2025-12-30 1527734/week @ 2026-01-06 1681550/week @ 2026-01-13 2009508/week @ 2026-01-20 2005689/week @ 2026-01-27 1929722/week @ 2026-02-03 2122440/week @ 2026-02-10 1819648/week @ 2026-02-17 1608590/week @ 2026-02-24

7,785,907 downloads per month
Used in 381 crates (104 directly)

MIT license

20KB
413 lines

tokio-retry

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

Build Status dependency status

Documentation

Installation

Add this to your Cargo.toml:

[dependencies]
tokio-retry = "0.3"

Examples

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–3.5MB
~53K SLoC