1
0
Fork 0
mirror of https://github.com/clechasseur/reessaie.git synced 2025-12-14 11:58:55 +01:00
Companion to reqwest_retry to use the Retry-After HTTP header if available
renovate[bot] 3b33c4beb6
chore(deps): update swatinem/rust-cache action to v2.8.2 (#23)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-11-30 22:58:14 -05:00
.github chore(deps): update swatinem/rust-cache action to v2.8.2 (#23) 2025-11-30 22:58:14 -05:00
src feat: add tracing support (#9) 2025-10-13 23:05:03 -04:00
tests feat: add tracing support (#9) 2025-10-13 23:05:03 -04:00
.gitignore Initial commit 2025-10-05 00:03:51 -04:00
Cargo.lock feat!: move version to 3.0.0, update dependencies (#22) 2025-11-28 22:45:31 -05:00
Cargo.toml feat!: move version to 3.0.0, update dependencies (#22) 2025-11-28 22:45:31 -05:00
CODE_OF_CONDUCT.md Initial commit 2025-10-05 00:03:51 -04:00
codecov.yml Initial commit 2025-10-05 00:03:51 -04:00
CONTRIBUTING.md chore: initial project setup 2025-10-05 00:22:45 -04:00
DEVELOPMENT.md chore: initial project setup 2025-10-05 00:22:45 -04:00
justfile chore: bring updates from template (#15) 2025-11-16 00:27:15 -05:00
LICENSE Initial commit 2025-10-05 00:03:51 -04:00
msrv-pins.toml chore: fix MSRV build on Ubuntu 2025-10-07 01:10:05 -04:00
README.md feat!: move version to 3.0.0, update dependencies (#22) 2025-11-28 22:45:31 -05:00
renovate.json Initial commit 2025-10-05 00:03:51 -04:00
rustfmt.toml Initial commit 2025-10-05 00:03:51 -04:00
SECURITY.md feat!: move version to 3.0.0, update dependencies (#22) 2025-11-28 22:45:31 -05:00
tarpaulin.toml Initial commit 2025-10-05 00:03:51 -04:00

reessaie

CI codecov Security audit crates.io downloads docs.rs Contributor Covenant

Companion library to reqwest-retry with helpers to use the Retry-After HTTP header to control the time between retries, if it's available.

Partially inspired by reqwest-retry-after.

Installing

Add reessaie to your dependencies:

[dependencies]
reessaie = "3.0.0"

or by running:

cargo add reesaie

Example

use anyhow::Context;
use reessaie::{RetryAfterMiddleware, RetryAfterPolicy};
use reqwest::Client;
use reqwest_middleware::ClientBuilder;

async fn get_with_retries(url: &str, max_retries: u32) -> Result<String, anyhow::Error> {
    let policy = RetryAfterPolicy::with_max_retries(max_retries);
    let client = ClientBuilder::new(Client::new())
        .with(RetryAfterMiddleware::new_with_policy(policy))
        .build();

    Ok(client
        .get(url)
        .send()
        .await
        .with_context(|| format!("error getting {url}"))?
        .text()
        .await
        .with_context(|| format!("error getting text for {url}"))?)
}

For more information, see the docs.

Minimum Rust version

reessaie currently builds on Rust 1.88 or newer.