Copyright | (c) 2015 Peter Trško |
---|---|
License | BSD3 |
Maintainer | peter.trsko@gmail.com |
Stability | unstable |
Portability | GHC specific language extensions. |
Safe Haskell | Safe |
Language | Haskell2010 |
Type class for common connection pool operations.
- class ConnectionPoolFor (protocol :: k) where
- type HandlerData protocol
Documentation
class ConnectionPoolFor (protocol :: k) 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.
type HandlerData protocol Source #
Data passed to individual connection handler.
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.
ConnectionPoolFor * TcpClient Source # | Defined using:
Since version 0.2. |
ConnectionPoolFor * UnixClient Source # | Defined using:
Since version 0.2. |