From c2f16ff6c49460291b2b4b065d318edae5a73eda Mon Sep 17 00:00:00 2001 From: Ilya Titkov Date: Sun, 26 Sep 2021 19:30:47 +0300 Subject: [PATCH] Add jitter to default-features --- Cargo.toml | 5 +---- src/lib.rs | 7 ++++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 34784cf..0bc3748 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,4 @@ tokio = { version = "1", features = [ "time", "rt" ], default-features = false } reqwest = "0.11" [features] -default = [ "tokio" ] - -[package.metadata.docs.rs] -features = ["rand", "tokio"] +default = [ "tokio", "rand" ] \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 84be70f..05bcb71 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,10 +32,10 @@ //! # } //! ``` //! ## Sequential retry with backoff. -//! Retries failed requests with an exponential backoff. +//! Retries failed requests with an exponential backoff and a jitter. //! ``` //! # async fn run() -> Result<(), reqwest::Error> { -//! use fure::{policies::{backoff, cond}, backoff::exponential}; +//! use fure::{policies::{backoff, cond}, backoff::{exponential, jitter}}; //! use std::time::Duration; //! //! let get_body = || async { @@ -44,7 +44,8 @@ //! .text() //! .await //! }; -//! let exp_backoff = exponential(Duration::from_secs(1), 2, Some(Duration::from_secs(10))); +//! let exp_backoff = exponential(Duration::from_secs(1), 2, Some(Duration::from_secs(10))) +//! .map(jitter); //! let policy = cond(backoff(exp_backoff), |result| !matches!(result, Some(Ok(_)))); //! let body = fure::retry(get_body, policy).await?; //! println!("body = {}", body);