hindsight-postgresql-store
Copyright(c) 2024
LicenseBSD3
Maintainermaintainer@example.com
Stabilityinternal
Safe HaskellNone
LanguageGHC2021

Hindsight.Store.PostgreSQL.Events.Insertion

Description

Handles the insertion of events into PostgreSQL tables, including transaction management, sequence number assignment, stream head updates, and optional synchronous projection execution.

Synopsis

Types

data InsertedEvents Source #

Result of event insertion

Main insertion functions

insertEventsWithSyncProjections :: forall (t :: Type -> Type). Traversable t => SyncProjectionRegistry -> Maybe CorrelationId -> Map StreamId (StreamWrite t SomeLatestEvent SQLStore) -> IO (Transaction InsertedEvents) Source #

Insert events and execute synchronous projections within the same transaction

Stream version utilities

calculateStreamVersions :: forall (t :: Type -> Type). Map StreamId (StreamWrite t SomeLatestEvent SQLStore) -> Transaction (Map StreamId StreamVersion) Source #

Calculate stream versions for events based on current stream state

nextStreamVersions :: forall (t :: Type -> Type). Foldable t => Map StreamId (StreamWrite t SomeLatestEvent SQLStore) -> Map StreamId StreamVersion -> Map StreamId [StreamVersion] Source #

Calculate next stream versions for each stream