cqrs-0.6.0: Command-Query Responsibility Segregation

Data.CQRS.EventStore.Backend

Description

Event store backend. You only need to import this module if you're planning on implementing a custom event store backend.

Synopsis

Documentation

data EventStoreBackend Source

Event stores are the backend used for reading and storing all the information about recorded events.

Constructors

EventStoreBackend 

Fields

esbStoreEvents :: GUID -> Int -> [(ByteString, Int)] -> IO ()

Store a sequence of events for aggregate identified by GUID into the event store, starting at the provided version number. If the version number does not match the expected value, a failure occurs.

esbRetrieveEvents :: GUID -> Int -> IO (Int, [ByteString])

Retrieve the sequence of events associated with the aggregate identified by the given GUID. Only events at or after the given version number are retrieved. The events are returned in increasing order of version number. The version number of the last event is returned as well.

esbEnumerateAllEvents :: forall a. Int -> Enumerator (Int, (GUID, Int, ByteString)) IO a

Enumerate all events later than given logical timestamp.

esbWriteSnapshot :: GUID -> (Int, ByteString) -> IO ()

Write snapshot for aggregate identified by GUID and the given version number. The version number is NOT checked for validity. If the event store does not support snapshots this function may do nothing.

esbGetLatestSnapshot :: GUID -> IO (Maybe (Int, ByteString))

Get latest snapshot of an aggregate identified by GUID. Returns the version number of the snapshot in addition to the data. An event store which does not support snapshots is permitted to return Nothing in all cases.

esbGetLatestVersion :: IO Int

Get the latest version global number.

esbWithTransaction :: forall a. IO a -> IO a

Run transaction against the event store. The transaction is expected to commit if the supplied IO action runs to completion (i.e. doesn't throw an exception) and to rollback otherwise.

esbCloseEventStoreBackend :: IO ()

Close the event store.