pub struct RepoEventBus { /* private fields */ }Expand description
A per-repository event bus backed by tokio::sync::broadcast.
Channels are lazily created on first publish or subscribe for a
given repo. Slow consumers that fall behind will receive
RecvError::Lagged, which is non-fatal — they skip missed events.
Implementations§
Source§impl RepoEventBus
impl RepoEventBus
Sourcepub fn publish(&self, repo_id: RepoId, event: SessionEvent)
pub fn publish(&self, repo_id: RepoId, event: SessionEvent)
Publish an event to all subscribers of the given repository.
If no subscribers exist yet, the event is silently dropped (the channel is still created for future subscribers).
Sourcepub fn subscribe(&self, repo_id: RepoId) -> Receiver<SessionEvent>
pub fn subscribe(&self, repo_id: RepoId) -> Receiver<SessionEvent>
Subscribe to events for a repository.
Returns a broadcast::Receiver that yields SessionEvents.
Sourcepub fn active_repos(&self) -> usize
pub fn active_repos(&self) -> usize
Number of repositories with active channels.
Sourcepub fn subscriber_count(&self, repo_id: RepoId) -> usize
pub fn subscriber_count(&self, repo_id: RepoId) -> usize
Number of active subscribers for a given repo.
Returns 0 if no channel exists for the repo.
Sourcepub fn prune_dead_channels(&self)
pub fn prune_dead_channels(&self)
Remove channels with no active subscribers.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RepoEventBus
impl !RefUnwindSafe for RepoEventBus
impl Send for RepoEventBus
impl Sync for RepoEventBus
impl Unpin for RepoEventBus
impl UnsafeUnpin for RepoEventBus
impl !UnwindSafe for RepoEventBus
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for 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> 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>
Converts
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>
Converts
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 more