connection-pool-0.2.1: Connection pool built on top of resource-pool and streaming-commons.

Copyright(c) 2015 Peter Trško
LicenseBSD3
Maintainerpeter.trsko@gmail.com
Stabilityunstable
PortabilityGHC specific language extensions.
Safe HaskellSafe
LanguageHaskell2010

Data.ConnectionPool.Class

Description

Type class for common connection pool operations.

Synopsis

Documentation

class ConnectionPoolFor protocol where Source #

Type class for common connection pool operations. It intentionally doesn't handle connection pool creation, which is best left to dedicated smart constructors.

Since version 0.2.

Associated Types

type HandlerData protocol Source #

Data passed to individual connection handler.

Methods

withConnection :: MonadBaseControl IO m => ConnectionPool protocol -> (HandlerData protocol -> m r) -> m r Source #

Temporarily take a connection from a pool, run handler with it, and return it to the pool afterwards.

Since version 0.2.

tryWithConnection :: MonadBaseControl IO m => ConnectionPool protocol -> (HandlerData protocol -> m r) -> m (Maybe r) Source #

Similar to withConnection, but only performs action if a connection could be taken from the pool without blocking. Otherwise, tryWithResource returns immediately with Nothing (ie. the action function is not called). Conversely, if a connection can be acquired from the pool without blocking, the action is performed and it's result is returned, wrapped in a Just.

Since version 0.2.

destroyAllConnections :: ConnectionPool protocol -> IO () Source #

Destroy all connections that might be still open in a connection pool. This is useful when one needs to release all resources at once and not to wait for idle timeout to be reached.

Since version 0.2.