multipool-persistent-postgresql 0.1.1.0 → 0.2.0.0
raw patch · 2 files changed
+11/−11 lines, 2 filesdep ~persistent-qqPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: persistent-qq
API changes (from Hackage documentation)
Files
multipool-persistent-postgresql.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.0.+-- This file has been generated from package.yaml by hpack version 0.31.1. -- -- see: https://github.com/sol/hpack ----- hash: 38184121adb69accd291a224f21f2e7561c4f2779343321d4743a42c47fa0ba6+-- hash: 7f351628eb129bc6cef3066ff4ba4a905087783e315394c21342074adbaae976 name: multipool-persistent-postgresql-version: 0.1.1.0+version: 0.2.0.0 synopsis: Read and write appropriately from both master and replicated postgresql instances. description: Please see the README on GitHub at <https://github.com/iand675/multipool#readme> category: Database@@ -42,7 +42,7 @@ , multipool-persistent , persistent >=2.9.0 , persistent-postgresql >=2.9.0- , persistent-qq >=2.9.0+ , persistent-qq , postgresql-common-persistent , unliftio-core , unordered-containers@@ -65,7 +65,7 @@ , multipool-persistent-postgresql , persistent >=2.9.0 , persistent-postgresql >=2.9.0- , persistent-qq >=2.9.0+ , persistent-qq , postgresql-common-persistent , unliftio-core , unordered-containers
src/Data/MultiPool/Persist/Postgresql.hs view
@@ -32,20 +32,20 @@ initMultiPool' :: (MonadLogger m, MonadUnliftIO m) => (MultiPool SqlBackend -> IO (Maybe (InstanceName SqlReadBackend))) -- Strategy for selectin the replica instance when calling 'runReadAny'. 'roundRobin' is the current default.- -> ConnectionString -- ^ Master connection string- -> Int -- ^ Max number of connections to master instance+ -> ConnectionString -- ^ Primary connection string+ -> Int -- ^ Max number of connections to primary instance -> [(InstanceName SqlReadBackend, ConnectionString, Int)] -- ^ Replica connection details -> m (MultiPool SqlBackend) initMultiPool' multiPoolAnyReplicaSelector str n is = do- multiPoolMaster <- createPostgresqlPool str n+ multiPoolPrimary <- createPostgresqlPool str n replicas <- mapM (\(inst, connStr, numConns) -> (,) <$> pure inst <*> createPostgresqlPool connStr numConns) is let multiPoolReplica = HM.fromList replicas- multiPoolAnyMasterSelector = const $ pure ()+ multiPoolAnyPrimarySelector = const $ pure () return $ MultiPool {..} -- | Performs a read on the first replica found that sufficiently up-to-date with the given LSN. This function can be combined with 'gatherLSNs' and some sort of caching mechanism to provide a simple way to scale out reads. An great article on this concept can be found [here](https://brandur.org/postgres-reads) ----- If no replica is up-to-date with the given LSN, the master instance will be used to run the query.+-- If no replica is up-to-date with the given LSN, the primary instance will be used to run the query. runReadCurrent :: MonadUnliftIO m => MultiPool SqlBackend@@ -55,7 +55,7 @@ -> m a runReadCurrent b lsnMap lsn m = case validLsnPools of- [] -> runReadAnyMaster b m+ [] -> runReadAnyPrimary b m (pool:_) -> runSqlPool m $ snd pool where validLsnPools =