pub trait EventSubscriber {
type SourceId: Eq;
type Event;
type Error;
// Required method
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 + '_>>;
}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§
Sourcetype SourceId: Eq
type SourceId: Eq
Type of the Source id, typically an AggregateId.
Sourcetype Event
type Event
Event type stored in the EventStore, typically an Aggregate::Event.
Required Methods§
Sourcefn 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 + '_>>
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...
}