cqrs-core-0.10.0: Command-Query Responsibility Segregation

Safe HaskellNone
LanguageHaskell2010

Data.CQRS.Types.ArchiveStore

Synopsis

Documentation

data ArchiveRef Source

Archive reference.

data ArchiveStore e Source

ArchiveStore for events of type e.

Constructors

ArchiveStore 

Fields

asGetUnarchivedEventCount :: IO Int

esGetUnarchivedEventCount returns the number of currently unarchived events. Because other processes/threads may be accessing the event store concurrently, the returned value may only be treated as an estimate. The caller is guaranteed, however, that -- absent any other process/thread calling esArchiveEvents -- the value will be monotonically increasing.

asArchiveEvents :: Int -> IO (Maybe UUID)

'esArchiveEvents n' archives up to n events. This function does nothing if n is less than or equal to 0. If there are fewer than n unarchived events, then all those events will be archived. Returns the UUID of the newly created archive, if any.

asReadLatestArchiveMetadata :: IO (Maybe ArchiveMetadata)

Retrieve the metadata of the latest archive. Returns Returns Nothing if there are no archives.

asReadArchiveMetadata :: UUID -> IO (Maybe ArchiveMetadata)

Retrieve archive metadata for a specified archive.

asReadArchive :: forall a. ArchiveRef -> (InputStream (UUID, PersistedEvent e) -> IO a) -> IO a

Read all the events in an archive. There's no guarantee on the ordering of the returned events except that the events for any specific aggregate root are returned in order of incresing version number.

data StoreError Source

Errors that can happen during esStoreEvents.

Constructors

VersionConflict UUID 

applyIso :: forall e' e. (e' -> e, e -> e') -> ArchiveStore e -> ArchiveStore e' Source

Transform an implementation of 'ArchiveStore a' to an implementation of 'ArchiveStore b' via an isomorphism. This can be used to add serialization/deserialization to event stores which do not support storing anything other than binary data.

enumerateAllEvents :: ArchiveStore e -> (InputStream (UUID, PersistedEvent e) -> IO ()) -> IO () Source

Enumerate all events in all archives. __This should ONLY be used for debugging purposes.__

rotateArchives :: ArchiveStore e -> Int -> IO () Source

Perform event archival until the current number of unarchived events goes below the given archiveSize. Does nothing if the given archiveSize is not a positive number.