| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hasql.Pool
Synopsis
- data Pool
- type Settings = (PoolSize, ResidenceTimeout, Settings)
- data UsageError
- acquire :: Settings -> IO Pool
- acquireWith :: PoolStripes -> ConnectionGetter -> Settings -> IO Pool
- release :: Pool -> IO ()
- use :: Pool -> Session a -> IO (Either UsageError a)
- useWithObserver :: Maybe ObserverAction -> Pool -> Session a -> IO (Either UsageError a)
- getPoolUsageStat :: Pool -> IO PoolSize
Documentation
A pool of connections to DB.
type Settings = (PoolSize, ResidenceTimeout, Settings) Source #
Settings of the connection pool. Consist of:
- Pool-size.
- Timeout. An amount of time for which an unused resource is kept open. The smallest acceptable value is 0.5 seconds.
- Connection settings.
data UsageError Source #
A union over the connection establishment error and the session error.
Constructors
| ConnectionError ConnectionError | |
| SessionError QueryError |
Instances
| Eq UsageError Source # | |
Defined in Hasql.Pool | |
| Show UsageError Source # | |
Defined in Hasql.Pool Methods showsPrec :: Int -> UsageError -> ShowS # show :: UsageError -> String # showList :: [UsageError] -> ShowS # | |
acquire :: Settings -> IO Pool Source #
Given the pool-size, timeout and connection settings create a connection-pool.
acquireWith :: PoolStripes -> ConnectionGetter -> Settings -> IO Pool Source #
Similar to acquire, allows for finer configuration.
use :: Pool -> Session a -> IO (Either UsageError a) Source #
Use a connection from the pool to run a session and return the connection to the pool, when finished.
useWithObserver :: Maybe ObserverAction -> Pool -> Session a -> IO (Either UsageError a) Source #
Same as use but allows for a custom observer action. You can use it for gathering latency metrics.
getPoolUsageStat :: Pool -> IO PoolSize Source #