Expand description
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, Subscriptions 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
Subscriptiontype which gets deleted once the process using it gets terminated.
Enums§
Traits§
- Event
Subscriber - Component to let users subscribe to newly-inserted events into the
EventStore. - Subscription
- A Subscription to an
EventStreamwhich can be “checkpointed”: keeps a record of the latest message processed by itself usingcheckpoint, and can resume working from such message by using theresume.
Type Aliases§
- Event
Stream - Stream of events returned by the
EventSubscriber::subscribe_allmethod. - Subscription
Stream - Stream of events returned by the
Subscription::resumemethod.