simpoole-0.1.0: Simple pool
Safe HaskellNone
LanguageHaskell2010

Simpoole

Synopsis

Documentation

data Pool m a Source #

Pool of resources

Since: 0.0.0

mapPool :: (forall x. m x -> n x) -> Pool m a -> Pool n a Source #

Lift a natural transformation m ~> n to Pool m ~> Pool n.

Since: 0.0.0

newUnlimitedPool Source #

Arguments

:: (MonadConc m, MonadIO m) 
=> m a

Resource creation

-> (a -> m ())

Resource destruction

-> Settings

Pool settings

-> m (Pool m a) 

Create a new pool that has no limit on how many resources it may create and hold.

Since: 0.1.0

newPool Source #

Arguments

:: (MonadConc m, MonadIO m, MonadFail m) 
=> m a

Resource creation

-> (a -> m ())

Resource destruction

-> Int

Maximum number of resources to exist at the same time

-> Settings

Pool 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.

Since: 0.1.0

withResource :: MonadMask m => Pool m a -> (a -> m r) -> m r Source #

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.

Since: 0.0.0

acquireResource :: Pool m a -> m a Source #

Acquire a resource.

Since: 0.1.0

returnResource :: Pool m a -> a -> m () Source #

Return a resource to the pool.

Since: 0.1.0

destroyResource :: Pool m a -> a -> m () Source #

Destroy a resource.

Since: 0.1.0

poolMetrics :: Pool m a -> m (Metrics Natural) Source #

Fetch pool metrics.

Since: 0.0.0

data Settings Source #

Lets you configure certain behaviours of the pool

Since: 0.1.0

Constructors

PoolSettings 

Fields

defaultSettings :: Settings Source #

Default pool settings

Since: 0.1.0

data ReturnPolicy Source #

Strategy to use when returning resources to the pool

Since: 0.1.0

Constructors

ReturnToFront

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.

Since: 0.1.0

ReturnToBack

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.

Since: 0.1.0

ReturnToMiddle

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.

Since: 0.1.0

Instances

Instances details
Bounded ReturnPolicy Source # 
Instance details

Defined in Simpoole

Enum ReturnPolicy Source # 
Instance details

Defined in Simpoole

Eq ReturnPolicy Source # 
Instance details

Defined in Simpoole

Ord ReturnPolicy Source # 
Instance details

Defined in Simpoole

Read ReturnPolicy Source # 
Instance details

Defined in Simpoole

Show ReturnPolicy Source # 
Instance details

Defined in Simpoole

data Metrics a Source #

Pool metrics

Since: 0.0.0

Constructors

Metrics 

Fields

Instances

Instances details
Functor Metrics Source # 
Instance details

Defined in Simpoole

Methods

fmap :: (a -> b) -> Metrics a -> Metrics b #

(<$) :: a -> Metrics b -> Metrics a #

Foldable Metrics Source # 
Instance details

Defined in Simpoole

Methods

fold :: Monoid m => Metrics m -> m #

foldMap :: Monoid m => (a -> m) -> Metrics a -> m #

foldMap' :: Monoid m => (a -> m) -> Metrics a -> m #

foldr :: (a -> b -> b) -> b -> Metrics a -> b #

foldr' :: (a -> b -> b) -> b -> Metrics a -> b #

foldl :: (b -> a -> b) -> b -> Metrics a -> b #

foldl' :: (b -> a -> b) -> b -> Metrics a -> b #

foldr1 :: (a -> a -> a) -> Metrics a -> a #

foldl1 :: (a -> a -> a) -> Metrics a -> a #

toList :: Metrics a -> [a] #

null :: Metrics a -> Bool #

length :: Metrics a -> Int #

elem :: Eq a => a -> Metrics a -> Bool #

maximum :: Ord a => Metrics a -> a #

minimum :: Ord a => Metrics a -> a #

sum :: Num a => Metrics a -> a #

product :: Num a => Metrics a -> a #

Traversable Metrics Source # 
Instance details

Defined in Simpoole

Methods

traverse :: Applicative f => (a -> f b) -> Metrics a -> f (Metrics b) #

sequenceA :: Applicative f => Metrics (f a) -> f (Metrics a) #

mapM :: Monad m => (a -> m b) -> Metrics a -> m (Metrics b) #

sequence :: Monad m => Metrics (m a) -> m (Metrics a) #

Eq a => Eq (Metrics a) Source # 
Instance details

Defined in Simpoole

Methods

(==) :: Metrics a -> Metrics a -> Bool #

(/=) :: Metrics a -> Metrics a -> Bool #

Ord a => Ord (Metrics a) Source # 
Instance details

Defined in Simpoole

Methods

compare :: Metrics a -> Metrics a -> Ordering #

(<) :: Metrics a -> Metrics a -> Bool #

(<=) :: Metrics a -> Metrics a -> Bool #

(>) :: Metrics a -> Metrics a -> Bool #

(>=) :: Metrics a -> Metrics a -> Bool #

max :: Metrics a -> Metrics a -> Metrics a #

min :: Metrics a -> Metrics a -> Metrics a #

Read a => Read (Metrics a) Source # 
Instance details

Defined in Simpoole

Show a => Show (Metrics a) Source # 
Instance details

Defined in Simpoole

Methods

showsPrec :: Int -> Metrics a -> ShowS #

show :: Metrics a -> String #

showList :: [Metrics a] -> ShowS #