-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Simple pool
--
-- Provides a simple pool implementation.
@package simpoole
@version 0.2.0
module Simpoole
-- | Pool of resources
data Pool m a
-- | Lift a natural transformation m ~> n to Pool m ~>
-- Pool n.
mapPool :: (forall x. m x -> n x) -> Pool m a -> Pool n a
-- | Create a new pool.
newPool :: (MonadConc m, MonadIO m) => m a -> (a -> m ()) -> Settings -> m (Pool m a)
-- | Use a resource from the pool. Once the continuation returns, the
-- resource will be returned to the pool. If the given continuation
-- throws an error then the acquired resource will be destroyed instead.
withResource :: MonadMask m => Pool m a -> (a -> m r) -> m r
-- | Acquire a resource.
acquireResource :: Pool m a -> m a
-- | Return a resource to the pool.
returnResource :: Pool m a -> a -> m ()
-- | Destroy a resource.
destroyResource :: Pool m a -> a -> m ()
-- | Fetch pool metrics.
poolMetrics :: Pool m a -> m (Metrics Natural)
-- | Lets you configure certain behaviours of the pool
data Settings
Settings :: Maybe NominalDiffTime -> ReturnPolicy -> Maybe Int -> Settings
-- | Maximum idle time after which a resource is destroyed
--
-- Setting it to Nothing means that nothing will ever be
-- destroyed based on idle time.
[settings_idleTimeout] :: Settings -> Maybe NominalDiffTime
-- | Read documentation on ReturnPolicy for details.
[settings_returnPolicy] :: Settings -> ReturnPolicy
-- | Maximum number of resources that may live at the same time.
--
-- Nothing means unlimited.
[settings_maxLiveLimit] :: Settings -> Maybe Int
-- | Default pool settings
defaultSettings :: Settings
-- | Strategy to use when returning resources to the pool
data ReturnPolicy
-- | Return resources to the front. Resources that have been used recently
-- are more likely to be reused again quicker.
--
-- This strategy is good if you want to scale down the pool more quickly
-- in case resources are not needed.
ReturnToFront :: ReturnPolicy
-- | Return resources to the back. Resources that have been used recently
-- are less likely to be used again quicker.
--
-- Use this strategy if you want to keep more resources in the pool
-- fresh, or when maintaining the pool in order to be ready for burst
-- workloads.
--
-- Note: This strategy can lead to no resources ever being destroyed when
-- all resources are continuously used within the idle timeout.
ReturnToBack :: ReturnPolicy
-- | Return resources to the middle. This offers a middleground between
-- ReturnToFront and ReturnToBack. By ensuring that the
-- starting sub-sequence of resources is reused quicker but the trailing
-- sub-sequence is not and therefore released more easily.
ReturnToMiddle :: ReturnPolicy
-- | Pool metrics
data Metrics a
Metrics :: a -> a -> a -> a -> Metrics a
-- | Total number of resources created
[metrics_createdResources] :: Metrics a -> a
-- | Total number of resources destroyed
[metrics_destroyedResources] :: Metrics a -> a
-- | Maximum number of resources that were alive simultaneously
[metrics_maxLiveResources] :: Metrics a -> a
-- | Number of resources currently idle
[metrics_idleResources] :: Metrics a -> a
instance GHC.Enum.Bounded Simpoole.ReturnPolicy
instance GHC.Enum.Enum Simpoole.ReturnPolicy
instance GHC.Classes.Ord Simpoole.ReturnPolicy
instance GHC.Classes.Eq Simpoole.ReturnPolicy
instance GHC.Read.Read Simpoole.ReturnPolicy
instance GHC.Show.Show Simpoole.ReturnPolicy
instance Data.Traversable.Traversable Simpoole.Metrics
instance Data.Foldable.Foldable Simpoole.Metrics
instance GHC.Base.Functor Simpoole.Metrics
instance GHC.Classes.Ord a => GHC.Classes.Ord (Simpoole.Metrics a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Simpoole.Metrics a)
instance GHC.Read.Read a => GHC.Read.Read (Simpoole.Metrics a)
instance GHC.Show.Show a => GHC.Show.Show (Simpoole.Metrics a)