Skip to content

Commit 687b7ea

Browse files
committed
chore: expose min and idleTimeoutMillis pg options
1 parent c02cae1 commit 687b7ea

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Replaced `idle_session_timeout` (server-side Postgres setting) with `idleTimeoutMillis` (client-side pg-pool setting) for idle connection cleanup. Set via `dbSync.idleTimeoutMs` in config or `BLOCKFROST_CONFIG_DBSYNC_IDLE_TIMEOUT_MS` env var (value in milliseconds). Disabled by default (pg-pool falls back to its own 10,000ms default). The previous `dbSync.idleSessionTimeoutMs` / `BLOCKFROST_CONFIG_DBSYNC_IDLE_SESSION_TIMEOUT_MS` options are removed.
13+
- Exposed `min` pool size option. Set via `dbSync.minConnections` in config or `BLOCKFROST_CONFIG_DBSYNC_MIN_CONN` env var. Disabled by default (pg-pool defaults to 0).
14+
1015
## [6.3.4] - 2026-03-17
1116

1217
### Added

src/app.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,11 @@ const start = (options = {}): FastifyInstance => {
118118
application_name: config.dbSync.applicationName,
119119
statement_timeout: config.dbSync.statementTimeout,
120120
connectionTimeoutMillis: config.dbSync.connectionTimeoutMs,
121-
...(config.dbSync.idleSessionTimeoutMs !== undefined && {
122-
options: `-c idle_session_timeout=${config.dbSync.idleSessionTimeoutMs}`,
121+
...(config.dbSync.idleTimeoutMs !== undefined && {
122+
idleTimeoutMillis: config.dbSync.idleTimeoutMs,
123+
}),
124+
...(config.dbSync.minConnections !== undefined && {
125+
min: config.dbSync.minConnections,
123126
}),
124127
});
125128

src/config.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,15 @@ export const loadConfig = () => {
8383
: config.has('dbSync.connectionTimeoutMs')
8484
? config.get<number>('dbSync.connectionTimeoutMs')
8585
: undefined;
86-
const databaseSyncIdleSessionTimeoutMs = process.env
87-
.BLOCKFROST_CONFIG_DBSYNC_IDLE_SESSION_TIMEOUT_MS
88-
? Number(process.env.BLOCKFROST_CONFIG_DBSYNC_IDLE_SESSION_TIMEOUT_MS)
89-
: config.has('dbSync.idleSessionTimeoutMs')
90-
? config.get<number>('dbSync.idleSessionTimeoutMs')
86+
const databaseSyncIdleTimeoutMs = process.env.BLOCKFROST_CONFIG_DBSYNC_IDLE_TIMEOUT_MS
87+
? Number(process.env.BLOCKFROST_CONFIG_DBSYNC_IDLE_TIMEOUT_MS)
88+
: config.has('dbSync.idleTimeoutMs')
89+
? config.get<number>('dbSync.idleTimeoutMs')
90+
: undefined;
91+
const databaseSyncMinConnections = process.env.BLOCKFROST_CONFIG_DBSYNC_MIN_CONN
92+
? Number(process.env.BLOCKFROST_CONFIG_DBSYNC_MIN_CONN)
93+
: config.has('dbSync.minConnections')
94+
? config.get<number>('dbSync.minConnections')
9195
: undefined;
9296
const ssl = config.has('dbSync.ssl') ? { rejectUnauthorized: false } : false;
9397
const databaseSyncApplicationName =
@@ -174,7 +178,8 @@ export const loadConfig = () => {
174178
maxConnections: databaseSyncMaxConnections,
175179
statementTimeout: databaseSyncStatementTimeout,
176180
connectionTimeoutMs: databaseSyncConnectionTimeoutMs,
177-
idleSessionTimeoutMs: databaseSyncIdleSessionTimeoutMs,
181+
idleTimeoutMs: databaseSyncIdleTimeoutMs,
182+
minConnections: databaseSyncMinConnections,
178183
ssl,
179184
applicationName: databaseSyncApplicationName,
180185
},

0 commit comments

Comments
 (0)