[−][src]Module eventually::subscription
Module containing support for Subscriptions to Events coming from the Event Store.
What are Subscriptions?
Subscriptions, as the name suggest, allows to subscribe to changes in the Event Store. Essentialy, Subscriptions receive Events when they get committed to the Store.
This allows for near real-time processing of multiple things, such as
publishing committed events on a message broker, or running projections
(more on that on Projection
documentation).
Subscriptions in eventually
EventSubscriber
trait
In order to subscribe to Events, eventually
exposes the EventSubscriber
trait, usually implemented by EventStore
implementations.
An EventSubscriber
opens an endless EventStream
, that gets
closed only at application shutdown, or if the stream gets explicitly dropped.
The EventStream
receives all the new Events committed
to the EventStore
.
Subscription
trait
The Subscription
trait represent an ongoing subscription
to Events coming from an EventStream
, as described above.
Similarly to the EventSubscriber
, a Subscription
returns an endless stream of Events called SubscriptionStream
.
However, Subscription
s are stateful: they save the latest
Event sequence number that has been processed through the SubscriptionStream
,
by using the checkpoint
method. Later, the Subscription
can be
restarted from where it was left off using the resume
method.
This module exposes a simple Subscription
implementation:
Transient
, for in-memory, one-off subscriptions.
For a long-running Subscription
implementation,
take a look at persisted subscriptions, such as postgres::subscription::Persisted
.
Structs
Transient |
|
Enums
Error | Error type returned by a |
Traits
EventSubscriber | Component to let users subscribe to newly-inserted events into the |
Subscription | A Subscription to an |
Type Definitions
EventStream | Stream of events returned by the |
SubscriptionStream | Stream of events returned by the |