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
//! # Circuit Breaker Pattern for Storage Resilience
//!
//! Implements a production-grade circuit breaker to handle Turso failures gracefully.
//!
//! ## Circuit States
//!
//! - **Closed**: Normal operation, all requests pass through
//! - **Open**: Too many failures detected, requests fail immediately
//! - **Half-Open**: Testing if the service has recovered
//!
//! ## Configuration
//!
//! - Failure threshold: Configurable consecutive failures to open circuit
//! - Timeout: Duration before attempting recovery (OPEN -> `HALF_OPEN`)
//! - Half-open test period: Duration to test recovery before closing
//! - Exponential backoff: Progressive delays between retries
//!
//! ## Example
//!
//! ```no_run
//! use do_memory_core::storage::circuit_breaker::{CircuitBreaker, CircuitBreakerConfig};
//! use std::sync::Arc;
//!
//! # async fn example() -> anyhow::Result<()> {
//! let config = CircuitBreakerConfig::default();
//! let circuit_breaker = Arc::new(CircuitBreaker::new(config));
//!
//! // Execute operation with circuit breaker protection
//! let result = circuit_breaker.call(|| async {
//! // Your Turso operation here
//! Ok::<_, do_memory_core::Error>(())
//! }).await;
//! # Ok(())
//! # }
//! ```
pub use ;