Crate eventsourced
source ·Expand description
Event sourced entities.
EventSourced is inspired to a large degree by the amazing Akka Persistence library. It provides a framework for implementing Event Sourcing and CQRS.
The EvtLog and SnapshotStore traits define a pluggable event log and a pluggable snapshot store respectively. For NATS and Postgres these are implemented in the respective crates.
The spawn function provides for creating event sourced entities, identifiable by an ID, for some event log and some snapshot store. Conversion of events and snapshot state to and from bytes happens via the given Binarize implementation; for prost and serde_json these are already provided.
Calling spawn results in a cloneable EntityRef which can be used to pass commands to the spawned entity by invoking handle_cmd. Commands are handled by the command handler of the spawned entity. They can be rejected by returning an error. Valid commands produce an event which gets persisted to the EvtLog and then applied to the event handler of the respective entity. Snapshots can be taken to speed up future spawning.
Events can be queried from the event log by ID or by entity type. These queries can be used to
build read side projections. There is early support for projections in the
eventsourced-projection crate.
Modules§
- Conversion to and from
Bytes.
Structs§
- A handle for a spawned event sourced entity which can be used to invoke its command handler.
- A command cannot be sent from an EntityRef to its entity or the result cannot be received from its entity.
- A SnapshotStore implementation that does nothing.
- Snapshot state along with its sequence number.
Enums§
- Error from spawning an event sourced entity.
Traits§
- Command and event handling for an event sourced entity.
- Extension methods for types implementing EventSourced.
- Persistence for events.
- Persistence for snapshots.
- Persistence for snapshots.