module Hasql.Pool.Config.Config where

import qualified Hasql.Connection as Connection
import qualified Hasql.Pool.Config.Defaults as Defaults
import Hasql.Pool.Observation (Observation)
import Hasql.Pool.Prelude

-- | Configufation for Hasql connection pool.
data Config = Config
  { Config -> Int
size :: Int,
    Config -> DiffTime
acquisitionTimeout :: DiffTime,
    Config -> DiffTime
agingTimeout :: DiffTime,
    Config -> DiffTime
idlenessTimeout :: DiffTime,
    Config -> IO Settings
connectionSettingsProvider :: IO Connection.Settings,
    Config -> Observation -> IO ()
observationHandler :: Observation -> IO ()
  }

-- | Reasonable defaults, which can be built upon.
defaults :: Config
defaults :: Config
defaults =
  Config
    { size :: Int
size = Int
Defaults.size,
      acquisitionTimeout :: DiffTime
acquisitionTimeout = DiffTime
Defaults.acquisitionTimeout,
      agingTimeout :: DiffTime
agingTimeout = DiffTime
Defaults.agingTimeout,
      idlenessTimeout :: DiffTime
idlenessTimeout = DiffTime
Defaults.idlenessTimeout,
      connectionSettingsProvider :: IO Settings
connectionSettingsProvider = IO Settings
Defaults.dynamicConnectionSettings,
      observationHandler :: Observation -> IO ()
observationHandler = Observation -> IO ()
Defaults.observationHandler
    }