pub struct StoreRouter { /* private fields */ }Expand description
Registers named SchedulerStore backends at host boot.
Use for multi-store hosts or a single default via DEFAULT_STORE_NAME. Typical Mode 1
flow:
Self::register_global(orinstall_default_mem_storefrom the mem backend).ChrononBuilder::scheduler_store_from_global().
Prefer passing a store directly to ChrononBuilder::scheduler_store in Mode 2/3 when each
binary already shares connection URLs — the global router is optional convenience for
single-process boots, not a substitute for a shared durable database.
Thread-safe when accessed through Self::register_global / default_store_from_global;
direct mutation requires exclusive access to the router instance.
§Examples
StoreRouter::register_global(DEFAULT_STORE_NAME, store);Runnable end-to-end: cargo run -p uf-chronon --example store_router_boot --features mem.
Implementations§
Source§impl StoreRouter
impl StoreRouter
Sourcepub fn register(
&mut self,
name: impl Into<String>,
store: Arc<dyn SchedulerStore>,
)
pub fn register( &mut self, name: impl Into<String>, store: Arc<dyn SchedulerStore>, )
Register a store under a logical name (overwrites any previous entry).
Sourcepub fn get(&self, name: &str) -> Option<Arc<dyn SchedulerStore>>
pub fn get(&self, name: &str) -> Option<Arc<dyn SchedulerStore>>
Resolve a registered store by name.
Sourcepub fn install_global(router: Self)
pub fn install_global(router: Self)
Replace the process-global router (typically once at startup).
Subsequent calls are ignored; the first successful install wins.
Sourcepub fn register_global(name: impl Into<String>, store: Arc<dyn SchedulerStore>)
pub fn register_global(name: impl Into<String>, store: Arc<dyn SchedulerStore>)
Register a store on the process-global router.
§Examples
StoreRouter::register_global(DEFAULT_STORE_NAME, store);Panics if the global router lock is poisoned.