Skip to main content

Module bulkhead

Module bulkhead 

Source
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: SQLite file 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.
BulkheadIndexBackend
Index backend wrapper with bulkhead (concurrency limiting) pattern.
BulkheadPersistenceBackend
Persistence backend wrapper with bulkhead (concurrency limiting) pattern.
BulkheadVectorBackend
Vector backend wrapper with bulkhead (concurrency limiting) pattern.
StorageBulkheadConfig
Configuration for the storage bulkhead pattern.

Functions§

capitalize_first 🔒
Capitalizes the first letter of a string.