pub struct NotificationRegistry { /* private fields */ }Expand description
In-memory registry of ephemeral notification channels.
The registry is Send + Sync and intended to live behind an
Arc on the runtime — typically one per server process. It
owns no on-disk state, no WAL entries, and no audit-event tail:
a process restart drops every channel and every connected
listener, which is the intended ephemeral contract.
Implementations§
Source§impl NotificationRegistry
impl NotificationRegistry
pub fn new() -> NotificationRegistry
Sourcepub fn subscribe(
&self,
scope: NotificationScope,
channel: impl Into<String>,
) -> Receiver<NotificationEvent>
pub fn subscribe( &self, scope: NotificationScope, channel: impl Into<String>, ) -> Receiver<NotificationEvent>
Subscribe to (scope, channel).
The returned receiver only observes notifications published
AFTER subscribe returns. Drop the receiver to unsubscribe;
the underlying channel is reaped from the registry when its
last receiver is dropped and no senders remain outstanding.
Sourcepub fn publish(
&self,
scope: NotificationScope,
channel: impl Into<String>,
payload: impl Into<String>,
now_ms: u128,
) -> usize
pub fn publish( &self, scope: NotificationScope, channel: impl Into<String>, payload: impl Into<String>, now_ms: u128, ) -> usize
Publish a payload on (scope, channel) and return the
number of currently connected listeners that received the
event. Returns 0 if no listeners are connected — the
notification is dropped (no buffering, no replay).
Authorization-gated publish.
principal_tenant is the publisher’s tenant binding
(None = platform/global). target is the channel scope
the publisher asked for. has_cross_tenant_cap must be
true if the calling transport’s policy evaluator
previously granted the principal the notify:cross-tenant
action; the registry does not consult policies directly,
keeping the authorization boundary on the transport side
(mirrors the AiProviderGate pattern from #711).
Authorization-gated subscribe — mirror of
Self::publish_authorized for the read side.
Sourcepub fn channel_count(&self) -> usize
pub fn channel_count(&self) -> usize
Number of channels currently registered. Test/diagnostic helper — operators should not depend on this value.
Trait Implementations§
Source§impl Clone for NotificationRegistry
impl Clone for NotificationRegistry
Source§fn clone(&self) -> NotificationRegistry
fn clone(&self) -> NotificationRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for NotificationRegistry
impl Default for NotificationRegistry
Source§fn default() -> NotificationRegistry
fn default() -> NotificationRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for NotificationRegistry
impl !UnwindSafe for NotificationRegistry
impl Forget for NotificationRegistry
impl Freeze for NotificationRegistrywhere
*const ArcInner<Mutex<RawMutex, HashMap<ChannelKey, Sender<NotificationEvent>>>> is !null: Freeze,
PhantomData<ArcInner<Mutex<RawMutex, HashMap<ChannelKey, Sender<NotificationEvent>>>>>: Freeze,
impl Move for NotificationRegistry
impl Send for NotificationRegistry
impl Sync for NotificationRegistry
impl Unpin for NotificationRegistry
impl UnsafeUnpin for NotificationRegistrywhere
*const ArcInner<Mutex<RawMutex, HashMap<ChannelKey, Sender<NotificationEvent>>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<RawMutex, HashMap<ChannelKey, Sender<NotificationEvent>>>>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request