hasql-pool-0.8.0.5: Pool of connections for Hasql
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hasql.Pool

Contents

Synopsis

Pool

data Pool Source #

Pool of connections to DB.

acquire Source #

Arguments

:: Int

Pool size.

-> Maybe Int

Connection acquisition timeout in microseconds.

-> Settings

Connection settings.

-> IO Pool 

Create a connection-pool.

No connections actually get established by this function. It is delegated to use.

acquireDynamically Source #

Arguments

:: Int

Pool size.

-> Maybe Int

Connection acquisition timeout in microseconds.

-> IO Settings

Action fetching connection settings.

-> IO Pool 

Create a connection-pool.

In difference to acquire new settings get fetched each time a connection is created. This may be useful for some security models.

No connections actually get established by this function. It is delegated to use.

release :: Pool -> IO () Source #

Release all the idle connections in the pool, and mark the in-use connections to be released after use. Any connections acquired after the call will be freshly established.

The pool remains usable after this action. So you can use this function to reset the connections in the pool. Naturally, you can also use it to release the resources.

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.

Session failing with a ClientError gets interpreted as a loss of connection. In such case the connection does not get returned to the pool and a slot gets freed up for a new connection to be established the next time one is needed. The error still gets returned from this function.

Errors

data UsageError Source #

Union over all errors that use can result in.

Constructors

ConnectionUsageError ConnectionError

Attempt to establish a connection failed.

SessionUsageError QueryError

Session execution failed.

AcquisitionTimeoutUsageError

Timeout acquiring a connection.

Instances

Instances details
Exception UsageError Source # 
Instance details

Defined in Hasql.Pool

Show UsageError Source # 
Instance details

Defined in Hasql.Pool

Eq UsageError Source # 
Instance details

Defined in Hasql.Pool