1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! # reliability-toolkit
//!
//! Async reliability primitives for Tokio-based Rust services. The crate is
//! deliberately small: each primitive is independent, composable, and avoids
//! pulling in unrelated dependencies.
//!
//! ## Primitives
//!
//! - [`RateLimiter`] — token-bucket rate limiter with configurable burst.
//! - [`CircuitBreaker`] — closed → open → half-open with failure-rate trip and cool-down.
//! - [`Retry`] — exponential backoff with full jitter and per-error predicates.
//! - [`Bulkhead`] — semaphore-backed concurrency cap.
//!
//! ## Composition
//!
//! Each primitive exposes an `execute()` (or `run()` / `acquire()`) that wraps
//! a user-supplied future. They are designed so the typical layering pattern —
//! `Retry(CircuitBreaker(Bulkhead(RateLimit(call))))` — falls out naturally.
//!
//! ```no_run
//! use std::time::Duration;
//! use reliability_toolkit::{RateLimiter, CircuitBreaker, Retry, Bulkhead, RetryConfig};
//!
//! # async fn outer() -> Result<(), Box<dyn std::error::Error>> {
//! let limiter = RateLimiter::new(100.0, 100); // 100 rps, burst 100
//! let breaker = CircuitBreaker::builder()
//! .failure_threshold(5)
//! .cool_down(Duration::from_secs(10))
//! .build();
//! let retry = Retry::new(RetryConfig::default());
//! let pool = Bulkhead::new(20);
//!
//! let result: Result<(), std::io::Error> = retry
//! .run(|| async {
//! limiter.acquire().await;
//! let _permit = pool
//! .acquire()
//! .await
//! .map_err(std::io::Error::other)?;
//! match breaker.call(async { Ok::<_, std::io::Error>(()) }).await {
//! Ok(inner) => inner,
//! Err(open) => Err(std::io::Error::other(open.to_string())),
//! }
//! })
//! .await;
//! # let _ = result;
//! # Ok(()) }
//! ```
/// Optional audit-stream-py producer. Gated behind the `audit-stream`
/// Cargo feature so the core toolkit stays HTTP-free.
pub use ;
pub use ;
pub use ToolkitError;
pub use RateLimiter;
pub use ;
pub use AuditingBreaker;