diff --git a/dbapi.cabal b/dbapi.cabal index 6097b1f8e..dfbe0033c 100644 --- a/dbapi.cabal +++ b/dbapi.cabal @@ -1,5 +1,5 @@ name: dbapi -version: 0.2.3.0 +version: 0.2.4.0 synopsis: The database is your api license: MIT license-file: LICENSE diff --git a/src/Dbapi.hs b/src/Dbapi.hs index 1b1606041..bd63b33f6 100644 --- a/src/Dbapi.hs +++ b/src/Dbapi.hs @@ -49,6 +49,7 @@ data AppConfig = AppConfig { , configPort :: Int , configAnonRole :: String , configSecure :: Bool + , configPool :: Int } data AuthUser = AuthUser { diff --git a/src/Main.hs b/src/Main.hs index e840202d5..4ad8154d6 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -26,12 +26,14 @@ argParser = AppConfig <*> strOption (long "anonymous" <> short 'a' <> metavar "ROLE" <> help "postgres role to use for non-authenticated requests") <*> switch (long "secure" <> short 's' - <> help "Redirect all requests to HTTPS" ) + <> help "Redirect all requests to HTTPS") + <*> option (long "db-pool" <> metavar "NUMBER" <> value 10 + <> help "Max connections in database pool") main :: IO () main = do conf <- execParser (info (helper <*> argParser) describe) - pool <- createPool (connectPostgreSQL' (configDbUri conf)) disconnect 1 600 10 + pool <- createPool (connectPostgreSQL' (configDbUri conf)) disconnect 1 600 (configPool conf) let port = configPort conf unless (configSecure conf) $ diff --git a/test/SpecHelper.hs b/test/SpecHelper.hs index 46c8264b8..6e9f7940a 100644 --- a/test/SpecHelper.hs +++ b/test/SpecHelper.hs @@ -29,7 +29,7 @@ isLeft (Left _ ) = True isLeft _ = False cfg :: AppConfig -cfg = AppConfig "postgres://dbapi_test:@localhost:5432/dbapi_test" 9000 "dbapi_anonymous" False +cfg = AppConfig "postgres://dbapi_test:@localhost:5432/dbapi_test" 9000 "dbapi_anonymous" False 10 openConnection :: IO Connection openConnection = connectPostgreSQL' $ configDbUri cfg