pub struct ObserverRegistry { /* private fields */ }Expand description
Shared, lock-free registry of TransactionObservers.
One registry instance lives per-deployment process, held by
BackendManager and cloned into every LoggingBackend so the
commit path can fan out without coordination. The internal
snapshot is swapped via arc_swap::ArcSwap: registration takes
a brief write, every commit-path read is wait-free.
Registration happens during deployment startup before traffic is accepted. The contract assumes near-zero registrations after startup completes; nothing in the type enforces that, but the trait doc’s “registration order matters” + “registered first fires first” promises hold as long as registration is startup-serialized.
Implementations§
Source§impl ObserverRegistry
impl ObserverRegistry
Sourcepub fn register(&self, observer: ObserverHandle)
pub fn register(&self, observer: ObserverHandle)
Register an observer. Appends to the end of the snapshot so registration order is preserved (replication first, audit second per the trait doc).
Sourcepub fn snapshot(&self) -> Arc<Vec<ObserverHandle>> ⓘ
pub fn snapshot(&self) -> Arc<Vec<ObserverHandle>> ⓘ
Snapshot of the currently-registered observers. Cheap (Arc
clone) — call from the commit path on every write.
Sourcepub fn requirements(&self) -> ObserverRequirements
pub fn requirements(&self) -> ObserverRequirements
Computed union of all registered observers’ requirements. Recomputed on each call; cache at the caller if hot.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
true if no observers are registered. Commit paths can use
this to skip building the TransactionEvent entirely.