Expand description
Bulkhead pattern implementation for storage operations.
Provides concurrency limiting to prevent resource exhaustion when making parallel storage calls. Uses a semaphore-based approach to limit the number of concurrent operations.
§Why Bulkhead for Storage?
The bulkhead pattern isolates storage operations and prevents cascading resource exhaustion:
- Connection pools: Prevents pool exhaustion under load
- File handles:
SQLitefile descriptor limits - Memory: Large batch operations can exhaust memory
- I/O bandwidth: Prevents I/O saturation
§Architecture
This module uses a generic Bulkhead<T> struct that provides the core
concurrency limiting logic. Backend-specific wrappers (BulkheadPersistenceBackend,
BulkheadIndexBackend, BulkheadVectorBackend) delegate to this shared
implementation while providing trait implementations for their respective
backend traits.
§Usage
ⓘ
use subcog::storage::{BulkheadPersistenceBackend, StorageBulkheadConfig};
let backend = SqlitePersistence::new(...)?;
let bulkhead = BulkheadPersistenceBackend::new(
backend,
StorageBulkheadConfig::default(),
"sqlite"
);
// Only 10 concurrent operations allowed (default)
bulkhead.store(&memory)?;Structs§
- Bulkhead
- Generic bulkhead wrapper providing concurrency limiting for any type.
- Bulkhead
Index Backend - Index backend wrapper with bulkhead (concurrency limiting) pattern.
- Bulkhead
Persistence Backend - Persistence backend wrapper with bulkhead (concurrency limiting) pattern.
- Bulkhead
Vector Backend - Vector backend wrapper with bulkhead (concurrency limiting) pattern.
- Storage
Bulkhead Config - Configuration for the storage bulkhead pattern.
Functions§
- capitalize_
first 🔒 - Capitalizes the first letter of a string.