Provide command-line flag for db pool size
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
@@ -49,6 +49,7 @@ data AppConfig = AppConfig {
|
||||
, configPort :: Int
|
||||
, configAnonRole :: String
|
||||
, configSecure :: Bool
|
||||
, configPool :: Int
|
||||
}
|
||||
|
||||
data AuthUser = AuthUser {
|
||||
|
||||
+4
-2
@@ -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) $
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user