cmsd2 / rust-tokio-retry

Extensible, asynchronous retry behaviours for futures/tokio

Home Page:https://crates.io/crates/tokio-retry

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tokio-retry

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

Build Status crates dependency status

Documentation

Installation

Add this to your Cargo.toml:

[dependencies]
tokio-retry = "0.2"

Examples

extern crate futures;
extern crate tokio;
extern crate tokio_retry;

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

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

fn main() {
    let retry_strategy = ExponentialBackoff::from_millis(10)
        .map(jitter)
        .take(3);

    let future = Retry::spawn(retry_strategy, action).then(|result| {
        println!("result {:?}", result);
        Ok(())
    });

    tokio::run(future);
}

About

Extensible, asynchronous retry behaviours for futures/tokio

https://crates.io/crates/tokio-retry

License:MIT License


Languages

Language:Rust 100.0%