From 53107f9180169d1e592960b5ab482937edead4f3 Mon Sep 17 00:00:00 2001 From: Ilya Titkov Date: Sun, 26 Sep 2021 19:34:52 +0300 Subject: [PATCH] Update readme and docs --- Cargo.toml | 2 +- README.md | 7 +++++-- src/lib.rs | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0bc3748..87cb691 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fure" -version = "0.3.1" +version = "0.3.2" edition = "2018" authors = ["Ilya Titkov "] keywords = ["futures-retry", "retry", "futures"] diff --git a/README.md b/README.md index e1fa5b9..78eb8bd 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ A crate for retrying futures. [`Policy`] trait will help you define different retry policies. Some builtin policies can be found in [`policies`] module. + +By default this create uses `tokio` timers for [`crate::policies::interval`] and [`crate::policies::backoff`] policies, +but `async-std` is also available as feature `async-std`. ## Examples. ### Interval retry. Starts with sending a request, setting up a 1 second timer, and waits for either of them. @@ -33,7 +36,7 @@ println!("body = {}", body); ### Sequential retry with backoff. Retries failed requests with an exponential backoff and a jitter. ```rust -use fure::{policies::{backoff, cond}, backoff::exponential}; +use fure::{policies::{backoff, cond}, backoff::{exponential, jitter}}; use std::time::Duration; let get_body = || async { @@ -43,7 +46,7 @@ let get_body = || async { .await }; let exp_backoff = exponential(Duration::from_secs(1), 2, Some(Duration::from_secs(10))) - .map(fure::backoff::jitter); + .map(jitter); let policy = cond(backoff(exp_backoff), |result| !matches!(result, Some(Ok(_)))); let body = fure::retry(get_body, policy).await?; println!("body = {}", body); diff --git a/src/lib.rs b/src/lib.rs index 05bcb71..852238b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,9 @@ //! [`Policy`] trait will help you define different retry policies. //! //! Some builtin policies can be found in [`policies`] module. +//! +//! By default this create uses `tokio` timers for [`crate::policies::interval`] and [`crate::policies::backoff`] policies, +//! but `async-std` is also available as feature `async-std`. //! # Examples. //! ## Interval retry. //! Starts with sending a request, setting up a 1 second timer, and waits for either of them.