Skip to main content

SubscriptionRegistry

Struct SubscriptionRegistry 

Source
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

Source

pub fn new() -> Self

Creates an empty registry.

Source

pub fn register( &mut self, subscription_id: SubscriptionId, task_id: TaskId, filter: EventFilter, )

Registers a new active subscription.

Source

pub fn trigger(&mut self, subscription_id: SubscriptionId)

Marks a subscription as triggered (promotion eligible).

Source

pub fn cancel(&mut self, subscription_id: SubscriptionId)

Marks a subscription as canceled (no longer active).

Source

pub fn active_subscriptions( &self, ) -> impl Iterator<Item = (SubscriptionId, &SubscriptionEntry)>

Returns an iterator over non-canceled, non-triggered active subscriptions.

Source

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).

Source

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).

Source

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.

Source

pub fn get( &self, subscription_id: &SubscriptionId, ) -> Option<&SubscriptionEntry>

Returns the subscription entry for the given ID.

Trait Implementations§

Source§

impl Debug for SubscriptionRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SubscriptionRegistry

Source§

fn default() -> SubscriptionRegistry

Returns the “default value” for a type. Read more
Source§

impl SubscriptionSource for SubscriptionRegistry

Source§

fn active_subscriptions_iter( &self, ) -> impl Iterator<Item = (SubscriptionId, &EventFilter)> + '_

Returns an iterator over (subscription_id, filter) pairs for all active (non-canceled, non-triggered) subscriptions.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more