-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Connection pool built on top of resource-pool and streaming-commons. -- @package connection-pool @version 0.1.3 -- | Internal packages are here to provide access to internal definitions -- for library writers, but they should not be used in application code. -- -- Preferably use qualified import, e.g.: -- --
--   import qualified Data.ConnectionPool.Internal.HandlerParams as Internal
--   
-- -- This module doesn't depend on streaming-commons and other -- non-HaskellPlatform packages with notable exception of -- resource-pool. Another notable thing is that this package is -- not OS specific. Please, bear this in mind when doing modifications. module Data.ConnectionPool.Internal.HandlerParams data HandlerParams HandlerParams :: !Int -> HandlerParams -- | See readBufferSize for details. _readBufferSize :: HandlerParams -> !Int -- | Lens for accessing read buffer size that handler should use when -- reading data from connection. readBufferSize :: Functor f => (Int -> f Int) -> HandlerParams -> f HandlerParams instance Typeable HandlerParams instance Data HandlerParams instance Generic HandlerParams instance Show HandlerParams instance Datatype D1HandlerParams instance Constructor C1_0HandlerParams instance Selector S1_0_0HandlerParams instance Default HandlerParams -- | Module defines helper functions that would be ideally provided by -- streaming-commons package and some wrappers with specialised -- type signatures. -- -- Internal packages are here to provide access to internal definitions -- for library writers, but they should not be used in application code. -- -- Preferably use qualified import, e.g.: -- --
--   import qualified Data.ConnectionPool.Internal.Streaming as Internal
--   
-- -- This module doesn't neither depend on resource-pool package nor -- any other module of this package, with notable exception of -- Data.ConnectionPool.Internal.HandlerParams, and it shoud stay -- that way. This module uses CPP to get OS specific things right. Most -- importantly Windows doesn't support UNIX Sockets. -- -- Please, bear above in mind when doing modifications. module Data.ConnectionPool.Internal.Streaming -- | Wrapper for getSocketFamilyTCP that takes ClientSettings -- instead of individual parameters. acquireTcpClientConnection :: ClientSettings -> IO (Socket, SockAddr) -- | Wrapper for runTcpAppImpl with a type signature that is more -- natural for implementing a TCP specific withConnection. runTcpApp :: MonadBaseControl IO m => Maybe SockAddr -> (AppData -> m r) -> HandlerParams -> Socket -> SockAddr -> m r -- | Simplified runTCPClient and runTCPServer that provides -- only construction of AppData and passing it to a callback -- function. runTcpAppImpl :: MonadBaseControl IO m => Maybe SockAddr -> Socket -> SockAddr -> Int -> (AppData -> m r) -> m r fromClientSettings :: ClientSettings -> HandlerParams -- | Wrapper for runUnixAppImpl with a type signature that is more -- natural for implementing a UNIX Socket specific withConnection. runUnixApp :: MonadBaseControl IO m => (AppDataUnix -> m r) -> HandlerParams -> Socket -> () -> m r -- | Simplified runUnixClient and runUnixServer that provides -- only construction of AppDataUnix and passing it to a callback -- function. runUnixAppImpl :: MonadBaseControl IO m => Socket -> Int -> (AppDataUnix -> m r) -> m r fromClientSettingsUnix :: ClientSettingsUnix -> HandlerParams -- | Internal packages are here to provide access to internal definitions -- for library writers, but they should not be used in application code. -- -- Preferably use qualified import, e.g.: -- --
--   import qualified Data.ConnectionPool.Internal.ResourcePoolParams
--     as Internal
--   
-- -- Surprisingly this module doesn't depend on resource-pool -- package and it would be good if it stayed that way, but not at the -- cost of crippling functionality. -- -- Importantly this package should not depend on streaming-commons -- package or other modules of this package. -- -- Please, bear above in mind when doing modifications. module Data.ConnectionPool.Internal.ResourcePoolParams -- | Parameters of resource pool that describe things like its internal -- structure. See createPool for details. data ResourcePoolParams ResourcePoolParams :: !Int -> !NominalDiffTime -> !Int -> ResourcePoolParams _numberOfStripes :: ResourcePoolParams -> !Int _resourceIdleTimeout :: ResourcePoolParams -> !NominalDiffTime _numberOfResourcesPerStripe :: ResourcePoolParams -> !Int -- | Lens for accessing maximum number of resources to keep open per -- stripe. The smallest acceptable value is 1 (default). numberOfResourcesPerStripe :: Functor f => (Int -> f Int) -> ResourcePoolParams -> f ResourcePoolParams -- | Lens for accessing stripe count. The number of distinct sub-pools to -- maintain. The smallest acceptable value is 1 (default). numberOfStripes :: Functor f => (Int -> f Int) -> ResourcePoolParams -> f ResourcePoolParams -- | Lens for accessing amount of time for which an unused resource is kept -- open. The smallest acceptable value is 0.5 seconds (default). resourceIdleTimeout :: Functor f => (NominalDiffTime -> f NominalDiffTime) -> ResourcePoolParams -> f ResourcePoolParams -- | Check if all parameters for underlying resource pool are valid: -- -- -- -- For more details see createPool. -- -- Since version 0.1.1.0. validateResourcePoolParams :: ResourcePoolParams -> Either String ResourcePoolParams instance Typeable ResourcePoolParams instance Data ResourcePoolParams instance Show ResourcePoolParams instance Default ResourcePoolParams -- | Internal packages are here to provide access to internal definitions -- for library writers, but they should not be used in application code. -- -- Preferably use qualified import, e.g.: -- --
--   import qualified Data.ConnectionPool.Internal.ConnectionPool as Internal
--   
-- -- This module doesn't depend on streaming-commons and other -- non-HaskellPlatform packages with notable exception of -- resource-pool. Another notable thing is that this package is -- not OS specific. Please, bear this in mind when doing modifications. module Data.ConnectionPool.Internal.ConnectionPool -- | Simple specialized wrapper for Pool. data ConnectionPool handlerParams a ConnectionPool :: !(Pool (Socket, a)) -> !handlerParams -> ConnectionPool handlerParams a _resourcePool :: ConnectionPool handlerParams a -> !(Pool (Socket, a)) _handlerParams :: ConnectionPool handlerParams a -> !handlerParams resourcePool :: Functor f => (Pool (Socket, a) -> f (Pool (Socket, b))) -> ConnectionPool handlerParams a -> f (ConnectionPool handlerParams b) handlerParams :: Functor f => (handlerParams -> f handlerParams') -> ConnectionPool handlerParams c -> f (ConnectionPool handlerParams' c) -- | Specialized wrapper for createPool, see its documentation for -- details. createConnectionPool :: handlerParams -> IO (Socket, a) -> (Socket -> IO ()) -> ResourcePoolParams -> IO (ConnectionPool handlerParams a) -- | 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. -- -- For more details see destroyAllResources. -- -- Since version 0.1.1.0. destroyAllConnections :: ConnectionPool handlerParams a -> IO () -- | Specialized wrapper for withResource. withConnection :: MonadBaseControl IO m => ConnectionPool c a -> (c -> Socket -> a -> m r) -> m r instance Typeable ConnectionPool instance Show handlerParams => Show (ConnectionPool handlerParams a) -- | Module defines type family of connection pools that is later -- specialised using type tags (phantom types) to specialize -- implementation of underlying ConnectionPool for various -- protocols. -- -- Internal packages are here to provide access to internal definitions -- for library writers, but they should not be used in application code. -- -- Preferably use qualified import, e.g.: -- --
--   import qualified Data.ConnectionPool.Internal.ConnectionPoolFamily
--     as Internal
--   
-- -- This module doesn't depend on streaming-commons and other -- non-HaskellPlatform packages directly and it is only allowed to import -- Data.ConnectionPool.Internal.ConnectionPool and -- Data.ConnectionPool.Internal.HandlerParams internal module and -- nothing else from this package. This package uses CPP to get OS -- specific things right. Most importantly Windows doesn't support UNIX -- Sockets. -- -- Please, bear above in mind when doing modifications. module Data.ConnectionPool.Internal.ConnectionPoolFamily -- | Family of connection pools parametrised by transport protocol. -- | Type tag used to specialize connection pool for TCP clients. data TcpClient -- | Type tag used to specialize connection pool for UNIX Socket clients. data UnixClient instance Typeable TcpClient instance Typeable UnixClient instance Typeable ConnectionPool -- | Connection pools for TCP clients and UNIX Socket clients (not -- supported on Windows). -- -- This package is built on top of resource-pool and -- streaming-commons packages. The later allows us to use -- conduit-extra package for implementing TCP and UNIX Sockets -- clients. Package conduit-extra defines appSource and -- appSink based on abstractions from streaming-commons -- package and they can be therefore reused. Difference between using -- conduit-extra or streaming-commons is that instead of -- using runTCPClient (or its lifted variant -- runGeneralTCPClient from conduit-extra) one would use -- withTcpClientConnection, and instead of runUnixClient -- it would be withUnixClientConnection. module Data.ConnectionPool -- | Family of connection pools parametrised by transport protocol. -- | Parameters of resource pool that describe things like its internal -- structure. See createPool for details. data ResourcePoolParams -- | Lens for accessing maximum number of resources to keep open per -- stripe. The smallest acceptable value is 1 (default). numberOfResourcesPerStripe :: Functor f => (Int -> f Int) -> ResourcePoolParams -> f ResourcePoolParams -- | Lens for accessing stripe count. The number of distinct sub-pools to -- maintain. The smallest acceptable value is 1 (default). numberOfStripes :: Functor f => (Int -> f Int) -> ResourcePoolParams -> f ResourcePoolParams -- | Lens for accessing amount of time for which an unused resource is kept -- open. The smallest acceptable value is 0.5 seconds (default). resourceIdleTimeout :: Functor f => (NominalDiffTime -> f NominalDiffTime) -> ResourcePoolParams -> f ResourcePoolParams -- | Check if all parameters for underlying resource pool are valid: -- -- -- -- For more details see createPool. -- -- Since version 0.1.1.0. validateResourcePoolParams :: ResourcePoolParams -> Either String ResourcePoolParams -- | Type tag used to specialize connection pool for TCP clients. data TcpClient -- | Settings for a TCP client, specifying how to connect to the server. data ClientSettings :: * -- | The data passed to an Application. data AppData :: * -- | Create connection pool for TCP clients. createTcpClientPool :: ResourcePoolParams -> ClientSettings -> IO (ConnectionPool TcpClient) -- | Temporarily take a TCP connection from a pool, run client with it, and -- return it to the pool afterwards. For details how connections are -- allocated see withResource. withTcpClientConnection :: MonadBaseControl IO m => ConnectionPool TcpClient -> (AppData -> m r) -> m r -- | Destroy all TCP 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. -- -- For more details see destroyAllResources. -- -- Since version 0.1.1.0. destroyAllTcpClientConnections :: ConnectionPool TcpClient -> IO () -- | Type tag used to specialize connection pool for UNIX Socket clients. data UnixClient -- | Settings for a Unix domain sockets client. data ClientSettingsUnix :: * -- | The data passed to a Unix domain sockets Application. data AppDataUnix :: * -- | Create connection pool for UNIX Sockets clients. createUnixClientPool :: ResourcePoolParams -> ClientSettingsUnix -> IO (ConnectionPool UnixClient) -- | Temporarily take a UNIX Sockets connection from a pool, run client -- with it, and return it to the pool afterwards. For details how -- connections are allocated see withResource. withUnixClientConnection :: MonadBaseControl IO m => ConnectionPool UnixClient -> (AppDataUnix -> m r) -> m r -- | Destroy all UNIX Sockets 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. -- -- For more details see destroyAllResources. -- -- Since version 0.1.1.0. destroyAllUnixClientConnections :: ConnectionPool UnixClient -> IO ()