pub struct NotifierRegistry { /* private fields */ }Expand description
Runtime-side registry of notifier plugins keyed by name, plus the routing table that decides which plugins receive each priority.
Constructed in ao-cli (Phase C) after plugin instantiation,
attached to ReactionEngine via with_notifier_registry (Phase B).
Existing call sites that don’t attach one keep working — identical
opt-in pattern to ReactionEngine::with_scm.
§Warn-once policy
resolve logs exactly one tracing::warn! per distinct
(priority, notifier_name) pair across the process lifetime, so a
typo in the routing table can’t spam the log on every poll tick.
Matches the dedup pattern used by
reaction_engine::warn_once_parse_failure for malformed durations.
Implementations§
Source§impl NotifierRegistry
impl NotifierRegistry
Sourcepub fn new(routing: NotificationRouting) -> Self
pub fn new(routing: NotificationRouting) -> Self
Construct an empty registry with the given routing table. Plugins
are added via register.
Sourcepub fn register(&mut self, name: impl Into<String>, plugin: Arc<dyn Notifier>)
pub fn register(&mut self, name: impl Into<String>, plugin: Arc<dyn Notifier>)
Register a plugin under a name. Overwrites any existing entry
for the same name — tests rely on this to stub plugins with
replacements. Production wiring in ao-cli registers each
plugin exactly once at startup.
Sourcepub fn get(&self, name: &str) -> Option<Arc<dyn Notifier>>
pub fn get(&self, name: &str) -> Option<Arc<dyn Notifier>>
Look up a plugin by name without going through routing.
Primarily useful for ao-cli smoke tests and for future phases
that may want direct-addressed notifications.
Sourcepub fn resolve(
&self,
priority: EventPriority,
) -> Vec<(String, Arc<dyn Notifier>)>
pub fn resolve( &self, priority: EventPriority, ) -> Vec<(String, Arc<dyn Notifier>)>
Resolve a priority against the routing table, returning the
(name, plugin) pairs the engine should dispatch to.
Empty return vec means “do nothing for this priority”. That happens in three cases, all of which trigger a warn-once:
- Priority missing from the routing table entirely.
- Priority present but points at an empty list.
- The routing table names one or more plugins that are not registered — the registered subset (if any) is returned and the missing names are each warned once.
Case 3 can return a non-empty vec (the registered subset) even though some of the configured names were missing. That is deliberate: a partially-wired routing table should still deliver to the plugins that DO exist, not fail closed.