From 8f95a93c775b056873b25fc1ba131b5fd7cdb3f6 Mon Sep 17 00:00:00 2001 From: Nikita Volkov Date: Sun, 22 Nov 2015 10:49:54 +0300 Subject: [PATCH] Acquire/release --- hasql.cabal | 2 +- library/Hasql/Connection.hs | 4 ++-- library/Hasql/Connection/Impl.hs | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hasql.cabal b/hasql.cabal index ea10ceb..0e46ad9 100644 --- a/hasql.cabal +++ b/hasql.cabal @@ -1,7 +1,7 @@ name: hasql version: - 0.13.0.1 + 0.14 category: Hasql, Database, PostgreSQL synopsis: diff --git a/library/Hasql/Connection.hs b/library/Hasql/Connection.hs index 58e2fd0..5c1b867 100644 --- a/library/Hasql/Connection.hs +++ b/library/Hasql/Connection.hs @@ -4,8 +4,8 @@ module Hasql.Connection ( Connection, ConnectionError(..), - connect, - disconnect, + acquire, + release, ) where diff --git a/library/Hasql/Connection/Impl.hs b/library/Hasql/Connection/Impl.hs index 6801e00..fac8c29 100644 --- a/library/Hasql/Connection/Impl.hs +++ b/library/Hasql/Connection/Impl.hs @@ -18,10 +18,10 @@ type ConnectionError = Maybe ByteString -- | --- Acquire a connection using the provided settings. -connect :: ByteString -> IO (Either ConnectionError Connection) -connect settings = - {-# SCC "connect" #-} +-- Acquire a connection using the provided settings encoded according to the PostgreSQL format. +acquire :: ByteString -> IO (Either ConnectionError Connection) +acquire settings = + {-# SCC "acquire" #-} runEitherT $ do pqConnection <- lift (IO.acquireConnection settings) lift (IO.checkConnectionStatus pqConnection) >>= traverse left @@ -32,6 +32,6 @@ connect settings = -- | -- Release the connection. -disconnect :: Connection -> IO () -disconnect (Connection pqConnection _ _) = +release :: Connection -> IO () +release (Connection pqConnection _ _) = LibPQ.finish pqConnection