pub struct SubscriptionRegistry { /* private fields */ }Expand description
In-memory registry of event subscriptions.
Reconstructed from WAL events at bootstrap via SubscriptionRegistry::register,
SubscriptionRegistry::trigger, and SubscriptionRegistry::cancel calls.
Maintains a secondary task_subscriptions index for O(S) per-task lookups
where S is the number of subscriptions for that task (not O(N) total).
Implementations§
Source§impl SubscriptionRegistry
impl SubscriptionRegistry
Sourcepub fn register(
&mut self,
subscription_id: SubscriptionId,
task_id: TaskId,
filter: EventFilter,
)
pub fn register( &mut self, subscription_id: SubscriptionId, task_id: TaskId, filter: EventFilter, )
Registers a new active subscription.
Sourcepub fn trigger(&mut self, subscription_id: SubscriptionId)
pub fn trigger(&mut self, subscription_id: SubscriptionId)
Marks a subscription as triggered (promotion eligible).
Sourcepub fn cancel(&mut self, subscription_id: SubscriptionId)
pub fn cancel(&mut self, subscription_id: SubscriptionId)
Marks a subscription as canceled (no longer active).
Sourcepub fn active_subscriptions(
&self,
) -> impl Iterator<Item = (SubscriptionId, &SubscriptionEntry)>
pub fn active_subscriptions( &self, ) -> impl Iterator<Item = (SubscriptionId, &SubscriptionEntry)>
Returns an iterator over non-canceled, non-triggered active subscriptions.
Sourcepub fn is_triggered(&self, task_id: TaskId) -> bool
pub fn is_triggered(&self, task_id: TaskId) -> bool
Returns true if any subscription for this task has been triggered.
O(S) where S = number of subscriptions for this task (via secondary index).
Sourcepub fn clear_triggered(&mut self, task_id: TaskId)
pub fn clear_triggered(&mut self, task_id: TaskId)
Clears the triggered flag for all triggered subscriptions for this task.
Called after the task has been promoted to Ready so the one-shot trigger is consumed and won’t re-promote on the next tick.
O(S) where S = number of subscriptions for this task (via secondary index).
Sourcepub fn gc_task(&mut self, task_id: TaskId)
pub fn gc_task(&mut self, task_id: TaskId)
Removes all subscription state for a fully-terminal task.
Called by the dispatch loop after a task reaches terminal state. Removes all subscriptions (including canceled ones) from both the primary map and the secondary index.
Sourcepub fn get(
&self,
subscription_id: &SubscriptionId,
) -> Option<&SubscriptionEntry>
pub fn get( &self, subscription_id: &SubscriptionId, ) -> Option<&SubscriptionEntry>
Returns the subscription entry for the given ID.