pub struct Supervisor { /* private fields */ }Expand description
Per-rule subscription supervisor.
Manages one scryer subscription per enabled rule plus federation fan-out.
Drives dedup and rate filtering before surfacing FiredEvents to the
dispatch engine (F4).
The supervisor is driven by polling (poll()). The P2 async runtime calls
poll() in a tokio task; tests call it synchronously.
Implementations§
Source§impl Supervisor
impl Supervisor
pub fn new( local_source: Arc<dyn SubscriptionSource>, peer_registry: Arc<dyn PeerRegistry>, dedup_capacity: usize, backpressure_limit: usize, ) -> Self
Sourcepub fn load_rule(&mut self, rule: TowerRule) -> Result<bool, CompileError>
pub fn load_rule(&mut self, rule: TowerRule) -> Result<bool, CompileError>
Load a rule and open its subscription(s).
Returns Ok(true) if the rule was loaded (enabled), Ok(false) if
skipped (disabled), or Err(CompileError) if the predicate is invalid.
Sourcepub fn disable_rule(&mut self, id: &RuleId) -> bool
pub fn disable_rule(&mut self, id: &RuleId) -> bool
Disable a rule and close its subscription(s).
Subscriptions are closed by dropping the RuleEntry (which drops the
Box<dyn EventStream> handles). Returns true if the rule was found.
Sourcepub fn update_rule(&mut self, rule: TowerRule) -> Result<(), CompileError>
pub fn update_rule(&mut self, rule: TowerRule) -> Result<(), CompileError>
Hot-reload a rule: close the existing subscription and open a new one.
Called by the config-file watcher (F6) when a rule file is edited on disk. If the updated rule is disabled, the old subscription is closed without opening a replacement.
Sourcepub fn poll(&mut self) -> (Vec<FiredEvent>, Vec<SubscriptionHealth>)
pub fn poll(&mut self) -> (Vec<FiredEvent>, Vec<SubscriptionHealth>)
Poll all active subscriptions and surface FiredEvents.
Reads up to backpressure_limit events per rule stream, applies the
compiled filter, dedup ring, and rate window. Returns
(fired_events, health_events) — both may be empty.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Number of currently active (enabled + subscribed) rules.