//! Resilience patterns for error handling and fault tolerance
//!
//! This module provides circuit breaker and retry patterns to handle
//! transient failures and prevent cascading failures in distributed systems.
//!
//! # Modules
//!
//! - `circuit_breaker`: Circuit breaker pattern implementation
//! - `retry`: Retry logic with exponential backoff
//!
//! # Example: Circuit Breaker
//!
//! ```rust
//! use common::resilience::circuit_breaker::{CircuitBreaker, CircuitBreakerConfig};
//! use std::time::Duration;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let config = CircuitBreakerConfig {
//!     failure_threshold: 5,
//!     timeout: Duration::from_secs(30),
//!     success_threshold: 2,
//! };
//!
//! let cb = CircuitBreaker::new("api_service", config);
//!
//! if cb.can_execute().await {
//!     // Execute operation
//!     cb.record_success().await;
//! } else {
//!     // Circuit is open - skip operation
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # Example: Retry with Backoff
//!
//! ```rust
//! use common::resilience::retry::{retry_with_backoff, RetryConfig};
//! use common::CommonError;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let result = retry_with_backoff(
//!     || async {
//!         // Your operation
//!         Ok::<_, CommonError>(42)
//!     },
//!     RetryConfig::default(),
//! ).await?;
//! # Ok(())
//! # }
//! ```

pub mod bounded_concurrency;
pub mod circuit_breaker;
pub mod integration_examples;
pub mod retry;

#[cfg(test)]
mod tests;

// Re-export commonly used types
pub use bounded_concurrency::{BoundedExecutor, BoundedExecutorError};
pub use circuit_breaker::{
    CircuitBreaker, CircuitBreakerConfig, CircuitBreakerState, CircuitBreakerTrait,
};
pub use retry::{retry_with_backoff, RetryConfig, RetryContext, RetryError};
