error_forge/recovery/mod.rs
1//! Error recovery patterns for handling transient errors
2//!
3//! This module provides various error recovery strategies that can be used to make
4//! applications more resilient to transient failures.
5//!
6//! # Features
7//!
8//! - Backoff strategies for controlling retry timing
9//! - Circuit breaker pattern to prevent cascading failures
10//! - Retry policies for flexible retry behaviors
11//!
12//! # Examples
13//!
14//! ```rust,ignore
15//! use error_forge::recovery::{ExponentialBackoff, RetryPolicy};
16//!
17//! let backoff = ExponentialBackoff::new()
18//! .with_initial_delay(100)
19//! .with_max_delay(10000)
20//! .with_jitter(true);
21//!
22//! let policy = RetryPolicy::new(backoff)
23//! .with_max_retries(3);
24//!
25//! let result = policy.retry(|| {
26//! // Operation that might fail
27//! Ok(())
28//! });
29//! ```
30
31mod backoff;
32mod circuit_breaker;
33mod retry;
34mod forge_extensions;
35
36pub use backoff::{Backoff, ExponentialBackoff, LinearBackoff, FixedBackoff};
37pub use circuit_breaker::{CircuitBreaker, CircuitState, CircuitOpenError, CircuitBreakerConfig};
38pub use retry::{RetryPolicy, RetryExecutor};
39pub use forge_extensions::ForgeErrorRecovery;
40
41/// Result type for recovery operations
42pub type RecoveryResult<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync + 'static>>;