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
//! Retry and resilience patterns for Effect-based computations.
//!
//! This module provides retry capabilities for stillwater effects, following the
//! "pure core, imperative shell" philosophy:
//!
//! - **Pure Core**: `RetryPolicy` is just data—no side effects, easily testable
//! - **Composable**: Policies can be combined and transformed
//! - **Declarative**: Describe *what* retry behavior you want, not *how* to implement it
//!
//! # Quick Start
//!
//! ```rust,ignore
//! // Note: Requires the `async` feature to be enabled
//! use stillwater::{Effect, RetryPolicy};
//! use std::time::Duration;
//!
//! # tokio_test::block_on(async {
//! // Create a retry policy with exponential backoff
//! let policy = RetryPolicy::exponential(Duration::from_millis(100))
//! .with_max_retries(3);
//!
//! // Retry an effect using a factory function
//! let effect = Effect::retry(
//! || Effect::<_, String, ()>::pure(42),
//! policy
//! );
//!
//! assert_eq!(effect.run(&()).await.unwrap().into_value(), 42);
//! # });
//! ```
//!
//! # Retry Strategies
//!
//! - **Constant**: Fixed delay between retries
//! - **Linear**: Delay increases linearly (100ms, 200ms, 300ms, ...)
//! - **Exponential**: Delay doubles each retry (100ms, 200ms, 400ms, ...)
//! - **Fibonacci**: Delay follows Fibonacci sequence
//!
//! # Jitter Support
//!
//! Jitter adds randomness to delays to prevent thundering herd problems.
//! Enable the `jitter` feature to use jitter:
//!
//! ```toml
//! stillwater = { version = "...", features = ["jitter"] }
//! ```
//!
//! ```rust,ignore
//! use stillwater::RetryPolicy;
//! use std::time::Duration;
//!
//! // Add ±25% randomness to delays
//! let policy = RetryPolicy::exponential(Duration::from_millis(100))
//! .with_jitter(0.25)
//! .with_max_retries(5);
//! ```
//!
//! # Error Types
//!
//! - [`RetryExhausted`]: Returned when all retries fail, contains the final error and metadata
//! - [`TimeoutError`]: Returned when an effect times out
pub use ;
pub use ;