[][src]Trait eventually::EventSubscriber

pub trait EventSubscriber {
    type SourceId: Eq;
    type Event;
    type Error;
    fn subscribe_all(
        &self
    ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Persisted<Self::SourceId, Self::Event>, Self::Error>> + Send>>, Self::Error>> + Send>>; }

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

Associated Types

type SourceId: Eq

Type of the Source id, typically an AggregateId.

type Event

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

type Error

Possible errors returned when receiving events from the notification channel.

Loading content...

Required methods

fn subscribe_all(
    &self
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Persisted<Self::SourceId, Self::Event>, Self::Error>> + Send>>, Self::Error>> + Send>>

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...
}
Loading content...

Implementors

impl<Id, Event> EventSubscriber for EventStore<Id, Event> where
    Event: Sync + Send + Clone,
    Id: Hash + Eq + Sync + Send + Clone
[src]

type SourceId = Id

type Event = Event

type Error = SubscriberError

Loading content...