Skip to content

Commit

Permalink
docs: Add section for sleeper (#130)
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo authored Aug 29, 2024
1 parent e731d8b commit 27b54d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions backon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
description = "Make retry like a built-in feature provided by Rust."
documentation = "https://docs.rs/backon"
name = "backon"
readme = "../README.md"
rust-version = "1.70"
version = "1.0.2"

Expand Down
15 changes: 14 additions & 1 deletion backon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,23 @@
//!
//! Retry in BackON requires a backoff strategy. BackON will accept a [`BackoffBuilder`] which will generate a new [`Backoff`] for each retry.
//!
//! Backon provides several backoff implementations with reasonable defaults:
//! BackON provides several backoff implementations with reasonable defaults:
//!
//! - [`ConstantBuilder`]: backoff with a constant delay, limited to a specific number of attempts.
//! - [`ExponentialBuilder`]: backoff with an exponential delay, also supports jitter.
//! - [`FibonacciBuilder`]: backoff with a fibonacci delay, also supports jitter.
//!
//! # Sleep
//!
//! Retry in BackON requires an implementation for sleeping. BackON will accept a [`Sleeper`] to pause for a specified duration.
//!
//! BackON offers the following features for users to choose from:
//!
//! - `tokio-sleep`: Use [`TokioSleeper`] within a Tokio context.
//! - `gloo-timers-sleep`: Use [`GlooTimersSleep`] to pause in a wasm32 environment.
//!
//! Users MUST provide a custom implementation if they prefer not to use the default options.
//!
//! # Retry
//!
//! For additional examples, please visit [`docs::examples`].
Expand All @@ -50,6 +61,8 @@
//! let content = fetch
//! // Retry with exponential backoff
//! .retry(ExponentialBuilder::default())
//! // Sleep implementation, default to tokio::time::sleep if `tokio-sleep` has been enabled.
//! .sleep(tokio::time::sleep)
//! // When to retry
//! .when(|e| e.to_string() == "EOF")
//! // Notify when retrying
Expand Down

0 comments on commit 27b54d8

Please sign in to comment.