pub struct StorageManager { /* private fields */ }Expand description
Storage manager coordinating multiple backends
Implementations§
Source§impl StorageManager
impl StorageManager
Sourcepub fn new(routing_strategy: RoutingStrategy) -> Self
pub fn new(routing_strategy: RoutingStrategy) -> Self
Create a new storage manager
Sourcepub fn with_primary(self, backend: Arc<AnyStorage>) -> Self
pub fn with_primary(self, backend: Arc<AnyStorage>) -> Self
Set primary storage backend
Sourcepub fn with_cache(self, backend: Arc<AnyStorage>) -> Self
pub fn with_cache(self, backend: Arc<AnyStorage>) -> Self
Set cache backend
Sourcepub fn with_secondary(self, backend: Arc<AnyStorage>) -> Self
pub fn with_secondary(self, backend: Arc<AnyStorage>) -> Self
Set secondary backend
Sourcepub fn with_fallback(self, enable: bool) -> Self
pub fn with_fallback(self, enable: bool) -> Self
Enable or disable automatic fallback
Sourcepub async fn state(&self) -> ManagerState
pub async fn state(&self) -> ManagerState
Get current state
Sourcepub async fn manager_stats(&self) -> ManagerStats
pub async fn manager_stats(&self) -> ManagerStats
Get manager statistics
Sourcepub async fn add_backend(&self, backend: Arc<AnyStorage>) -> StorageResult<()>
pub async fn add_backend(&self, backend: Arc<AnyStorage>) -> StorageResult<()>
Add a backend dynamically
Sourcepub async fn remove_backend(
&self,
backend_type: StorageBackend,
) -> StorageResult<()>
pub async fn remove_backend( &self, backend_type: StorageBackend, ) -> StorageResult<()>
Remove a backend
Sourcepub async fn get_backend(
&self,
backend_type: StorageBackend,
) -> Option<Arc<AnyStorage>>
pub async fn get_backend( &self, backend_type: StorageBackend, ) -> Option<Arc<AnyStorage>>
Get backend by type
Sourcepub async fn list_backends(&self) -> Vec<StorageBackend>
pub async fn list_backends(&self) -> Vec<StorageBackend>
List all available backends
Sourcepub async fn initialize(&mut self) -> StorageResult<()>
pub async fn initialize(&mut self) -> StorageResult<()>
Initialize all backends
Sourcepub async fn shutdown(&mut self) -> StorageResult<()>
pub async fn shutdown(&mut self) -> StorageResult<()>
Shutdown all backends
Sourcepub async fn health_check_all(&self) -> HashMap<StorageBackend, StorageHealth>
pub async fn health_check_all(&self) -> HashMap<StorageBackend, StorageHealth>
Health check all backends
Sourcepub async fn stats_all(&self) -> HashMap<StorageBackend, StorageStats>
pub async fn stats_all(&self) -> HashMap<StorageBackend, StorageStats>
Get statistics from all backends
Trait Implementations§
Source§impl Debug for StorageManager
impl Debug for StorageManager
Source§impl Storage for StorageManager
impl Storage for StorageManager
Source§fn backend(&self) -> StorageBackend
fn backend(&self) -> StorageBackend
Get backend type
Source§fn metadata<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<StorageMetadata>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn metadata<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<StorageMetadata>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get storage metadata
Source§fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<StorageHealth>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<StorageHealth>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Health check
Source§fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<StorageStats>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<StorageStats>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get statistics
Source§fn insert<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
value: &'life3 T,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
T: 'async_trait + Serialize + DeserializeOwned + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn insert<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
value: &'life3 T,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
T: 'async_trait + Serialize + DeserializeOwned + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Insert a new entry
Source§fn insert_with_ttl<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
value: &'life3 T,
ttl_seconds: i64,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
fn insert_with_ttl<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, value: &'life3 T, ttl_seconds: i64, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
Insert entry with TTL (time-to-live in seconds)
Source§fn get<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = StorageResult<Option<StorageEntry<T>>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Serialize + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = StorageResult<Option<StorageEntry<T>>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Serialize + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Get an entry by key
Source§fn update<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
value: &'life3 T,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
fn update<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, value: &'life3 T, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
Update an existing entry
Source§fn update_versioned<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
value: &'life3 T,
expected_version: u64,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
fn update_versioned<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, value: &'life3 T, expected_version: u64, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
Update entry with optimistic locking (version check)
Source§fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Delete an entry
Source§fn exists<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn exists<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Check if entry exists
Source§fn execute_batch<'life0, 'async_trait>(
&'life0 self,
batch: Batch,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute_batch<'life0, 'async_trait>(
&'life0 self,
batch: Batch,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute batch operations
Source§fn query<'life0, 'async_trait, T>(
&'life0 self,
query: Query,
) -> Pin<Box<dyn Future<Output = StorageResult<Vec<StorageEntry<T>>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Serialize + Send + Sync + 'static,
Self: 'async_trait,
'life0: 'async_trait,
fn query<'life0, 'async_trait, T>(
&'life0 self,
query: Query,
) -> Pin<Box<dyn Future<Output = StorageResult<Vec<StorageEntry<T>>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Serialize + Send + Sync + 'static,
Self: 'async_trait,
'life0: 'async_trait,
Query entries matching criteria
Source§fn count<'life0, 'async_trait>(
&'life0 self,
query: Query,
) -> Pin<Box<dyn Future<Output = StorageResult<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn count<'life0, 'async_trait>(
&'life0 self,
query: Query,
) -> Pin<Box<dyn Future<Output = StorageResult<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Count entries matching criteria
Source§fn begin_transaction<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<Transaction>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn begin_transaction<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<Transaction>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Begin a transaction
Source§fn commit_transaction<'life0, 'async_trait>(
&'life0 self,
transaction: Transaction,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn commit_transaction<'life0, 'async_trait>(
&'life0 self,
transaction: Transaction,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Commit a transaction
Source§fn rollback_transaction<'life0, 'async_trait>(
&'life0 self,
transaction: Transaction,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn rollback_transaction<'life0, 'async_trait>(
&'life0 self,
transaction: Transaction,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Rollback a transaction
Source§fn scan_prefix<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
prefix: &'life2 str,
) -> Pin<Box<dyn Future<Output = StorageResult<Vec<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn scan_prefix<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
prefix: &'life2 str,
) -> Pin<Box<dyn Future<Output = StorageResult<Vec<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Scan keys with prefix
Source§fn get_multi<'life0, 'life1, 'async_trait, T>(
&'life0 self,
table: &'life1 str,
keys: Vec<String>,
) -> Pin<Box<dyn Future<Output = StorageResult<Vec<Option<StorageEntry<T>>>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Serialize + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_multi<'life0, 'life1, 'async_trait, T>(
&'life0 self,
table: &'life1 str,
keys: Vec<String>,
) -> Pin<Box<dyn Future<Output = StorageResult<Vec<Option<StorageEntry<T>>>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Serialize + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get multiple entries by keys
Source§fn delete_multi<'life0, 'life1, 'async_trait>(
&'life0 self,
table: &'life1 str,
keys: Vec<String>,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_multi<'life0, 'life1, 'async_trait>(
&'life0 self,
table: &'life1 str,
keys: Vec<String>,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete multiple entries
Source§fn compare_and_swap<'life0, 'life1, 'life2, 'life3, 'async_trait, T>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
expected_version: u64,
new_value: &'life3 T,
) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
fn compare_and_swap<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, table: &'life1 str, key: &'life2 str, expected_version: u64, new_value: &'life3 T, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
Atomic compare-and-swap
Source§fn get_modified_since<'life0, 'life1, 'async_trait, T>(
&'life0 self,
table: &'life1 str,
since: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = StorageResult<Vec<StorageEntry<T>>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Serialize + Send + Sync + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_modified_since<'life0, 'life1, 'async_trait, T>(
&'life0 self,
table: &'life1 str,
since: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = StorageResult<Vec<StorageEntry<T>>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Serialize + Send + Sync + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get entries modified after timestamp
Source§fn get_expiring_before<'life0, 'life1, 'async_trait, T>(
&'life0 self,
table: &'life1 str,
before: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = StorageResult<Vec<StorageEntry<T>>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Serialize + Send + Sync + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_expiring_before<'life0, 'life1, 'async_trait, T>(
&'life0 self,
table: &'life1 str,
before: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = StorageResult<Vec<StorageEntry<T>>>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Serialize + Send + Sync + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get entries that expire before timestamp
Source§fn cleanup_expired<'life0, 'life1, 'async_trait>(
&'life0 self,
table: &'life1 str,
) -> Pin<Box<dyn Future<Output = StorageResult<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn cleanup_expired<'life0, 'life1, 'async_trait>(
&'life0 self,
table: &'life1 str,
) -> Pin<Box<dyn Future<Output = StorageResult<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Cleanup expired entries
Source§fn compact<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn compact<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Compact storage (if supported)
Source§fn flush<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn flush<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Flush pending writes
Source§fn initialize<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn initialize<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Initialize storage
Auto Trait Implementations§
impl !RefUnwindSafe for StorageManager
impl !UnwindSafe for StorageManager
impl Freeze for StorageManager
impl Send for StorageManager
impl Sync for StorageManager
impl Unpin for StorageManager
impl UnsafeUnpin for StorageManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.