feat: introduce pool acquisition timeout (fixes #2348)
The configuration option db-pool-acquisition-timeout specifies the time in seconds to wait for the pool to free up a connection slot. Otherwise, a 504 error is returned. By default, there is no timeout.
This commit is contained in:
@@ -97,7 +97,10 @@ destroy = destroyPool
|
||||
|
||||
initPool :: AppConfig -> IO SQL.Pool
|
||||
initPool AppConfig{..} =
|
||||
SQL.acquire configDbPoolSize Nothing $ toUtf8 configDbUri
|
||||
SQL.acquire configDbPoolSize timeoutMilliseconds $ toUtf8 configDbUri
|
||||
where
|
||||
timeoutMilliseconds = (* oneSecond) <$> configDbPoolAcquisitionTimeout
|
||||
oneSecond = 1000000
|
||||
|
||||
-- | Run an action with a database connection.
|
||||
usePool :: AppState -> SQL.Session a -> IO (Either SQL.UsageError a)
|
||||
|
||||
Reference in New Issue
Block a user