Skip to main content

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//! - `ForgeError`-aware retry executors for sync workloads
12//!
13//! # Examples
14//!
15//! ```rust,ignore
16//! use error_forge::recovery::RetryPolicy;
17//!
18//! let policy = RetryPolicy::new_exponential()
19//!     .with_max_retries(3);
20//!
21//! let result = policy.retry(|| {
22//!     // Operation that might fail
23//!     Ok(())
24//! });
25//! ```
26
27mod backoff;
28mod circuit_breaker;
29mod forge_extensions;
30mod retry;
31
32pub use backoff::{Backoff, ExponentialBackoff, FixedBackoff, LinearBackoff};
33pub use circuit_breaker::{CircuitBreaker, CircuitBreakerConfig, CircuitOpenError, CircuitState};
34pub use forge_extensions::ForgeErrorRecovery;
35pub use retry::{RetryExecutor, RetryPolicy};
36
37/// Result type for recovery operations
38pub type RecoveryResult<T> =
39    std::result::Result<T, Box<dyn std::error::Error + Send + Sync + 'static>>;