domaindriven-core-0.5.0: Batteries included event sourcing and CQRS
Safe HaskellSafe-Inferred
LanguageHaskell2010

DomainDriven.Persistance.Postgres.Internal

Description

Postgres events with state as an IORef

Synopsis

Documentation

data PostgresEvent model event Source #

Constructors

PostgresEvent 

Fields

Instances

Instances details
Generic (PostgresEvent model event) Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

Associated Types

type Rep (PostgresEvent model event) :: Type -> Type #

Methods

from :: PostgresEvent model event -> Rep (PostgresEvent model event) x #

to :: Rep (PostgresEvent model event) x -> PostgresEvent model event #

FromJSON e => ReadModel (PostgresEvent m e) Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

Associated Types

type Model (PostgresEvent m e) Source #

type Event (PostgresEvent m e) Source #

(ToJSON e, FromJSON e) => WriteModel (PostgresEvent m e) Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

Methods

transactionalUpdate :: MonadUnliftIO m0 => PostgresEvent m e -> (Model (PostgresEvent m e) -> m0 (Model (PostgresEvent m e) -> a, [Event (PostgresEvent m e)])) -> m0 a Source #

type Rep (PostgresEvent model event) Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

type Rep (PostgresEvent model event) = D1 ('MetaData "PostgresEvent" "DomainDriven.Persistance.Postgres.Internal" "domaindriven-core-0.5.0-7rYqBJZZqKF59TNQHBa9rT" 'False) (C1 ('MetaCons "PostgresEvent" 'PrefixI 'True) ((S1 ('MetaSel ('Just "connectionPool") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Pool Connection)) :*: (S1 ('MetaSel ('Just "eventTableName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 EventTableName) :*: S1 ('MetaSel ('Just "modelIORef") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (IORef (NumberedModel model))))) :*: (S1 ('MetaSel ('Just "app") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (model -> Stored event -> model)) :*: (S1 ('MetaSel ('Just "seed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 model) :*: S1 ('MetaSel ('Just "chunkSize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChunkSize)))))
type Event (PostgresEvent m e) Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

type Event (PostgresEvent m e) = e
type Model (PostgresEvent m e) Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

type Model (PostgresEvent m e) = m

data PostgresEventTrans model event Source #

Constructors

PostgresEventTrans 

Fields

Instances

Instances details
Generic (PostgresEventTrans model event) Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

Associated Types

type Rep (PostgresEventTrans model event) :: Type -> Type #

Methods

from :: PostgresEventTrans model event -> Rep (PostgresEventTrans model event) x #

to :: Rep (PostgresEventTrans model event) x -> PostgresEventTrans model event #

type Rep (PostgresEventTrans model event) Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

type Rep (PostgresEventTrans model event) = D1 ('MetaData "PostgresEventTrans" "DomainDriven.Persistance.Postgres.Internal" "domaindriven-core-0.5.0-7rYqBJZZqKF59TNQHBa9rT" 'False) (C1 ('MetaCons "PostgresEventTrans" 'PrefixI 'True) ((S1 ('MetaSel ('Just "transaction") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 OngoingTransaction) :*: (S1 ('MetaSel ('Just "eventTableName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 EventTableName) :*: S1 ('MetaSel ('Just "modelIORef") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (IORef (NumberedModel model))))) :*: (S1 ('MetaSel ('Just "app") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (model -> Stored event -> model)) :*: (S1 ('MetaSel ('Just "seed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 model) :*: S1 ('MetaSel ('Just "chunkSize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChunkSize)))))

createEventTable :: (FromJSON e, WriteModel (PostgresEventTrans m e)) => PostgresEventTrans m e -> IO () Source #

Create the table required for storing state and events, if they do not yet exist.

postgresWriteModelNoMigration :: (FromJSON e, WriteModel (PostgresEventTrans m e)) => Pool Connection -> EventTableName -> (m -> Stored e -> m) -> m -> IO (PostgresEvent m e) Source #

Setup the persistance model and verify that the tables exist.

postgresWriteModel :: Pool Connection -> EventTable -> (m -> Stored e -> m) -> m -> IO (PostgresEvent m e) Source #

Setup the persistance model and verify that the tables exist.

newtype Exists Source #

Constructors

Exists 

Fields

Instances

Instances details
Generic Exists Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

Associated Types

type Rep Exists :: Type -> Type #

Methods

from :: Exists -> Rep Exists x #

to :: Rep Exists x -> Exists #

Show Exists Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

Eq Exists Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

Methods

(==) :: Exists -> Exists -> Bool #

(/=) :: Exists -> Exists -> Bool #

FromRow Exists Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

type Rep Exists Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

type Rep Exists = D1 ('MetaData "Exists" "DomainDriven.Persistance.Postgres.Internal" "domaindriven-core-0.5.0-7rYqBJZZqKF59TNQHBa9rT" 'True) (C1 ('MetaCons "Exists" 'PrefixI 'True) (S1 ('MetaSel ('Just "exists") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))

createPostgresPersistance :: forall event model. Pool Connection -> EventTableName -> (model -> Stored event -> model) -> model -> IO (PostgresEvent model event) Source #

newtype EventQuery Source #

Constructors

EventQuery 

Fields

Instances

Instances details
Generic EventQuery Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

Associated Types

type Rep EventQuery :: Type -> Type #

Show EventQuery Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

type Rep EventQuery Source # 
Instance details

Defined in DomainDriven.Persistance.Postgres.Internal

type Rep EventQuery = D1 ('MetaData "EventQuery" "DomainDriven.Persistance.Postgres.Internal" "domaindriven-core-0.5.0-7rYqBJZZqKF59TNQHBa9rT" 'True) (C1 ('MetaCons "EventQuery" 'PrefixI 'True) (S1 ('MetaSel ('Just "getPgQuery") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Query)))

headMay :: [a] -> Maybe a Source #

getEventStream' :: FromJSON event => PostgresEventTrans model event -> SerialT IO (Stored event) Source #

withStreamReadTransaction :: forall t m a model event. (IsStream t, MonadAsync m, MonadCatch m) => PostgresEvent model event -> (PostgresEventTrans model event -> t m a) -> t m a Source #

A transaction that is always rolled back at the end. This is useful when using cursors as they can only be used inside a transaction.

withIOTrans :: forall a model event. PostgresEvent model event -> (PostgresEventTrans model event -> IO a) -> IO a Source #

getModel' :: forall e m. FromJSON e => PostgresEventTrans m e -> IO m Source #