mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-11 11:48:28 +01:00
Infer pg pool size from number of caps by default
This commit is contained in:
parent
47ae6b8387
commit
af20bc6291
@ -36,8 +36,8 @@ runBenchApp pool m = runSimpleApp $ runSqlPool m pool
|
||||
createBenchPool :: IO ConnectionPool
|
||||
createBenchPool = do
|
||||
loadYamlSettingsArgs [configSettingsYmlValue] useEnv >>= \case
|
||||
AppSettings{appDatabase = DSPostgres pgString pgPoolSize} ->
|
||||
runNoLoggingT $ createPostgresqlPool (encodeUtf8 pgString) pgPoolSize
|
||||
AppSettings{appDatabase = DSPostgres pgString _} ->
|
||||
runNoLoggingT $ createPostgresqlPool (encodeUtf8 pgString) 1
|
||||
_ -> throwString "Benchmarks are crafted for PostgreSQL"
|
||||
|
||||
releasePool :: ConnectionPool -> IO ()
|
||||
|
||||
@ -56,7 +56,7 @@ data AppSettings = AppSettings
|
||||
}
|
||||
|
||||
data DatabaseSettings
|
||||
= DSPostgres !Text !Int
|
||||
= DSPostgres !Text !(Maybe Int)
|
||||
| DSSqlite !Text !Int
|
||||
|
||||
parseDatabase
|
||||
|
||||
@ -66,6 +66,7 @@ import RIO
|
||||
import RIO.Time
|
||||
import Types (CompilerP(..), FlagNameP, Origin, SnapName, VersionRangeP)
|
||||
import Settings (DatabaseSettings (..))
|
||||
import UnliftIO.Concurrent (getNumCapabilities)
|
||||
|
||||
currentSchema :: Int
|
||||
currentSchema = 1
|
||||
@ -197,7 +198,9 @@ withStackageDatabase shouldLog dbs inner = do
|
||||
let makePool :: (MonadUnliftIO m, MonadLogger m) => m (Pool SqlBackend)
|
||||
makePool =
|
||||
case dbs of
|
||||
DSPostgres connStr size -> createPostgresqlPool (encodeUtf8 connStr) size
|
||||
DSPostgres connStr mSize -> do
|
||||
size <- maybe getNumCapabilities pure mSize
|
||||
createPostgresqlPool (encodeUtf8 connStr) size
|
||||
DSSqlite connStr size -> do
|
||||
pool <- createSqlitePool connStr size
|
||||
runSqlPool (do
|
||||
|
||||
Loading…
Reference in New Issue
Block a user