Stability | experimental |
---|---|
Maintainer | Alp Mestanogullari <alp@zalora.com> |
Safe Haskell | None |
Useful functions and instances for using servant with a PostgreSQL database.
- Use
contextOfConnInfo
orcontextOfConnStr
to create a PostgreSQLContext
s. * If you want connection-pooling, usepooledContextOfConnInfo
andpooledContextOfConnStr
.
- contextOfConnInfo :: ConnectInfo -> Context Connection
- contextOfConnStr :: ByteString -> Context Connection
- pooledContextOfConnInfo :: Int -> NominalDiffTime -> Int -> ConnectInfo -> IO (Context Connection)
- pooledContextOfConnStr :: Int -> NominalDiffTime -> Int -> ByteString -> IO (Context Connection)
PostgreSQL Context
contextOfConnInfo :: ConnectInfo -> Context ConnectionSource
Create a
from the given
Context
Connection
ConnectInfo
.
This means a new connection will be fired whenever you perform a database operation. If you want to avoid that, see the pooledContextOfXXX functions.
contextOfConnStr :: ByteString -> Context ConnectionSource
Create a
from the given
connection string.
Context
Connection
This means a new connection will be fired whenever you perform a database operation. If you want to avoid that, see the pooledContextOfXXX functions.
PostgreSQL Context
with connection pooling
:: Int | Number of stripes (sub-pools). Minimum: 1 |
-> NominalDiffTime | amount of time during which an unused
|
-> Int | Maximum number of resources to keep open per stripe. Minimum: 1 |
-> ConnectInfo | connection information |
-> IO (Context Connection) |
Create a Context
that'll use a Pool
of
PostgreSQL Connection
s internally, from
a ConnectInfo
value.
:: Int | Number of stripes (sub-pools). Minimum: 1 |
-> NominalDiffTime | amount of time during which an unused
|
-> Int | Maximum number of resources to keep open per stripe. Minimum: 1 |
-> ByteString | connection string |
-> IO (Context Connection) |
Create a Context
that'll use a Pool
of
PostgreSQL Connection
s internally, from
a connection string (a ByteString
).