cqrs-0.1.0: src/Data/CQRS/EventStore.hs
-- | Event store data types.
module Data.CQRS.EventStore
( EventStore(..)
) where
import Data.CQRS.Event
import Data.CQRS.GUID
import Data.Binary
-- | Event stores are the backend used for reading and storing all the
-- information about recorded events.
data EventStore =
EventStore {
-- | 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.
storeEvents :: (Event e a, Binary e) => GUID a -> Int -> [e] -> IO (),
-- | Retrieve the sequence of events associated with the aggregate
-- identified by the given GUID. The events are returned in increasing
-- order of version number. The version number of the last event is returned
-- as well.
retrieveEvents :: (Event e a, Binary e) => GUID a -> IO (Int,[e]),
-- | 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.
withTransaction :: forall a . IO a -> IO a,
-- | Close the event store.
closeEventStore :: IO ()
}