| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hasql.Pool
Synopsis
- data Pool
- type PoolSize = Int
- type Settings = (PoolSize, ResidenceTimeout, ConnectionSettings)
- data ConnectionSettings = ConnectionSettings {
- host :: Text
- port :: Word16
- user :: Text
- password :: Text
- dbName :: Text
- connAcqTimeout :: Word16
- txIdleTimeout :: TimeoutSetting
- stmtTimeout :: TimeoutSetting
- sslMode :: Text
- sslRootCert :: Text
- data UsageError
- type ConnectionGetter = IO (Either ConnectionError Connection)
- data Stats = Stats {
- currentUsage :: !Int
- available :: !Int
- data TimeoutSetting = TimeoutSetting Word16 TimeUnit
- data TimeUnit
- = Microseconds
- | Milliseconds
- | Seconds
- | Minutes
- | Hours
- | Days
- errorToDetailedMsg :: UsageError -> Text
- errorIsTransient :: UsageError -> Bool
- stats :: Pool -> IO Stats
- getPoolUsageStat :: Pool -> IO PoolSize
- acquire :: Settings -> IO Pool
- acquireWith :: 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)
- useWithPoolAcquisitionTimeout :: Int -> Pool -> Session a -> IO (Either UsageError a)
- useWithObserverAndPoolAcquisitionTimeout :: Maybe ObserverAction -> Int -> Pool -> Session a -> IO (Either UsageError a)
- withConnectionWithPoolAcquisitionTimeout :: Int -> Pool -> (Connection -> IO (Either UsageError a)) -> IO (Either UsageError a)
- withResourceOnEither :: Pool resource -> (resource -> IO (Either failure success)) -> IO (Either failure success)
- extendedConnectionSettings :: ConnectionSettings -> Settings
Documentation
type Settings = (PoolSize, ResidenceTimeout, ConnectionSettings) 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 ConnectionSettings Source #
Extended connection settings
Constructors
| ConnectionSettings | |
Fields
| |
data UsageError Source #
A union over the connection establishment error and the session error.
Instances
| Show UsageError Source # | |
Defined in Hasql.Pool Methods showsPrec :: Int -> UsageError -> ShowS # show :: UsageError -> String # showList :: [UsageError] -> ShowS # | |
| Eq UsageError Source # | |
Defined in Hasql.Pool | |
type ConnectionGetter = IO (Either ConnectionError Connection) Source #
Connection getter action that allows for obtaining Postgres connection settings via external resources such as AWS tokens etc.
Constructors
| Stats | |
Fields
| |
data TimeoutSetting Source #
Constructors
| TimeoutSetting Word16 TimeUnit |
Instances
| Show TimeoutSetting Source # | |
Defined in Hasql.Pool Methods showsPrec :: Int -> TimeoutSetting -> ShowS # show :: TimeoutSetting -> String # showList :: [TimeoutSetting] -> ShowS # | |
Constructors
| Microseconds | |
| Milliseconds | |
| Seconds | |
| Minutes | |
| Hours | |
| Days |
errorToDetailedMsg :: UsageError -> Text Source #
errorIsTransient :: UsageError -> Bool Source #
acquire :: Settings -> IO Pool Source #
Given the pool-size, timeout and connection settings create a connection-pool.
acquireWith :: ConnectionGetter -> Settings -> IO Pool Source #
Similar to acquire, allows for finer configuration.
release :: Pool -> IO () Source #
Release the connection-pool by closing and removing all connections.
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.
useWithPoolAcquisitionTimeout :: Int -> Pool -> Session a -> IO (Either UsageError a) Source #
Same as use but bounds the time spent waiting for an available pool slot.
The timeout is in seconds; zero means wait indefinitely.
useWithObserverAndPoolAcquisitionTimeout :: Maybe ObserverAction -> Int -> Pool -> Session a -> IO (Either UsageError a) Source #
Same as useWithObserver but bounds the time spent waiting for an available pool slot.
The timeout is in seconds; zero means wait indefinitely.
withConnectionWithPoolAcquisitionTimeout :: Int -> Pool -> (Connection -> IO (Either UsageError a)) -> IO (Either UsageError a) Source #
Borrow a live connection from the pool and run a callback with it.
This is useful for libraries that need to pin one connection across multiple operations, for example while managing their own transaction state.
The timeout is in seconds; zero means wait indefinitely.
withResourceOnEither :: Pool resource -> (resource -> IO (Either failure success)) -> IO (Either failure success) Source #
extendedConnectionSettings :: ConnectionSettings -> Settings Source #
Produce connection settings suitable for acquiring a connection, from an extended set of parameters covering ssl options.