packages feed

hasql-pool 0.7.1.3 → 0.7.2

raw patch · 3 files changed

+23/−5 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Hasql.Pool: acquireDynamically :: Int -> IO Settings -> IO Pool

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+# 0.7.2++Added support for dynamic connection configuration ([issue #11](https://github.com/nikita-volkov/hasql-pool/issues/11)).+ # 0.7.1.2  Fixed connections not being released if they were in use during the call to `release`.
hasql-pool.cabal view
@@ -1,7 +1,7 @@ name:   hasql-pool version:-  0.7.1.3+  0.7.2 category:   Hasql, Database, PostgreSQL synopsis:
library/Hasql/Pool.hs view
@@ -2,6 +2,7 @@   ( -- * Pool     Pool,     acquire,+    acquireDynamically,     release,     use, @@ -19,7 +20,7 @@ -- | A pool of connections to DB. data Pool = Pool   { -- | Connection settings.-    poolConnectionSettings :: Connection.Settings,+    poolFetchConnectionSettings :: IO Connection.Settings,     -- | Avail connections.     poolConnectionQueue :: TQueue Connection,     -- | Capacity.@@ -33,8 +34,20 @@ -- No connections actually get established by this function. It is delegated -- to 'use'. acquire :: Int -> Connection.Settings -> IO Pool-acquire poolSize connectionSettings = do-  Pool connectionSettings+acquire poolSize connectionSettings =+  acquireDynamically poolSize (pure connectionSettings)++-- | Given the pool-size and connection settings constructor action+-- create a connection-pool.+--+-- No connections actually get established by this function. It is delegated+-- to 'use'.+--+-- In difference to 'acquire' new settings get fetched each time a connection+-- is created. This may be useful for some security models.+acquireDynamically :: Int -> IO Connection.Settings -> IO Pool+acquireDynamically poolSize fetchConnectionSettings = do+  Pool fetchConnectionSettings     <$> newTQueueIO     <*> newTVarIO poolSize     <*> newTVarIO True@@ -73,7 +86,8 @@       else return . return . Left $ PoolIsReleasedUsageError   where     onNewConn = do-      connRes <- Connection.acquire poolConnectionSettings+      settings <- poolFetchConnectionSettings+      connRes <- Connection.acquire settings       case connRes of         Left connErr -> do           atomically $ modifyTVar' poolCapacity succ