cqrs-0.9.0: Command-Query Responsibility Segregation

Safe HaskellNone

Data.CQRS.Command

Description

Module to import for the Command side of the application.

Synopsis

Documentation

class Serializable a => Aggregate a

Type class for aggregates.

data AggregateRef a e Source

Aggregate root reference.

class Eventable a e | a -> e where

Type class for applying events to aggregates.

Methods

applyEvent :: Maybe a -> e -> Maybe a

Apply an event to the aggregate and return the updated aggregate.

class EventStoreBackend esb

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

data GUID

A Globally Unique IDentifier.

Instances

Eq GUID 
Data GUID 
Ord GUID 
Show GUID

Showing a GUID.

Typeable GUID 
Serializable GUID

Serialize instance.

NFData GUID 

newGUID :: IO GUID

Create a new random GUID.

data Repository e b Source

Repository consisting of an event store and an event bus.

data UnitOfWorkT e m a Source

UnitOfWork monad transformer.

Instances

createAggregate :: (Serializable e, Typeable a, Typeable e, Aggregate a, Eventable a e) => GUID -> UnitOfWorkT e IO (AggregateRef a e)Source

Add aggregate root. The aggregate root will be created upon transaction commit.

createOrLoadAggregate :: (Serializable e, Typeable a, Typeable e, Aggregate a, Eventable a e) => GUID -> UnitOfWorkT e IO (AggregateRef a e)Source

Create or load aggregate. The aggregate root will be created (if necessary) upon transaction commit.

findAggregate :: (Serializable e, Typeable a, Typeable e, Aggregate a, Eventable a e) => GUID -> UnitOfWorkT e IO (Maybe (AggregateRef a e, a))Source

Find aggregate root.

loadAggregate :: (Serializable e, Typeable a, Typeable e, Aggregate a, Eventable a e) => GUID -> UnitOfWorkT e IO (AggregateRef a e, a)Source

Load aggregate root. The aggregate root must exist.

publishEvent :: (MonadIO m, Serializable e, Typeable a, Typeable e, Aggregate a, Eventable a e, NFData a, NFData e) => AggregateRef a e -> e -> UnitOfWorkT e m ()Source

Publish event for an aggregate root.

runUnitOfWorkT :: forall b c e. (Typeable e, Serializable e, EventStoreBackend b) => Repository e b -> UnitOfWorkT e IO c -> IO cSource

Run transaction against an event store.