Safe Haskell | None |
---|---|
Language | Haskell2010 |
Simpoole
Synopsis
- data Pool m a
- mapPool :: (forall x. m x -> n x) -> Pool m a -> Pool n a
- newPool :: (MonadConc m, MonadIO m) => m a -> (a -> m ()) -> Settings -> m (Pool m a)
- withResource :: MonadMask m => Pool m a -> (a -> m r) -> m r
- acquireResource :: Pool m a -> m a
- returnResource :: Pool m a -> a -> m ()
- destroyResource :: Pool m a -> a -> m ()
- poolMetrics :: Pool m a -> m (Metrics Natural)
- data Settings = Settings {}
- defaultSettings :: Settings
- data ReturnPolicy
- data Metrics a = Metrics {}
Documentation
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
Arguments
:: (MonadConc m, MonadIO m) | |
=> m a | Resource creation |
-> (a -> m ()) | Resource destruction |
-> Settings | Pool settings |
-> m (Pool m a) |
Create a new pool.
Since: 0.2.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
Lets you configure certain behaviours of the pool
Since: 0.1.0
Constructors
Settings | Since: 0.2.0 |
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. Note: This strategy can lead to no resources ever being destroyed when all resources are repeatedly used within the idle timeout. Since: 0.1.0 |
ReturnToMiddle | Return resources to the middle. This offers a middleground between Since: 0.1.0 |
Instances
Pool metrics
Since: 0.0.0
Constructors
Metrics | |
Fields
|
Instances
Functor Metrics Source # | |
Foldable Metrics Source # | |
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 # elem :: Eq a => a -> Metrics a -> Bool # maximum :: Ord a => Metrics a -> a # minimum :: Ord a => Metrics a -> a # | |
Traversable Metrics Source # | |
Eq a => Eq (Metrics a) Source # | |
Ord a => Ord (Metrics a) Source # | |
Read a => Read (Metrics a) Source # | |
Show a => Show (Metrics a) Source # | |