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: name:
hasql hasql
version: version:
0.13.0.1 0.14
category: category:
Hasql, Database, PostgreSQL Hasql, Database, PostgreSQL
synopsis: synopsis:

View File

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

View File

@ -18,10 +18,10 @@ type ConnectionError =
Maybe ByteString Maybe ByteString
-- | -- |
-- Acquire a connection using the provided settings. -- Acquire a connection using the provided settings encoded according to the PostgreSQL format.
connect :: ByteString -> IO (Either ConnectionError Connection) acquire :: ByteString -> IO (Either ConnectionError Connection)
connect settings = acquire settings =
{-# SCC "connect" #-} {-# SCC "acquire" #-}
runEitherT $ do runEitherT $ do
pqConnection <- lift (IO.acquireConnection settings) pqConnection <- lift (IO.acquireConnection settings)
lift (IO.checkConnectionStatus pqConnection) >>= traverse left lift (IO.checkConnectionStatus pqConnection) >>= traverse left
@ -32,6 +32,6 @@ connect settings =
-- | -- |
-- Release the connection. -- Release the connection.
disconnect :: Connection -> IO () release :: Connection -> IO ()
disconnect (Connection pqConnection _ _) = release (Connection pqConnection _ _) =
LibPQ.finish pqConnection LibPQ.finish pqConnection