[−][src]Trait eventually::EventSubscriber
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.
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>>
&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...
}
Implementors
impl<Id, Event> EventSubscriber for EventStore<Id, Event> where
Event: Sync + Send + Clone,
Id: Hash + Eq + Sync + Send + Clone,
[src]
Event: Sync + Send + Clone,
Id: Hash + Eq + Sync + Send + Clone,
type SourceId = Id
type Event = Event
type Error = SubscriberError
fn subscribe_all(
&self
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Persisted<<EventStore<Id, Event> as EventSubscriber>::SourceId, <EventStore<Id, Event> as EventSubscriber>::Event>, <EventStore<Id, Event> as EventSubscriber>::Error>> + Send>>, <EventStore<Id, Event> as EventSubscriber>::Error>> + Send>>
[src]
&self
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Persisted<<EventStore<Id, Event> as EventSubscriber>::SourceId, <EventStore<Id, Event> as EventSubscriber>::Event>, <EventStore<Id, Event> as EventSubscriber>::Error>> + Send>>, <EventStore<Id, Event> as EventSubscriber>::Error>> + Send>>