<div align="center">
<img src="https://devhub.vip/pages/docs/img/logo.png" alt="jitter-backoff logo" height="120">
# jitter-backoff
**Zero-Dependency Exponential Backoff, Jitter Strategies, Atomic Retry Budgets & `Retry-After` Parsing**
[](https://crates.io/crates/jitter-backoff)
[](https://docs.rs/jitter-backoff)
[](https://github.com/crates-dev/ctares/actions/workflows/rust.yml)
[](https://www.rust-lang.org)
[](../LICENSE)
[Workspace Overview](../README.md) ยท [API Docs](https://docs.rs/jitter-backoff/latest/)
</div>
---
## Overview
`jitter-backoff` implements zero-dependency exponential backoff with full, equal, and decorrelated jitter, a lock-free atomic `RetryBudget` against retry storms, and RFC 9110 `Retry-After` parsing for HTTP clients and workers.
## Installation
```sh
cargo add jitter-backoff
```
## Usage
```rust
use jitter_backoff::{JitterMode, RetryBudget, RetryPolicy, parse_retry_after};
let policy = RetryPolicy::new(5, 100, 30_000).with_jitter(JitterMode::Full);
let mut state = policy.start_with_seed(42);
let _delay = state.next_delay();
let budget = RetryBudget::new(20, 100);
budget.deposit();
assert!(budget.try_withdraw());
assert!(parse_retry_after("120").is_some());
```
## Verification
```sh
cargo run -p crate-cli -- fmt --check
cargo clippy -p jitter-backoff --all-features --all-targets -- -D warnings
cargo test -p jitter-backoff --all-features
```
## License
This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details.
## Contact
For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip).