| Stability | experimental |
|---|---|
| Maintainer | Alp Mestanogullari <alp@zalora.com> |
| Safe Haskell | None |
Servant.Context.PostgreSQL
Description
Useful functions and instances for using servant with a PostgreSQL database.
- Use
contextOfConnInfoorcontextOfConnStrto create a PostgreSQLContexts. * If you want connection-pooling, usepooledContextOfConnInfoandpooledContextOfConnStr.
- 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 ConnectionConnectInfo.
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
Arguments
| :: 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 Connections internally, from a ConnectInfo value.
Arguments
| :: 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 Connections internally, from a connection string (a ByteString).