hasql-resource-pool-0.6.0.0: A pool of connections for Hasql based on resource-pool.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hasql.Pool

Synopsis

Documentation

data Pool Source #

A pool of open DB connections.

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.

Instances

Instances details
Show UsageError Source # 
Instance details

Defined in Hasql.Pool

Eq UsageError Source # 
Instance details

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.

data Stats Source #

Constructors

Stats 

Fields

Instances

Instances details
Show Stats Source # 
Instance details

Defined in Hasql.Pool

Methods

showsPrec :: Int -> Stats -> ShowS #

show :: Stats -> String #

showList :: [Stats] -> ShowS #

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.

withResourceOnEither :: Pool resource -> (resource -> IO (Either failure success)) -> IO (Either failure success) Source #