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:
|
name:
|
||||||
hasql
|
hasql
|
||||||
version:
|
version:
|
||||||
0.13.0.1
|
0.14
|
||||||
category:
|
category:
|
||||||
Hasql, Database, PostgreSQL
|
Hasql, Database, PostgreSQL
|
||||||
synopsis:
|
synopsis:
|
||||||
|
@ -4,8 +4,8 @@ module Hasql.Connection
|
|||||||
(
|
(
|
||||||
Connection,
|
Connection,
|
||||||
ConnectionError(..),
|
ConnectionError(..),
|
||||||
connect,
|
acquire,
|
||||||
disconnect,
|
release,
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user