[][src]Crate cqrs_es

cqrs

A lightweight, opinionated CQRS and event sourcing framework targeting serverless architectures.

Build tag Crates.io docs

Installation

cqrs-es is available from Crates.io or Github.

[dependencies]
cqrs-es = "0.0.18"

Usage

Documentation is available here along with an introduction to CQRS and event sourcing.

A demo application is available here.

Todos

  • Event upcasters.
  • Event serialization uses the event type as the root node of the JSON tree. This simplifies deserialization but is non-standard.
  • A persistence implementation for DynamoDb.
  • A persistence implementation for MySql.
  • Support for snapshots.

Modules

mem_store

An in-memory event store suitable for local testing.

test

Test provides a test framework for building a resilient test base around aggregates. A TestFramework should be used to build a comprehensive set of aggregate tests to verify your application logic (aka business rules).

Structs

CqrsFramework

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

EventEnvelope

EventEnvelope 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.

UserErrorPayload

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

AggregateError

The base error for the framework.

Traits

Aggregate

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.

Command

A Command represents a request to modify the state of an Aggregate by producing DomainEvents.

DomainEvent

A DomainEvent represents any business change in the state of an Aggregate. DomainEvents are immutable and with event sourcing they are the source of truth.

EventStore

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

Query

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.

QueryProcessor

Each CQRS platform should have one or more QueryProcessors where it will distribute committed events, it is the responsibility of the QueryProcessor to update any interested queries.