Aggregate store

Eventuous provides a single abstraction for the domain objects persistence, which is the AggregateStore.

The AggregateStore uses the IEventStore abstraction to be persistence-agnostic, so it can be used as-is, when you give it a proper implementation of event store.

We have only two operations in the AggegateStore:

  • Load - retrieves events from an aggregate stream and restores the aggregate state using those events.
  • Store - collects new events from an aggregate and stores those events to the aggregate stream.

The AggregateStore constructor needs two arguments:

Our ApplicationService uses the AggregateStore in its command-handling flow.

Infrastructure

Eventuous supports EventStoreDB out of the box, but only v20+ with gRPC protocol.

Using this pre-made event persistence is easy. You can register the necessary dependencies in your Startup class when using ASP.NET Core:

services.AddSingleton(new EventStoreClient(
    EventStoreClientSettings.Create(connectionString)
));
services.AddSingleton<IEventSerializer>(
    new DefaultEventSerializer(
        new JsonSerializerOptions(JsonSerializerDefaults.Web)
    )
);
services.AddSingleton<IEventStore, EsDbEventStore>();
services.AddSingleton<IAggregateStore, AggregateStore>();

Edit this page on GitHub