Skip to main content

BackendManager

Struct BackendManager 

Source
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

Source

pub fn empty() -> Self

Create an empty BackendManager for testing.

Source

pub fn from_backends( table_backends: HashMap<String, Arc<dyn KvBackend>>, ) -> Result<Self>

Create from pre-built backends.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn register_observer(&self, observer: ObserverHandle)

Convenience: register an observer on the shared registry. No-op when no registry has been attached.

Source

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.

Source

pub fn pubsub(&self) -> Option<&Arc<PubSubManager>>

Get the PubSub manager, if set.

Source

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).

Source

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.

Source

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.

Source

pub fn vector(&self) -> Option<&Arc<VectorContext>>

Get the per-app vector context, if set.

Source

pub fn with_merged_tables(&self, other: &Self) -> Self

Create a new manager with this manager’s tables plus additional tables.

Source

pub fn with_qualified_merge(&self, other: &Self, database: &str) -> Self

Merge another manager’s tables with database-qualified keys.

Source

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.

Source

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>>.

Source

pub fn table_names(&self) -> Vec<String>

List all table names managed by this BackendManager.

Source

pub fn get_backend_for_table( &self, table_name: &str, ) -> Result<Arc<dyn KvBackend>>

Get the storage backend for a specific table by name.

Source

pub async fn health_probe(&self) -> Result<()>

Probe storage health by performing lightweight reads across all backends.

Source

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.

Trait Implementations§

Source§

impl Debug for BackendManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more