EventSubscriber

Trait EventSubscriber 

Source
pub trait EventSubscriber {
    type SourceId: Eq;
    type Event;
    type Error;

    // Required method
    fn subscribe_all(
        &self,
    ) -> BoxFuture<'_, Result<EventStream<'_, Self>, Self::Error>>;
}
Expand description

Component to let users subscribe to newly-inserted events into the EventStore.

Check out [subscribe_all] for more information.

Additional information can be found in the Volatile Subscription section of eventstore.com

Required Associated Types§

Source

type SourceId: Eq

Type of the Source id, typically an AggregateId.

Source

type Event

Event type stored in the EventStore, typically an Aggregate::Event.

Source

type Error

Possible errors returned when receiving events from the notification channel.

Required Methods§

Source

fn subscribe_all( &self, ) -> BoxFuture<'_, Result<EventStream<'_, Self>, Self::Error>>

Subscribes to all new events persisted in the EventStore, from the moment of calling this function, in the future.

Since this is a long-running stream, make sure not to block or await the full computation of the stream.

Prefer using a while let consumer for this EventStream:

let stream = subscriber.subscribe_all().await?;

while let Some(event) = stream.next().await {
    // Do stuff with the received event...
}

Implementors§