| Copyright | (c) 2024 |
|---|---|
| License | BSD3 |
| Maintainer | maintainer@example.com |
| Stability | internal |
| Safe Haskell | None |
| Language | GHC2021 |
Hindsight.Store.PostgreSQL.Events.Concurrency
Description
This module implements optimistic concurrency control for the PostgreSQL backend by validating version expectations before event insertion.
Version checks use row-level locking to ensure consistency while minimizing contention between concurrent writers to different streams.
Synopsis
- checkVersions :: forall (t :: Type -> Type). Map StreamId (StreamWrite t SomeLatestEvent SQLStore) -> Transaction (Maybe (ConsistencyErrorInfo SQLStore))
Documentation
checkVersions :: forall (t :: Type -> Type). Map StreamId (StreamWrite t SomeLatestEvent SQLStore) -> Transaction (Maybe (ConsistencyErrorInfo SQLStore)) Source #
Validate version expectations for all event batches.
Acquires row-level locks on affected streams and checks that each
stream's current version matches the expected version. Returns
Nothing if all checks pass, or details of any mismatches.