chore(): Add support for extra pool configuration (#11636)
**What** Support more pool configuration
This commit is contained in:
committed by
GitHub
parent
d493347980
commit
ca6a15717d
@@ -19,12 +19,16 @@ export function pgConnectionLoader(): ReturnType<
|
||||
|
||||
// Share a knex connection to be consumed by the shared modules
|
||||
const connectionString = configModule.projectConfig.databaseUrl
|
||||
const driverOptions: any =
|
||||
configModule.projectConfig.databaseDriverOptions || {}
|
||||
const driverOptions: any = {
|
||||
...(configModule.projectConfig.databaseDriverOptions || {}),
|
||||
}
|
||||
const schema = configModule.projectConfig.databaseSchema || "public"
|
||||
const idleTimeoutMillis = driverOptions.pool?.idleTimeoutMillis ?? undefined // prevent null to be passed
|
||||
const poolMin = driverOptions.pool?.min ?? 2
|
||||
const poolMax = driverOptions.pool?.max
|
||||
const reapIntervalMillis = driverOptions.pool?.reapIntervalMillis ?? undefined
|
||||
const createRetryIntervalMillis =
|
||||
driverOptions.pool?.createRetryIntervalMillis ?? undefined
|
||||
|
||||
delete driverOptions.pool
|
||||
|
||||
@@ -36,6 +40,8 @@ export function pgConnectionLoader(): ReturnType<
|
||||
min: poolMin,
|
||||
max: poolMax,
|
||||
idleTimeoutMillis,
|
||||
reapIntervalMillis,
|
||||
createRetryIntervalMillis,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -115,6 +115,10 @@ export class MedusaAppLoader {
|
||||
),
|
||||
}
|
||||
|
||||
const driverOptions = { ...(configManager.config.projectConfig.databaseDriverOptions ?? {}) }
|
||||
const pool = driverOptions.pool ?? {}
|
||||
delete driverOptions.pool
|
||||
|
||||
const sharedResourcesConfig: ModuleServiceInitializeOptions = {
|
||||
database: {
|
||||
clientUrl:
|
||||
@@ -125,6 +129,7 @@ export class MedusaAppLoader {
|
||||
)?.client?.config?.connection?.connectionString ??
|
||||
configManager.config.projectConfig.databaseUrl,
|
||||
driverOptions: configManager.config.projectConfig.databaseDriverOptions,
|
||||
pool: pool,
|
||||
debug: configManager.config.projectConfig.databaseLogging ?? false,
|
||||
schema: configManager.config.projectConfig.databaseSchema,
|
||||
database: configManager.config.projectConfig.databaseName,
|
||||
|
||||
Reference in New Issue
Block a user