Expand description
A library providing components to build event-sourced applications.
The eventually
crate provides base abstractions to design your application
domain using Domain-driven Design, using the Aggregate
trait,
and provides a set of nice utilities around those core abstractions:
EventStore
, Repository
, Subscription
and Projection
.
§Event Sourcing Primer
Event Sourcing is an architectural pattern which requires domain entities’ (in ES lingo, Aggregates) internal state to be mutated and persisted as a list of Domain Events, rather than serializing the whole state to the database (as you would do with a typical CRUD architecture).
Events are persisted in an Event Store: an ordered, append-only log of all the events produced in your domain.
Events can be retrieved from an Event Store through Event Streams, stream of chronologically-ordered events.
The state of your Aggregates can thus be rebuilt by streaming all the Events back in the application, as they happened in time, to build the latest version of the state.
This architectural pattern brings in a lot of interesting goodies:
- Auditing: never need to guess what happened in your system, thanks to the Event Store, you have a list of all the Events that have been committed during time.
- Time-machine: travel back in time, by setting the state of your service to a specific point in time, thanks to the Event Store; useful for debugging purposes.
- Projections: create read-optimized models of your Aggregates as needed for you business operations, continuously, every time new Events are committed to the Event Store.
- Concurrency Handling: Event-sourced application make extensive use of Optimistic Concurrency to handle concurrent-writes scenarios – concurrency conflicts and state reconciliation can become part of your Domain!
- High Performance, High Availability: thanks to the append-only Event Store and the use of Projections, you can write highly performant and highly available services that handle an intense amount of traffic.
Modules§
- aggregate
- Module containing support for the Aggergate pattern.
- inmemory
- Module containing utilities using in-memory backend strategy.
- optional
- Module for the Aggregate extension trait using an
Option
state. - repository
- Module containing Repository implementation to retrieve, save and delete Aggregates.
- store
- Module containing support for the Event Store.
- subscription
- Module containing support for Subscriptions to Events coming from the Event Store.
- sync
- Module containing the synchronization primitives used by the library.
- versioning
- Module containing support for Optimistic Concurrency using Versioning.
Structs§
- Aggregate
Root - An
AggregateRoot
represents an handler to theAggregate
it’s managing, such as: - Aggregate
Root Builder - Builder type for new
AggregateRoot
instances. - Projector
- A
Projector
manages the state of a singleProjection
by opening a long-running stream of all events coming from theEventStore
. - Repository
- Implementation of the Repository pattern for storing, retrieving
and deleting
Aggregate
s.
Traits§
- Aggregate
- An Aggregate manages a domain entity
State
, acting as a transaction boundary. - Aggregate
Ext - Extension trait with some handy methods to use with
Aggregate
s. - Event
Store - An Event Store is an append-only, ordered list of
Event
s for a certain “source” – e.g. anAggregate
. - Event
Subscriber - Component to let users subscribe to newly-inserted events into the
EventStore
. - Projection
- A
Projection
is an optimized read model (or materialized view) of anAggregate
model(s), that can be assembled by left-folding its previous state and a number of ordered, consecutive events. - Subscription
- A Subscription to an
EventStream
which can be “checkpointed”: keeps a record of the latest message processed by itself usingcheckpoint
, and can resume working from such message by using theresume
. - Versioned
- Data type that carries a version for Optimistic Concurrency Control.
Functions§
- spawn
- Spawns a new asynchronous task, returning a
JoinHandle
for it.
Type Aliases§
- Aggregate
Id - A short extractor type for the Aggregate
Id
.