Acquire/release

This commit is contained in:
Nikita Volkov 2015-11-22 10:49:54 +03:00
parent f4535f34f7
commit 8f95a93c77
3 changed files with 9 additions and 9 deletions

View File

@ -1,7 +1,7 @@
name:
hasql
version:
0.13.0.1
0.14
category:
Hasql, Database, PostgreSQL
synopsis:

View File

@ -4,8 +4,8 @@ module Hasql.Connection
(
Connection,
ConnectionError(..),
connect,
disconnect,
acquire,
release,
)
where

View File

@ -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