Copyright | (c) 2015, Peter Trško |
---|---|
License | BSD3 |
Maintainer | peter.trsko@gmail.com |
Stability | unstable |
Portability | CPP, FlexibleContexts, NoImplicitPrelude, PolyKinds, TypeFamilies |
Safe Haskell | Safe |
Language | Haskell2010 |
Data.ConnectionPool.Class
Description
Type class for common connection pool operations.
- class ConnectionPoolFor protocol where
- type HandlerData protocol
- withConnection :: MonadBaseControl IO m => ConnectionPool protocol -> (HandlerData protocol -> m r) -> m r
- tryWithConnection :: MonadBaseControl IO m => ConnectionPool protocol -> (HandlerData protocol -> m r) -> m (Maybe r)
- destroyAllConnections :: ConnectionPool protocol -> IO ()
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.
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.
Instances
ConnectionPoolFor * TcpClient Source | Defined using:
Since version 0.2. |
ConnectionPoolFor * UnixClient Source | Defined using:
Since version 0.2. |