Skip to main content

EventBus

Trait EventBus 

Source
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§

Source

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.

Source

fn subscribe(&self) -> Box<dyn EventSubscriber>

Create a new subscriber that receives all future events.

Source

fn subscriber_count(&self) -> usize

Number of active subscribers.

Implementors§