eventsourcing-0.9.0: CQRS/ES library.

Safe HaskellNone
LanguageHaskell2010

Database.CQRS.InMemory

Synopsis

Documentation

data Stream metadata event Source #

In-memory event stream.

It's using STM internally so it's safe to have different thread writing events to the stream concurrently. Its main purpose is for tests but it could be used for production code as well.

Instances
(MonadError Error m, MonadIO m, NFData event, NFData metadata) => WritableStream m (Stream metadata event) Source # 
Instance details

Defined in Database.CQRS.InMemory

Methods

writeEventWithMetadata :: Stream metadata event -> EventType (Stream metadata event) -> EventMetadata (Stream metadata event) -> ConsistencyCheck (EventIdentifier (Stream metadata event)) -> m (EventIdentifier (Stream metadata event)) Source #

MonadIO m => Stream m (Stream metadata event) Source # 
Instance details

Defined in Database.CQRS.InMemory

Associated Types

type EventType (Stream metadata event) :: Type Source #

type EventIdentifier (Stream metadata event) :: Type Source #

type EventMetadata (Stream metadata event) :: Type Source #

Methods

streamEvents :: Stream metadata event -> StreamBounds' (Stream metadata event) -> Producer [Either (EventIdentifier (Stream metadata event), String) (EventWithContext' (Stream metadata event))] m () Source #

type EventType (Stream metadata event) Source # 
Instance details

Defined in Database.CQRS.InMemory

type EventType (Stream metadata event) = event
type EventIdentifier (Stream metadata event) Source # 
Instance details

Defined in Database.CQRS.InMemory

type EventIdentifier (Stream metadata event) = Integer
type EventMetadata (Stream metadata event) Source # 
Instance details

Defined in Database.CQRS.InMemory

type EventMetadata (Stream metadata event) = metadata

emptyStream :: MonadIO m => m (Stream metadata event) Source #

Initialise an empty event stream.

data StreamFamily identifier metadata event Source #

A family of in-memory streams.

There are two things to be aware of when using this type:

getStream adds a new empty stream to the family regardless of whether it's used or not. If an attacker can make your application call getStream with arbitrary stream identifiers, it can lead to a Denial-of-Service attack.

Slow consumers of event notifications (from allNewEvents) could become an issue if events are written at a higher pace that they can keep up with. In order to avoid the queue of notifications to grow bigger and bigger, it's capped at 100 (hard-coded for now.) This means that writing a new event can be blocked by a full consumer's queue.

Instances
(Eq identifier, Hashable identifier, MonadIO m) => StreamFamily m (StreamFamily identifier metadata event) Source # 
Instance details

Defined in Database.CQRS.InMemory

Associated Types

type StreamType (StreamFamily identifier metadata event) :: Type Source #

type StreamIdentifier (StreamFamily identifier metadata event) :: Type Source #

Methods

getStream :: StreamFamily identifier metadata event -> StreamIdentifier (StreamFamily identifier metadata event) -> m (StreamType (StreamFamily identifier metadata event)) Source #

allNewEvents :: StreamFamily identifier metadata event -> m (Producer [(StreamIdentifier (StreamFamily identifier metadata event), Either (EventIdentifier (StreamType (StreamFamily identifier metadata event)), String) (EventWithContext' (StreamType (StreamFamily identifier metadata event))))] m a) Source #

latestEventIdentifiers :: StreamFamily identifier metadata event -> Producer (StreamIdentifier (StreamFamily identifier metadata event), EventIdentifier (StreamType (StreamFamily identifier metadata event))) m () Source #

type StreamType (StreamFamily identifier metadata event) Source # 
Instance details

Defined in Database.CQRS.InMemory

type StreamType (StreamFamily identifier metadata event) = Stream metadata event
type StreamIdentifier (StreamFamily identifier metadata event) Source # 
Instance details

Defined in Database.CQRS.InMemory

type StreamIdentifier (StreamFamily identifier metadata event) = identifier

emptyStreamFamily :: forall metadata identifier event m. MonadIO m => m (StreamFamily identifier metadata event) Source #

Initialise an empty stream family.