Skip to main content

Supervisor

Struct Supervisor 

Source
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

Source

pub fn new( local_source: Arc<dyn SubscriptionSource>, peer_registry: Arc<dyn PeerRegistry>, dedup_capacity: usize, backpressure_limit: usize, ) -> Self

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn active_count(&self) -> usize

Number of currently active (enabled + subscribed) rules.

Source

pub fn is_active(&self, id: &RuleId) -> bool

Whether a rule is currently active.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.