module Arbiter.Core.PoolConfig
( PoolConfig (..)
, defaultPoolConfig
, poolConfigForWorkers
) where
data PoolConfig = PoolConfig
{ PoolConfig -> Int
poolSize :: Int
, PoolConfig -> Int
poolIdleTimeout :: Int
, PoolConfig -> Maybe Int
poolStripes :: Maybe Int
}
deriving stock (PoolConfig -> PoolConfig -> Bool
(PoolConfig -> PoolConfig -> Bool)
-> (PoolConfig -> PoolConfig -> Bool) -> Eq PoolConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PoolConfig -> PoolConfig -> Bool
== :: PoolConfig -> PoolConfig -> Bool
$c/= :: PoolConfig -> PoolConfig -> Bool
/= :: PoolConfig -> PoolConfig -> Bool
Eq, Int -> PoolConfig -> ShowS
[PoolConfig] -> ShowS
PoolConfig -> String
(Int -> PoolConfig -> ShowS)
-> (PoolConfig -> String)
-> ([PoolConfig] -> ShowS)
-> Show PoolConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PoolConfig -> ShowS
showsPrec :: Int -> PoolConfig -> ShowS
$cshow :: PoolConfig -> String
show :: PoolConfig -> String
$cshowList :: [PoolConfig] -> ShowS
showList :: [PoolConfig] -> ShowS
Show)
defaultPoolConfig :: PoolConfig
defaultPoolConfig :: PoolConfig
defaultPoolConfig =
PoolConfig
{ poolSize :: Int
poolSize = Int
10
, poolIdleTimeout :: Int
poolIdleTimeout = Int
300
, poolStripes :: Maybe Int
poolStripes = Int -> Maybe Int
forall a. a -> Maybe a
Just Int
1
}
poolConfigForWorkers :: Int -> PoolConfig
poolConfigForWorkers :: Int -> PoolConfig
poolConfigForWorkers Int
workerCnt =
PoolConfig
{ poolSize :: Int
poolSize = Int -> Int -> Int
forall a. Ord a => a -> a -> a
max Int
2 (Int
2 Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
workerCnt)
, poolIdleTimeout :: Int
poolIdleTimeout = Int
300
, poolStripes :: Maybe Int
poolStripes = Int -> Maybe Int
forall a. a -> Maybe a
Just Int
1
}