Provide command-line flag for db pool size
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
name: dbapi
|
name: dbapi
|
||||||
version: 0.2.3.0
|
version: 0.2.4.0
|
||||||
synopsis: The database is your api
|
synopsis: The database is your api
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ data AppConfig = AppConfig {
|
|||||||
, configPort :: Int
|
, configPort :: Int
|
||||||
, configAnonRole :: String
|
, configAnonRole :: String
|
||||||
, configSecure :: Bool
|
, configSecure :: Bool
|
||||||
|
, configPool :: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
data AuthUser = AuthUser {
|
data AuthUser = AuthUser {
|
||||||
|
|||||||
+4
-2
@@ -26,12 +26,14 @@ argParser = AppConfig
|
|||||||
<*> strOption (long "anonymous" <> short 'a' <> metavar "ROLE"
|
<*> strOption (long "anonymous" <> short 'a' <> metavar "ROLE"
|
||||||
<> help "postgres role to use for non-authenticated requests")
|
<> help "postgres role to use for non-authenticated requests")
|
||||||
<*> switch (long "secure" <> short 's'
|
<*> 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 :: IO ()
|
||||||
main = do
|
main = do
|
||||||
conf <- execParser (info (helper <*> argParser) describe)
|
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
|
let port = configPort conf
|
||||||
|
|
||||||
unless (configSecure conf) $
|
unless (configSecure conf) $
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ isLeft (Left _ ) = True
|
|||||||
isLeft _ = False
|
isLeft _ = False
|
||||||
|
|
||||||
cfg :: AppConfig
|
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 :: IO Connection
|
||||||
openConnection = connectPostgreSQL' $ configDbUri cfg
|
openConnection = connectPostgreSQL' $ configDbUri cfg
|
||||||
|
|||||||
Reference in New Issue
Block a user