Skip to main content

llm_optimizer_processor/storage/
mod.rs

1//! Storage module
2//!
3//! This module provides multi-backend storage capabilities with support for
4//! PostgreSQL, Redis, and Sled. It includes a unified Storage trait and
5//! a StorageManager for coordinating multiple backends.
6//!
7//! # Example
8//!
9//! ```rust,no_run
10//! use processor::storage::{StorageManager, RoutingStrategy};
11//!
12//! #[tokio::main]
13//! async fn main() -> anyhow::Result<()> {
14//!     // Create storage manager
15//!     let mut manager = StorageManager::new(RoutingStrategy::CacheAside);
16//!
17//!     // Initialize
18//!     manager.initialize().await?;
19//!
20//!     // Use storage
21//!     // ...
22//!
23//!     // Shutdown
24//!     manager.shutdown().await?;
25//!
26//!     Ok(())
27//! }
28//! ```
29
30pub mod config;
31pub mod error;
32pub mod manager;
33pub mod postgresql;
34pub mod redis;
35pub mod sled_backend;
36pub mod traits;
37pub mod types;
38
39// Re-export commonly used types
40
41// Core traits
42pub use traits::{
43    Backup, BackupMetadata, CacheStorage, CacheStats, KeyValueStorage, Migrator, Migration,
44    PubSubStorage, RelationalStorage, SqlParam, SqlResult, Storage, Subscriber,
45};
46
47// Configuration
48pub use config::{
49    MonitoringConfig, PoolConfig, PostgreSQLConfig, RedisConfig, RetryConfig, SSLMode, SledConfig,
50    SledMode, StorageConfig,
51};
52
53// Error types
54pub use error::{ErrorCategory, StorageError, StorageResult};
55
56// Types
57pub use types::{
58    Batch, Filter, Operation, Operator, Query, Sort, SortDirection, StorageBackend, StorageEntry,
59    StorageHealth, StorageMetadata, StorageStats, Transaction, TransactionState, Value,
60};
61
62// Manager
63pub use manager::{ManagerState, ManagerStats, RoutingStrategy, StorageManager};
64
65// Backend implementations
66pub use postgresql::PostgreSQLStorage;
67pub use redis::RedisStorage;
68pub use sled_backend::SledStorage;
69
70// Storage wrapper enum for dynamic dispatch
71mod wrapper;
72pub use wrapper::AnyStorage;