Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Event store

Samuel Debruyn edited this page Dec 24, 2015 · 6 revisions

The event store is a key part of Cirqus. It is configured with the Command Processor. The event store is where Cirqus saves and loads events. This means that this is your primary database, and everything else can be (re)created from this data.

IEventStore

Requirements for an event store are modest: It needs to be able to save an event batch (i.e. one or more events) atomically, and it needs to be able to guard two constraints:

  1. (aggregate root ID, sequence number) for each event is unique
  2. (global sequence number) for each event is unique.

While these are the most basic requirements, it's more fun to use an event store if it is capable of efficiently retrieving (preferably by streaming them) events

  • ordered by global sequence number from a specific global sequence number and on (this is what the views/projections will usually do)
  • ordered by sequence number for a specific aggregate root ID and a specific sequence number and on (this is used to hydrate aggregate root instances for command processing and when inspected from views)

which all of the current event store implementations are perfectly capable of doing.

Examples

Files / SQLite example

var processor = CommandProcessor.With().EventStore(conf =>
{
    conf.UseFiles("/path/to/event/store/location/");
}).Create();

SQLite has the same configuration parameters, all it needs is the path to the database file.

SQL Server / PostgreSQL / MongoDB example

SQL Server, PostgreSQL and MongoDB are all configured in the same way. They have an optional boolean at the end to disable automatic table creation.

var processor = CommandProcessor.With().EventStore(conf =>
{
    conf.UseSqlServer("NameOfConnectionStringOrConnectionStringItself", "NameOfTableWhereEventsShouldGo");
}).Create();

Cirqus will create the events table (unless you supply false as the last parameter), so make sure the database user has the right to create new tables.

Clone this wiki locally