pub struct BackendManager { /* private fields */ }Expand description
Manages storage backends with per-table backend selection.
Each table gets its own backend instance. Multiple applications safely share databases. Uses LRU cache for bounded memory on backend type validation.
Implementations§
Source§impl BackendManager
impl BackendManager
Sourcepub fn from_backends(
table_backends: HashMap<String, Arc<dyn KvBackend>>,
) -> Result<Self>
pub fn from_backends( table_backends: HashMap<String, Arc<dyn KvBackend>>, ) -> Result<Self>
Create from pre-built backends.
Sourcepub fn set_transaction_log(&self, log: TransactionLogHandle)
pub fn set_transaction_log(&self, log: TransactionLogHandle)
Set the unified transaction log. Can only be called once
(uses OnceLock). Called at startup once the deployment’s
transaction-log backend
({root_directory}/logs/transactions/{deployment_hash}/)
has been opened and a TransactionLog impl built on top.
Sourcepub fn transaction_log(&self) -> Option<&TransactionLogHandle>
pub fn transaction_log(&self) -> Option<&TransactionLogHandle>
Get the unified transaction log, if set. Audit readers, replication senders, and any future log consumer use this to reach the durable record of every committed write.
Sourcepub fn set_observer_registry(&self, registry: Arc<ObserverRegistry>)
pub fn set_observer_registry(&self, registry: Arc<ObserverRegistry>)
Set the shared ObserverRegistry. Can only be called once
(uses OnceLock). Called at startup once the same Arc has
been threaded into every per-table LoggingBackend via
LogWrapping.observers, so this is the manager-side handle
to the same instance.
Sourcepub fn observer_registry(&self) -> Option<&Arc<ObserverRegistry>>
pub fn observer_registry(&self) -> Option<&Arc<ObserverRegistry>>
Get the shared observer registry, if set. Plugins (replication,
audit, etc.) register their TransactionObserver here during
startup; every per-table LoggingBackend reads the same
snapshot on its commit path.
Sourcepub fn register_observer(&self, observer: ObserverHandle)
pub fn register_observer(&self, observer: ObserverHandle)
Convenience: register an observer on the shared registry. No-op when no registry has been attached.
Sourcepub fn set_pubsub(&self, pubsub: Arc<PubSubManager>)
pub fn set_pubsub(&self, pubsub: Arc<PubSubManager>)
Set the PubSub manager. Can only be called once (uses OnceLock).
Called at startup after BackendManager is created and wrapped in Arc.
Sourcepub fn pubsub(&self) -> Option<&Arc<PubSubManager>>
pub fn pubsub(&self) -> Option<&Arc<PubSubManager>>
Get the PubSub manager, if set.
Sourcepub fn set_table_defs(&self, defs: HashMap<String, Arc<TableDefinition>>)
pub fn set_table_defs(&self, defs: HashMap<String, Arc<TableDefinition>>)
Attach the per-table source TableDefinitions
(keyed by table name). Set once at construction so downstream
consumers — replication’s @distribute filter, the router’s
@export flags — read this single source of truth rather than a
side-channel map. Can only be set once (uses OnceLock).
Sourcepub fn table_def(&self, table_name: &str) -> Option<Arc<TableDefinition>>
pub fn table_def(&self, table_name: &str) -> Option<Arc<TableDefinition>>
The source TableDefinition for table_name, if known. None when
defs weren’t attached (test fixtures) or the table is unknown.
Sourcepub fn set_vector(&self, vector: Arc<VectorContext>)
pub fn set_vector(&self, vector: Arc<VectorContext>)
Set the per-app vector context. Can only be called once (uses OnceLock).
Called at startup after vector hooks and batcher are configured.
Sourcepub fn vector(&self) -> Option<&Arc<VectorContext>>
pub fn vector(&self) -> Option<&Arc<VectorContext>>
Get the per-app vector context, if set.
Sourcepub fn with_merged_tables(&self, other: &Self) -> Self
pub fn with_merged_tables(&self, other: &Self) -> Self
Create a new manager with this manager’s tables plus additional tables.
Sourcepub fn with_qualified_merge(&self, other: &Self, database: &str) -> Self
pub fn with_qualified_merge(&self, other: &Self, database: &str) -> Self
Merge another manager’s tables with database-qualified keys.
Sourcepub fn set_index_registry(&self, registry: Arc<dyn Any + Send + Sync>)
pub fn set_index_registry(&self, registry: Arc<dyn Any + Send + Sync>)
Set the per-app secondary-index registry. Type-erased so this crate
stays free of yeti-sdk imports — yeti-sdk’s Tables::get does the
downcast. Can only be called once (uses OnceLock). Called at
startup once IndexManagers are built from the loaded schema.
Sourcepub fn index_registry(&self) -> Option<&Arc<dyn Any + Send + Sync>>
pub fn index_registry(&self) -> Option<&Arc<dyn Any + Send + Sync>>
Get the per-app secondary-index registry, if set. Callers (yeti-sdk)
downcast to their concrete HashMap<String, Arc<IndexManager>>.
Sourcepub fn table_names(&self) -> Vec<String>
pub fn table_names(&self) -> Vec<String>
List all table names managed by this BackendManager.
Sourcepub fn get_backend_for_table(
&self,
table_name: &str,
) -> Result<Arc<dyn KvBackend>>
pub fn get_backend_for_table( &self, table_name: &str, ) -> Result<Arc<dyn KvBackend>>
Get the storage backend for a specific table by name.
Sourcepub async fn health_probe(&self) -> Result<()>
pub async fn health_probe(&self) -> Result<()>
Probe storage health by performing lightweight reads across all backends.
Sourcepub async fn validate_table_backend(
&self,
table_name: &str,
key_prefix: &str,
expected_backend: BackendType,
) -> Result<()>
pub async fn validate_table_backend( &self, table_name: &str, key_prefix: &str, expected_backend: BackendType, ) -> Result<()>
Validate that a table is using the correct backend.