eventsourcing-0.9.0: CQRS/ES library.

Safe HaskellSafe
LanguageHaskell2010

Database.CQRS.Transformer

Contents

Synopsis

Transformed stream

type Transformer inputEvent eventId event = inputEvent -> Transform eventId event () Source #

data TransformedStream m identifier metadata event Source #

Instances
Monad m => Stream m (TransformedStream m identifier metadata event) Source # 
Instance details

Defined in Database.CQRS.Transformer

Associated Types

type EventType (TransformedStream m identifier metadata event) :: Type Source #

type EventIdentifier (TransformedStream m identifier metadata event) :: Type Source #

type EventMetadata (TransformedStream m identifier metadata event) :: Type Source #

Methods

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

type EventType (TransformedStream m identifier metadata event) Source # 
Instance details

Defined in Database.CQRS.Transformer

type EventType (TransformedStream m identifier metadata event) = event
type EventIdentifier (TransformedStream m identifier metadata event) Source # 
Instance details

Defined in Database.CQRS.Transformer

type EventIdentifier (TransformedStream m identifier metadata event) = identifier
type EventMetadata (TransformedStream m identifier metadata event) Source # 
Instance details

Defined in Database.CQRS.Transformer

type EventMetadata (TransformedStream m identifier metadata event) = metadata

transformStream :: Stream m stream => Transformer (Either (EventIdentifier stream, String) (EventWithContext' stream)) identifier (EventWithContext identifier metadata event) -> (identifier -> m (EventIdentifier stream)) -> stream -> TransformedStream m identifier metadata event Source #

Transformed stream family

data TransformedStreamFamily m streamId eventId metadata event Source #

Instances
Monad m => StreamFamily m (TransformedStreamFamily m streamId eventId metadata event) Source # 
Instance details

Defined in Database.CQRS.Transformer

Associated Types

type StreamType (TransformedStreamFamily m streamId eventId metadata event) :: Type Source #

type StreamIdentifier (TransformedStreamFamily m streamId eventId metadata event) :: Type Source #

Methods

getStream :: TransformedStreamFamily m streamId eventId metadata event -> StreamIdentifier (TransformedStreamFamily m streamId eventId metadata event) -> m (StreamType (TransformedStreamFamily m streamId eventId metadata event)) Source #

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

latestEventIdentifiers :: TransformedStreamFamily m streamId eventId metadata event -> Producer (StreamIdentifier (TransformedStreamFamily m streamId eventId metadata event), EventIdentifier (StreamType (TransformedStreamFamily m streamId eventId metadata event))) m () Source #

type StreamType (TransformedStreamFamily m streamId eventId metadata event) Source # 
Instance details

Defined in Database.CQRS.Transformer

type StreamType (TransformedStreamFamily m streamId eventId metadata event) = TransformedStream m eventId metadata event
type StreamIdentifier (TransformedStreamFamily m streamId eventId metadata event) Source # 
Instance details

Defined in Database.CQRS.Transformer

type StreamIdentifier (TransformedStreamFamily m streamId eventId metadata event) = streamId

transformStreamFamily :: forall m streamId eventId metadata event streamFamily. (Hashable (StreamIdentifier streamFamily), Ord (StreamIdentifier streamFamily), Stream m (StreamType streamFamily), StreamFamily m streamFamily) => Transformer (Either (EventIdentifier (StreamType streamFamily), String) (EventWithContext' (StreamType streamFamily))) eventId (EventWithContext eventId metadata event) -> (StreamIdentifier streamFamily -> m streamId) -> (streamId -> m (StreamIdentifier streamFamily)) -> (EventIdentifier (StreamType streamFamily) -> m eventId) -> (eventId -> m (EventIdentifier (StreamType streamFamily))) -> streamFamily -> TransformedStreamFamily m streamId eventId metadata event Source #

Transform monad

type Transform eventId event = Free (TransformF eventId event) Source #

Monad in which you can push, merge and flush events.

pushEvent :: event -> Transform eventId event () Source #

Push a new event at the end of the queue.

mergeEvents :: ([event] -> (a, [event])) -> Transform eventId event a Source #

Apply a function to the queue of event returning a value and a new queue, sets the queue to the new one and return the value.

The intent is to allow a new event to be merged in a previous one if possible to make the new event stream more compact.

flushEvents :: Transform eventId event () Source #

Flush the queue so it can be processed downstream, e.g. sent to a message broker.

Flushing may also occur automatically.

failTransformer :: eventId -> String -> Transform eventId event () Source #

Flush the events and push an error downstream.