pub struct TriggerRegistry { /* private fields */ }Expand description
In-memory cache + persistent backing of the trigger
registry. Mutating operations (install / drop) write
through to storage; reads served from the cache. The
Arc<dyn StorageEngine> is held internally so the
procedure call surface only needs the registry handle —
not a separate store reference — to mutate the persistent
state.
Implementations§
Source§impl TriggerRegistry
impl TriggerRegistry
Sourcepub fn from_storage(store: Arc<dyn StorageEngine>) -> Result<Self>
pub fn from_storage(store: Arc<dyn StorageEngine>) -> Result<Self>
Hydrate from the storage backend on startup. Skips any blob that fails to deserialise — a corrupted entry should surface a warning but not refuse to start the server.
Sourcepub fn install(&self, spec: TriggerSpec) -> Result<Option<TriggerSpec>>
pub fn install(&self, spec: TriggerSpec) -> Result<Option<TriggerSpec>>
Persist a new trigger and add it to the cache. Returns the previous spec under the same name, if any (so the caller can report install-replaced-existing).
Sourcepub fn drop(&self, name: &str) -> Result<Option<TriggerSpec>>
pub fn drop(&self, name: &str) -> Result<Option<TriggerSpec>>
Drop by name. Returns the previous spec when one
existed; Ok(None) is the no-op case.
Sourcepub fn list(&self) -> Vec<TriggerSpec>
pub fn list(&self) -> Vec<TriggerSpec>
Snapshot every registered trigger in deterministic (name-sorted) order.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
true when at least one trigger is registered. Lets the
commit hook short-circuit the diff computation when no
trigger could possibly fire.
Sourcepub fn refresh(&self) -> Result<()>
pub fn refresh(&self) -> Result<()>
Reload the in-memory cache from storage. Called by the
Raft applier and the routing-mode trigger fan-out after
they apply an InstallTrigger / DropTrigger command,
so a peer that wasn’t the original install/drop site
still sees the change immediately. Failures are surfaced
to the caller — the applier logs them, since by that
point the storage write has already succeeded.
Trait Implementations§
Source§impl Clone for TriggerRegistry
impl Clone for TriggerRegistry
Source§fn clone(&self) -> TriggerRegistry
fn clone(&self) -> TriggerRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more