Add config option for pool timeout (#1280)
This commit is contained in:
committed by
Steve Chávez
parent
2044f77d49
commit
d32f373e1e
@@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- #690, Add `?columns` query parameter for faster bulk inserts, also ignores unspecified json keys in a payload - @steve-chavez
|
||||
- #1239, Add support for resource embedding on materialized views - @vitorbaptista
|
||||
- #1264, Add support for bulk RPC call - @steve-chavez
|
||||
- #1278, Add db-pool-timeout config option - @qu4tro
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -19,6 +20,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- #1238, Fix PostgreSQL to OpenAPI type mappings for numeric and character types - @fpusch
|
||||
- #1265, Fix query generated on bulk upsert with an empty array - @qu4tro
|
||||
- #1273, Fix RPC ignoring unknown arguments by default - @steve-chavez
|
||||
- #1257, Fix incorrect status when a PATCH request doesn't find rows to change - @qu4tro
|
||||
|
||||
## [5.2.0] - 2018-12-12
|
||||
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ module Main where
|
||||
|
||||
|
||||
import PostgREST.App (postgrest)
|
||||
import PostgREST.Config (AppConfig (..),
|
||||
import PostgREST.Config (AppConfig (..), configPoolTimeout',
|
||||
prettyVersion, readOptions)
|
||||
import PostgREST.DbStructure (getDbStructure, getPgVersion)
|
||||
import PostgREST.Error (encodeError)
|
||||
@@ -164,7 +164,7 @@ main = do
|
||||
--
|
||||
-- create connection pool with the provided settings, returns either
|
||||
-- a 'Connection' or a 'ConnectionError'. Does not throw.
|
||||
pool <- P.acquire (configPool conf, 10, pgSettings)
|
||||
pool <- P.acquire (configPool conf, configPoolTimeout' conf, pgSettings)
|
||||
--
|
||||
-- To be filled in by connectionWorker
|
||||
refDbStructure <- newIORef Nothing
|
||||
|
||||
@@ -19,6 +19,7 @@ module PostgREST.Config ( prettyVersion
|
||||
, readOptions
|
||||
, corsPolicy
|
||||
, AppConfig (..)
|
||||
, configPoolTimeout'
|
||||
)
|
||||
where
|
||||
|
||||
@@ -73,6 +74,7 @@ data AppConfig = AppConfig {
|
||||
, configJwtAudience :: Maybe StringOrURI
|
||||
|
||||
, configPool :: Int
|
||||
, configPoolTimeout :: Int
|
||||
, configMaxRows :: Maybe Integer
|
||||
, configReqCheck :: Maybe Text
|
||||
, configQuiet :: Bool
|
||||
@@ -81,6 +83,11 @@ data AppConfig = AppConfig {
|
||||
, configExtraSearchPath :: [Text]
|
||||
}
|
||||
|
||||
configPoolTimeout' :: (Fractional a) => AppConfig -> a
|
||||
configPoolTimeout' =
|
||||
fromRational . toRational . configPoolTimeout
|
||||
|
||||
|
||||
defaultCorsPolicy :: CorsResourcePolicy
|
||||
defaultCorsPolicy = CorsResourcePolicy Nothing
|
||||
["GET", "POST", "PATCH", "PUT", "DELETE", "OPTIONS"] ["Authorization"] Nothing
|
||||
@@ -136,6 +143,7 @@ readOptions = do
|
||||
<*> (fromMaybe False . join . fmap coerceBool <$> C.key "secret-is-base64")
|
||||
<*> parseJwtAudience "jwt-aud"
|
||||
<*> (fromMaybe 10 . join . fmap coerceInt <$> C.key "db-pool")
|
||||
<*> (fromMaybe 10 . join . fmap coerceInt <$> C.key "db-pool-timeout")
|
||||
<*> (join . fmap coerceInt <$> C.key "max-rows")
|
||||
<*> (mfilter (/= "") <$> C.key "pre-request")
|
||||
<*> pure False
|
||||
@@ -208,6 +216,7 @@ readOptions = do
|
||||
|db-schema = "public" # this schema gets added to the search_path of every request
|
||||
|db-anon-role = "postgres"
|
||||
|db-pool = 10
|
||||
|db-pool-timeout = 10
|
||||
|
|
||||
|server-host = "127.0.0.1"
|
||||
|server-port = 3000
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ _baseCfg = -- Connection Settings
|
||||
-- Jwt settings
|
||||
(Just $ encodeUtf8 "reallyreallyreallyreallyverysafe") False Nothing
|
||||
-- Connection Modifiers
|
||||
10 Nothing (Just "test.switch_role")
|
||||
10 10 Nothing (Just "test.switch_role")
|
||||
-- Debug Settings
|
||||
True
|
||||
[ ("app.settings.app_host", "localhost")
|
||||
|
||||
Reference in New Issue
Block a user