#futures #tokio #retry #exponential #backoff

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

#76 in Asynchronous

Download history 33905/week @ 2022-11-27 33280/week @ 2022-12-04 32073/week @ 2022-12-11 26779/week @ 2022-12-18 15385/week @ 2022-12-25 24709/week @ 2023-01-01 34311/week @ 2023-01-08 33149/week @ 2023-01-15 34280/week @ 2023-01-22 39409/week @ 2023-01-29 37538/week @ 2023-02-05 38864/week @ 2023-02-12 39168/week @ 2023-02-19 39036/week @ 2023-02-26 44346/week @ 2023-03-05 46642/week @ 2023-03-12

171,962 downloads per month
Used in 119 crates (33 directly)

MIT license

19KB
413 lines

tokio-retry

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

Build Status crates 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.8–7.5MB
~115K SLoC