reqwest-middleware/reqwest-retry/src/lib.rs
tl-rodrigo-gryzinski b8645f81eb
Include README in crate doctests and improve documentation (#8)
* chore: Improve docs and include some examples in doctests
2021-09-28 19:26:03 +01:00

34 lines
1 KiB
Rust

//! Middleware to retry failed HTTP requests built on [`reqwest_middleware`].
//!
//! Use [`RetryTransientMiddleware`] to retry failed HTTP requests. Retry control flow is managed
//! by a [`RetryPolicy`].
//!
//! ## Example
//!
//! ```
//! use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
//! use reqwest_retry::{RetryTransientMiddleware, policies::ExponentialBackoff};
//!
//! async fn run_retries() {
//! // Retry up to 3 times with increasing intervals between attempts.
//! let retry_policy = ExponentialBackoff::builder().build_with_max_retries(3);
//! let client = ClientBuilder::new(reqwest::Client::new())
//! .with(RetryTransientMiddleware::new_with_policy(retry_policy))
//! .build();
//!
//! client
//! .get("https://truelayer.com")
//! .header("foo", "bar")
//! .send()
//! .await
//! .unwrap();
//! }
//! ```
mod middleware;
mod retryable;
pub use retry_policies::{policies, RetryPolicy};
pub use middleware::RetryTransientMiddleware;
pub use retryable::Retryable;