Expand description
§cqrs-es2
A Rust library providing lightweight CQRS and event sourcing framework.
Provides all basic interfaces for the CQRS system.
§Installation
[dependencies]
# serialization
serde = { version = "^1.0.127", features = ["derive"] }
serde_json = "^1.0.66"
# CQRS framework
cqrs-es2 = { version = "*"}§Usage
Full fledged demo applications:
Structs§
- Aggregate
Context - Returns the aggregate and context around it that is needed when committing events in an event store implementation.
- Consumer
Tester ConsumerTesterprovides a consistent way to test query implementations- Event
Context EventContextis a data structure that encapsulates an event with along with it’s pertinent information. All of the associated data will be transported and persisted together.- Handler
Tester HandlerTesterprovides a consistent way to test aggregate implementations- Query
Context - Returns the query and context around it that is needed when committing in a query store implementation.
- User
Error - Payload for an
Error::UserError, somewhat modeled on the errors produced by thevalidatorpackage. This payload implementsSerializewith the intention of allowing the user to return this object as the response payload.
Enums§
- Error
- The base error for the framework.
Traits§
- IAggregate
- In CQRS (and Domain Driven Design) an
Aggregateis the fundamental component that encapsulates the state and application logic (aka business rules) for the application. AnAggregateis always an entity along with all objects associated with it. - ICommand
- An
ICommandrepresents business API call. - ICommand
Handler - Command handlers are usually the aggregates. It consumes the command and emit all events resulting from this command.
- IEvent
- An
IEventrepresents any business change in the state of anAggregate.IEvents are immutable and with event sourcing they are the source of truth. - IEvent
Consumer - Event consumers are usually the queries. It updates its state with the emitted events.
- IEvent
Handler - Event handlers are usually the aggregates. It applies the events to its state.
- IQuery
- A
Queryis a read element in a CQRS system. As events are emitted multiple downstream queries are updated to reflect the current state of the system. A query may also be referred to as a ‘view’, the concepts are identical but ‘query’ is used here to conform with CQRS nomenclature.