Skip to content

Commit

Permalink
Update readme and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonqn committed Sep 26, 2021
1 parent c2f16ff commit 53107f9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fure"
version = "0.3.1"
version = "0.3.2"
edition = "2018"
authors = ["Ilya Titkov <[email protected]>"]
keywords = ["futures-retry", "retry", "futures"]
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 53107f9

Please sign in to comment.