pub trait EventBus: Send + Sync {
// Required methods
fn publish<'life0, 'async_trait>(
&'life0 self,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn subscribe(&self) -> Box<dyn EventSubscriber>;
fn subscriber_count(&self) -> usize;
}Expand description
Trait for the event bus — abstracts over in-memory vs distributed transports.
Required Methods§
Sourcefn publish<'life0, 'async_trait>(
&'life0 self,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn publish<'life0, 'async_trait>(
&'life0 self,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Publish an event to all subscribers.
Sourcefn subscribe(&self) -> Box<dyn EventSubscriber>
fn subscribe(&self) -> Box<dyn EventSubscriber>
Create a new subscriber that receives all future events.
Sourcefn subscriber_count(&self) -> usize
fn subscriber_count(&self) -> usize
Number of active subscribers.