Crate cqrs_es2[][src]

Expand description

cqrs-es2

A lightweight CQRS and event sourcing framework.

Publish Test Crates.io docs

Usage

Full fledged demo applications:

Modules

A simple memory store for testing purposes only

Postgres store

Structs

Returns the aggregate and context around it that is needed when committing events in an event store implementation.

EventContext is 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.

Returns the query and context around it that is needed when committing in a query store implementation.

This is the base framework for applying commands to produce events.

A framework for rigorously testing the aggregate logic, one of the most important parts of any CQRS system.

Payload for an AggregateError::UserError, somewhat modeled on the errors produced by the validator package. This payload implements Serialize with the intention of allowing the user to return this object as the response payload.

Enums

The base error for the framework.

Traits

In CQRS (and Domain Driven Design) an Aggregate is the fundamental component that encapsulates the state and application logic (aka business rules) for the application. An Aggregate is always an entity along with all objects associated with it.

An ICommand represents business API call.

Command handlers are usually the aggregates. It consumes the command and emit all events resulting from this command.

An IEvent represents any business change in the state of an Aggregate. IEvents are immutable and with event sourcing they are the source of truth.

Event consumers are usually the queries. It updates its state with the emitted events.

Event dispatcher are usually the query stores. It updates its query with the emitted events.

Event handlers are usually the aggregates. It applies the events to its state.

The abstract central source for loading past events and committing new events.

A Query is 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.

The abstract central source for loading and committing queries.