eventful-postgresql 0.1.1 → 0.1.2
raw patch · 3 files changed
+22/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- eventful-postgresql.cabal +2/−7
- src/Eventful/Store/Postgresql.hs +18/−1
- tests/Eventful/Store/PostgresqlSpec.hs +2/−0
eventful-postgresql.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: eventful-postgresql-version: 0.1.1+version: 0.1.2 synopsis: Postgres implementations for eventful description: Postgres implementations for eventful category: Database,Eventsourcing,PostgreSQL@@ -27,7 +27,6 @@ library hs-source-dirs: src- default-extensions: ConstraintKinds DeriveFunctor DeriveGeneric FlexibleContexts FlexibleInstances FunctionalDependencies GADTs GeneralizedNewtypeDeriving MultiParamTypeClasses OverloadedStrings QuasiQuotes RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeFamilies ghc-options: -Wall build-depends: base >= 4.9 && < 5@@ -37,7 +36,6 @@ , bytestring , mtl , persistent- , persistent-postgresql , text exposed-modules: Eventful.Store.Postgresql@@ -49,7 +47,6 @@ hs-source-dirs: tests src- default-extensions: ConstraintKinds DeriveFunctor DeriveGeneric FlexibleContexts FlexibleInstances FunctionalDependencies GADTs GeneralizedNewtypeDeriving MultiParamTypeClasses OverloadedStrings QuasiQuotes RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeFamilies ghc-options: -Wall build-depends: base >= 4.9 && < 5@@ -59,11 +56,11 @@ , bytestring , mtl , persistent- , persistent-postgresql , text , hspec , HUnit , eventful-test-helpers+ , persistent-postgresql other-modules: Eventful.Store.PostgresqlSpec HLint@@ -75,7 +72,6 @@ main-is: HLint.hs hs-source-dirs: tests- default-extensions: ConstraintKinds DeriveFunctor DeriveGeneric FlexibleContexts FlexibleInstances FunctionalDependencies GADTs GeneralizedNewtypeDeriving MultiParamTypeClasses OverloadedStrings QuasiQuotes RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeFamilies ghc-options: -Wall build-depends: base >= 4.9 && < 5@@ -85,7 +81,6 @@ , bytestring , mtl , persistent- , persistent-postgresql , text , hlint other-modules:
src/Eventful/Store/Postgresql.hs view
@@ -1,3 +1,7 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE TypeFamilies #-}+ -- | Defines an Postgresql event store. module Eventful.Store.Postgresql@@ -26,7 +30,7 @@ let getLatestVersion = sqlMaxEventVersion config maxPostgresVersionSql getEvents = sqlGetAggregateEvents config- storeEvents' = sqlStoreEvents config maxPostgresVersionSql+ storeEvents' = sqlStoreEvents config (Just tableLockFunc) maxPostgresVersionSql storeEvents = transactionalExpectedWriteHelper getLatestVersion storeEvents' in EventStore{..} @@ -42,3 +46,16 @@ _ <- liftIO $ runSqlPool (runMigrationSilent migrateSqlEvent) pool return ()++-- | We need to lock the events table or else our global sequence number might+-- not be monotonically increasing over time from the point of view of a+-- reader.+--+-- For example, say transaction A begins to write an event and the+-- auto-increment key is 1. Then, transaction B starts to insert an event and+-- gets an id of 2. If transaction B is quick and completes, then a listener+-- might see the event from B and thinks it has all the events up to a sequence+-- number of 2. However, once A finishes and the event with the id of 1 is+-- done, then the listener won't know that event exists.+tableLockFunc :: Text -> Text+tableLockFunc tableName = "LOCK " <> tableName <> " IN EXCLUSIVE MODE"
tests/Eventful/Store/PostgresqlSpec.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE OverloadedStrings #-}+ module Eventful.Store.PostgresqlSpec (spec) where import Control.Monad.Reader (ask)