pub struct SubscriptionRegistry { /* private fields */ }Expand description
Registry managing all active subscriptions.
Thread-safe via internal RwLock. Read operations (used by the Ring 1
dispatcher) take a read lock. Write operations (create/cancel) take a write
lock but are rare Ring 2 operations.
Three indices provide O(1) lookups:
subscriptions: bySubscriptionIdby_source: bysource_id(u32) — used by the dispatcherby_name: by source name (String) — used by admin API
§Panics
All methods on this type panic if an internal RwLock has been poisoned
(i.e., a thread panicked while holding the lock). This should not occur
under normal operation.
Implementations§
Source§impl SubscriptionRegistry
impl SubscriptionRegistry
Sourcepub fn create(
&self,
source_name: String,
source_id: u32,
config: SubscriptionConfig,
) -> (SubscriptionId, Receiver<ChangeEvent>)
pub fn create( &self, source_name: String, source_id: u32, config: SubscriptionConfig, ) -> (SubscriptionId, Receiver<ChangeEvent>)
Creates a new subscription for the given source.
Returns the subscription ID and a broadcast Receiver
that the subscriber uses to receive ChangeEvents.
§Arguments
source_name— Name of the MV or streaming query.source_id— Ring 0 source identifier (fromNotificationHub).config— Subscription configuration (buffer size, backpressure, etc.).
Sourcepub fn pause(&self, id: SubscriptionId) -> bool
pub fn pause(&self, id: SubscriptionId) -> bool
Pauses an active subscription.
Returns true if the subscription was Active and is now Paused.
Returns false if the subscription does not exist or is not active.
Sourcepub fn resume(&self, id: SubscriptionId) -> bool
pub fn resume(&self, id: SubscriptionId) -> bool
Resumes a paused subscription.
Returns true if the subscription was Paused and is now Active.
Returns false if the subscription does not exist or is not paused.
Sourcepub fn cancel(&self, id: SubscriptionId) -> bool
pub fn cancel(&self, id: SubscriptionId) -> bool
Cancels a subscription and removes it from all indices.
Returns true if the subscription existed and was removed.
Sourcepub fn get_senders_for_source(&self, source_id: u32) -> Vec<Sender<ChangeEvent>>
pub fn get_senders_for_source(&self, source_id: u32) -> Vec<Sender<ChangeEvent>>
Returns broadcast senders for all active subscriptions of a source.
Called by the Ring 1 dispatcher on every notification. Uses a read lock for fast concurrent access.
Sourcepub fn get_subscriptions_by_name(&self, name: &str) -> Vec<SubscriptionId>
pub fn get_subscriptions_by_name(&self, name: &str) -> Vec<SubscriptionId>
Returns subscription IDs for the given source name.
Sourcepub fn subscription_count(&self) -> usize
pub fn subscription_count(&self) -> usize
Returns the total number of registered subscriptions.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Returns the number of active subscriptions.
Sourcepub fn metrics(&self, id: SubscriptionId) -> Option<SubscriptionMetrics>
pub fn metrics(&self, id: SubscriptionId) -> Option<SubscriptionMetrics>
Returns a metrics snapshot for the given subscription.
Sourcepub fn state(&self, id: SubscriptionId) -> Option<SubscriptionState>
pub fn state(&self, id: SubscriptionId) -> Option<SubscriptionState>
Returns the state of a subscription.
Sourcepub fn record_delivery(&self, id: SubscriptionId, count: u64)
pub fn record_delivery(&self, id: SubscriptionId, count: u64)
Increments the delivered event count for a subscription.
Called by the Ring 1 dispatcher after successful delivery.
Sourcepub fn record_drop(&self, id: SubscriptionId, count: u64)
pub fn record_drop(&self, id: SubscriptionId, count: u64)
Increments the dropped event count for a subscription.
Called by the Ring 1 dispatcher on backpressure.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SubscriptionRegistry
impl RefUnwindSafe for SubscriptionRegistry
impl Send for SubscriptionRegistry
impl Sync for SubscriptionRegistry
impl Unpin for SubscriptionRegistry
impl UnwindSafe for SubscriptionRegistry
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.