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

#83 in Asynchronous

Download history 127603/week @ 2023-12-13 97169/week @ 2023-12-20 67053/week @ 2023-12-27 122821/week @ 2024-01-03 131173/week @ 2024-01-10 147621/week @ 2024-01-17 148696/week @ 2024-01-24 134621/week @ 2024-01-31 143046/week @ 2024-02-07 148687/week @ 2024-02-14 147864/week @ 2024-02-21 148647/week @ 2024-02-28 143380/week @ 2024-03-06 151121/week @ 2024-03-13 144565/week @ 2024-03-20 122475/week @ 2024-03-27

590,620 downloads per month
Used in 247 crates (56 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.6–4MB
~69K SLoC