eventsourcing-postgresql-0.9.0: PostgreSQL adaptor for eventsourcing.

Safe HaskellNone
LanguageHaskell2010

Database.CQRS.PostgreSQL.Stream

Synopsis

Documentation

data Stream identifier metadata event Source #

Stream of events stored in a PostgreSQL relation.

The job of sharding streams in different tables is left to the database. If this is something you want to do, you can create a view and a trigger on insert into that view.

Instances
(Event event, MonadError Error m, MonadIO m, Ord identifier, FromField identifier, ToField identifier, FromRow metadata, FromField (EncodingFormat event)) => Stream m (Stream identifier metadata event) Source # 
Instance details

Defined in Database.CQRS.PostgreSQL.Stream

Associated Types

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

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

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

Methods

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

(WritableEvent event, MonadError Error m, MonadIO m, Ord identifier, FromField identifier, ToField identifier, FromField (EncodingFormat event), ToField (EncodingFormat event), FromRow metadata, ToRow metadata) => WritableStream m (Stream identifier metadata event) Source # 
Instance details

Defined in Database.CQRS.PostgreSQL.Stream

Methods

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

type EventMetadata (Stream identifier metadata event) Source # 
Instance details

Defined in Database.CQRS.PostgreSQL.Stream

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

Defined in Database.CQRS.PostgreSQL.Stream

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

Defined in Database.CQRS.PostgreSQL.Stream

type EventType (Stream identifier metadata event) = event

makeStream Source #

Arguments

:: (WritableEvent event, ToField (EncodingFormat event), ToField identifier, ToRow metadata) 
=> (forall a. (Connection -> IO a) -> IO a)

Connection pool as a function.

-> Query

Relation name.

-> Query

Identifier column name. If there are several, use a tuple.

-> [Query]

Column names for metadata.

-> Query

Event column name.

-> Stream identifier metadata event 

Make a Stream from basic information about the relation name and columns.

makeStream' Source #

Arguments

:: (ToRow r, ToRow r') 
=> (forall a. (Connection -> IO a) -> IO a)

Connection pool as a function.

-> (Query, r)

Select query.

-> (forall encEvent. (ToField encEvent, ToRow metadata) => encEvent -> metadata -> ConsistencyCheck identifier -> (Query, r'))

Insert query builder.

-> Query

Identifier column (use tuple if several.)

-> Stream identifier metadata event 

Make a stream from queries.

This function is less safe than makeStream and should only be used when makeStream is not flexible enough. It is also closer to the implementation and more subject to changes.