mirror of
https://github.com/nikita-volkov/hasql.git
synced 2024-12-28 04:57:14 +03:00
Acquire/release
This commit is contained in:
parent
f4535f34f7
commit
8f95a93c77
@ -1,7 +1,7 @@
|
||||
name:
|
||||
hasql
|
||||
version:
|
||||
0.13.0.1
|
||||
0.14
|
||||
category:
|
||||
Hasql, Database, PostgreSQL
|
||||
synopsis:
|
||||
|
@ -4,8 +4,8 @@ module Hasql.Connection
|
||||
(
|
||||
Connection,
|
||||
ConnectionError(..),
|
||||
connect,
|
||||
disconnect,
|
||||
acquire,
|
||||
release,
|
||||
)
|
||||
where
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user