packages feed

hasql-pool 0.10 → 0.10.0.1

raw patch · 4 files changed

+22/−12 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

hasql-pool.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               hasql-pool-version:            0.10+version:            0.10.0.1 category:           Hasql, Database, PostgreSQL synopsis:           Pool of connections for Hasql homepage:           https://github.com/nikita-volkov/hasql-pool
library/Hasql/Pool.hs view
@@ -25,8 +25,12 @@  isAlive :: Word64 -> Word64 -> Word64 -> Conn -> Bool isAlive maxLifetime maxIdletime now Conn {..} =-  now <= connCreationTimeNSec + maxLifetime-    && now <= connUseTimeNSec + maxIdletime+  now+    <= connCreationTimeNSec+    + maxLifetime+    && now+    <= connUseTimeNSec+    + maxIdletime  -- | Pool of connections to DB. data Pool = Pool
library/Hasql/Pool/Prelude.hs view
@@ -26,7 +26,7 @@ import Data.Fixed as Exports import Data.Foldable as Exports hiding (toList) import Data.Function as Exports hiding (id, (.))-import Data.Functor as Exports+import Data.Functor as Exports hiding (unzip) import Data.Functor.Compose as Exports import Data.IORef as Exports import Data.Int as Exports
test/Main.hs view
@@ -74,15 +74,18 @@       release pool       res <- use pool $ getSettingSession "testing.foo"       res `shouldBe` Right Nothing-    it "Times out connection acquisition" $+    it "Times out connection acquisition"+      $       -- 1ms timeout-      withPool 1 0.001 1_800 1_800 connectionSettings $ \pool -> do+      withPool 1 0.001 1_800 1_800 connectionSettings+      $ \pool -> do         sleeping <- newEmptyMVar         t0 <- getCurrentTime         res <-           race-            ( use pool $-                liftIO $ do+            ( use pool+                $ liftIO+                $ do                   putMVar sleeping ()                   threadDelay 1_000_000 -- 1s             )@@ -93,9 +96,11 @@         t1 <- getCurrentTime         res `shouldBe` Right (Left AcquisitionTimeoutUsageError)         diffUTCTime t1 t0 `shouldSatisfy` (< 0.5) -- 0.5s-    it "Passively times out old connections (maxLifetime)" $+    it "Passively times out old connections (maxLifetime)"+      $       -- 0.5s connection lifetime-      withPool 1 10 0.5 1_800 connectionSettings $ \pool -> do+      withPool 1 10 0.5 1_800 connectionSettings+      $ \pool -> do         res <- use pool $ setSettingSession "testing.foo" "hello world"         res `shouldBe` Right ()         res2 <- use pool $ getSettingSession "testing.foo"@@ -141,12 +146,13 @@  getConnectionSettings :: IO Connection.Settings getConnectionSettings =-  B8.unwords . catMaybes+  B8.unwords+    . catMaybes     <$> sequence       [ setting "host" $ defaultEnv "POSTGRES_HOST" "localhost",         setting "port" $ defaultEnv "POSTGRES_PORT" "5432",         setting "user" $ defaultEnv "POSTGRES_USER" "postgres",-        setting "password" $ maybeEnv "POSTGRES_PASSWORD",+        setting "password" $ defaultEnv "POSTGRES_PASSWORD" "postgres",         setting "dbname" $ defaultEnv "POSTGRES_DBNAME" "postgres"       ]   where