-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Simple pool
--
-- Provides a simple pool implementation.
@package simpoole
@version 0.1.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 that has no limit on how many resources it may
-- create and hold.
newUnlimitedPool :: (MonadConc m, MonadIO m) => m a -> (a -> m ()) -> Settings -> m (Pool m a)
-- | Similar to newUnlimitedPool but allows you to limit the number
-- of resources that will exist at the same time. When all resources are
-- currently in use, further resource acquisition will block until one is
-- no longer in use.
newPool :: (MonadConc m, MonadIO m, MonadFail m) => m a -> (a -> m ()) -> Int -> 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
PoolSettings :: NominalDiffTime -> ReturnPolicy -> Settings
-- | Maximum idle time after which a resource is destroyed
[settings_idleTimeout] :: Settings -> NominalDiffTime
[settings_returnPolicy] :: Settings -> ReturnPolicy
-- | 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. This strategy can lead
-- to no resources ever been freed when all resources are 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)