[][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, 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

Subscription type which gets deleted once the process using it gets terminated.

Enums

Error

Error type returned by a Transient Subscription.

Traits

EventSubscriber

Component to let users subscribe to newly-inserted events into the EventStore.

Subscription

A Subscription to an EventStream which can be "checkpointed": keeps a record of the latest message processed by itself using checkpoint, and can resume working from such message by using the resume.

Type Definitions

EventStream

Stream of events returned by the EventSubscriber::subscribe_all method.

SubscriptionStream

Stream of events returned by the Subscription::resume method.