Expand description
Storage resilience wrapper with circuit breaking.
Provides circuit breaker protection for storage backends to prevent cascade failures when backends become unhealthy.
§Circuit Breaker States
+--------+ failures >= threshold +------+
| Closed | ---------------------------> | Open |
+--------+ +------+
^ |
| success | timeout elapsed
| v
+-------------------------------- +-----------+
| Half-Open |
+-----------+§Usage
ⓘ
use subcog::storage::resilience::{StorageResilienceConfig, ResilientPersistenceBackend};
use subcog::storage::index::SqliteBackend;
let backend = SqliteBackend::new(db_path)?;
let config = StorageResilienceConfig::default();
let resilient = ResilientPersistenceBackend::new(backend, config, "sqlite");
// Operations are now protected by circuit breaker
resilient.store(&memory)?;Structs§
- Circuit
Breaker - Circuit breaker for storage backends.
- Resilient
Index Backend - Index backend wrapper with circuit breaker and retry protection.
- Resilient
Persistence Backend - Persistence backend wrapper with circuit breaker and retry protection.
- Resilient
Vector Backend - Vector backend wrapper with circuit breaker and retry protection.
- Storage
Resilience Config - Resilience configuration for storage backends.
Enums§
- Breaker
State 🔒 - Circuit breaker state machine.
Functions§
- calculate_
jitter 🔒 - Calculates jitter for retry backoff using system time as pseudo-random source.
- calculate_
retry_ 🔒delay - Calculates retry delay with exponential backoff and jitter.
- is_
retryable_ 🔒connection_ error - Checks if a connection error is retryable.
- is_
retryable_ storage_ error - Checks if a storage error is retryable (transient failures that may succeed on retry).
- retry_
connection - Executes a connection operation with retry and exponential backoff.