Stability | experimental |
---|---|
Maintainer | Alp Mestanogullari <alp@zalora.com> |
Safe Haskell | None |
Create servant Context
s with pooling support
using resource-pool
- pooledContext :: IO c -> (c -> IO ()) -> Int -> NominalDiffTime -> Int -> IO (Context c)
- contextOfPool :: Pool c -> Context c
- data NominalDiffTime
Documentation
:: IO c | Action that creates a new connection |
-> (c -> IO ()) | Action that destroys an existing connection |
-> Int | Number of stripes (sub-pools). Minimum: 1 |
-> NominalDiffTime | Amount of time during which an unused connection is kept open |
-> Int | Maximum number of resources to keep open per stripe. Minimum: 1 |
-> IO (Context c) |
This is a handy function that lets you create the Context
and the Pool
altogether. It just calls createPool
and
applies contextOfPool
.
contextOfPool :: Pool c -> Context cSource
Use this function to get a Context
using a Pool
you already have around.
Note that the type in the Context
is not
Pool c
but just c
.
It'll however use withResource
under the hood
to make a new connection available. That means
taking an unused one from the pool or bringing
a new one to life.
data NominalDiffTime
This is a length of time, as measured by UTC. Conversion functions will treat it as seconds. It has a precision of 10^-12 s. It ignores leap-seconds, so it's not necessarily a fixed amount of clock time. For instance, 23:00 UTC + 2 hours of NominalDiffTime = 01:00 UTC (+ 1 day), regardless of whether a leap-second intervened.