| Copyright | (c) 2024 |
|---|---|
| License | BSD3 |
| Maintainer | maintainer@example.com |
| Stability | experimental |
| Safe Haskell | None |
| Language | GHC2021 |
Hindsight.Store.PostgreSQL.Projections.Sync
Description
This module provides a complete synchronous projection system for PostgreSQL, including registry management, event processing, catch-up functionality, and transaction-based execution. It merges functionality from the original SyncProjection, SyncProjectionCatchUp, and Projection.Sync modules.
Synopsis
- data SyncProjectionRegistry
- emptySyncProjectionRegistry :: SyncProjectionRegistry
- registerSyncProjection :: forall (ts :: [Symbol]). ProjectionId -> ProjectionHandlers ts SQLStore -> SyncProjectionRegistry -> SyncProjectionRegistry
- executeSyncProjectionForEvent :: forall (event :: Symbol). Event event => SyncProjectionRegistry -> Proxy event -> EventEnvelope event SQLStore -> Transaction ()
- catchUpSyncProjections :: Pool -> SyncProjectionRegistry -> IO (Either CatchUpError ())
- data CatchUpError
- matchEventHandlers :: forall (event :: Symbol) (ts :: [Symbol]) backend. Event event => ProjectionHandlers ts backend -> Proxy event -> [ProjectionHandler event backend]
- executeHandlerChain :: forall (event :: Symbol) backend. Event event => [ProjectionHandler event backend] -> EventEnvelope event backend -> Transaction [ProjectionResult]
- handleProjectionError :: ProjectionError -> Transaction ProjectionResult
Registry Management
data SyncProjectionRegistry Source #
Registry of synchronous projections
emptySyncProjectionRegistry :: SyncProjectionRegistry Source #
Create an empty registry
registerSyncProjection :: forall (ts :: [Symbol]). ProjectionId -> ProjectionHandlers ts SQLStore -> SyncProjectionRegistry -> SyncProjectionRegistry Source #
Register a synchronous projection
Event Processing
executeSyncProjectionForEvent :: forall (event :: Symbol). Event event => SyncProjectionRegistry -> Proxy event -> EventEnvelope event SQLStore -> Transaction () Source #
Execute all registered synchronous projections for a single event
Catch-up Functionality
catchUpSyncProjections :: Pool -> SyncProjectionRegistry -> IO (Either CatchUpError ()) Source #
Catch up all sync projections to the latest events
data CatchUpError Source #
Errors that can occur during catch-up
Instances
| Exception CatchUpError Source # | |
Defined in Hindsight.Store.PostgreSQL.Projections.Sync Methods toException :: CatchUpError -> SomeException # fromException :: SomeException -> Maybe CatchUpError # displayException :: CatchUpError -> String # backtraceDesired :: CatchUpError -> Bool # | |
| Show CatchUpError Source # | |
Defined in Hindsight.Store.PostgreSQL.Projections.Sync Methods showsPrec :: Int -> CatchUpError -> ShowS # show :: CatchUpError -> String # showList :: [CatchUpError] -> ShowS # | |
| Eq CatchUpError Source # | |
Defined in Hindsight.Store.PostgreSQL.Projections.Sync | |
PostgreSQL-Specific Projection Functions
matchEventHandlers :: forall (event :: Symbol) (ts :: [Symbol]) backend. Event event => ProjectionHandlers ts backend -> Proxy event -> [ProjectionHandler event backend] Source #
Type-safe handler matching using unified logic
Uses the common handler matching logic from Hindsight.Projection.Matching
executeHandlerChain :: forall (event :: Symbol) backend. Event event => [ProjectionHandler event backend] -> EventEnvelope event backend -> Transaction [ProjectionResult] Source #
Execute a chain of handlers for an event (PostgreSQL Transaction context)
This processes handlers in sequence, collecting results. Unlike the generic version, this is specialized for PostgreSQL transactions.
handleProjectionError :: ProjectionError -> Transaction ProjectionResult Source #
Handle projection errors in PostgreSQL Transaction context