[][src]Crate cqrs_es

srvrls - a lightweight serverless framework

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.6"

Or for a specific branch

[dependencies]
cqrs-es = { git = "https://github.com/serverlesstechnology/cqrs.git", branch = "master"}

Opinions

  • Aggregate persistence is via event sourcing only.
  • Metadata is implemented only as a HashMap<String,String>. Further, the MetadataSupplier that the user provides has no insight into the event or aggregate that it supplies metadata for. This may be changed.
  • JSON serialization only.
  • Generics are preferred over boxed traits.
  • Persistence is implemented through a Postgres database.

Todos/research

  • Event upcasters.
  • Some additional framework around GenericViewRepository to simplify event replay.
  • Explore options for increasing the usefulness of MetadataSupplier.
  • Event serialization uses the event type as the root node of the JSON tree. This simplifies deserialization but is non-standard.
  • Paging for PostgresEventStore
  • Persistence implementation for DynamoDb.

Modules

test

Test provides a test framework for building a resilient test base around aggregates.

tools

Tools provides a simple postgres view repository to simplify loading and updating views.

view

View provides the basic downstream query objects needed to render queries (or "views") that describe the state of the system.

Structs

CqrsFramework

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

MemStore

Simple memory store only useful for testing purposes

MessageEnvelope

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

NoopMetadataSupplier

A simple MetadataSupplier that adds no information.

PostgresStore

Storage engine using an Postgres backing. This is the only persistent store currently provided.

TimeMetadataSupplier

A simple MetadataSupplier that adds the current time. Note that these times are not guaranteed to be unique.

Enums

AggregateError

The base error for the framework.

Traits

Aggregate

A trait that defines an Aggregate, the fundamental component in CQRS that encapsulates the state and business logic 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.

MetadataSupplier

A MetadataSupplier will add metadata to events as they are produced by the aggregate.