[−][src]Crate eventually
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 |
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
AggregateRoot | An |
AggregateRootBuilder | Builder type for new |
Projector | A |
Repository | Implementation of the Repository pattern for storing, retrieving
and deleting |
Traits
Aggregate | An Aggregate manages a domain entity |
AggregateExt | Extension trait with some handy methods to use with |
EventStore | An Event Store is an append-only, ordered list of |
EventSubscriber | Component to let users subscribe to newly-inserted events into the |
Projection | A |
Subscription | A Subscription to an |
Versioned | Data type that carries a version for Optimistic Concurrency Control. |
Functions
spawn | Spawns a new asynchronous task, returning a
|
Type Definitions
AggregateId | A short extractor type for the Aggregate |