+3
-8
@@ -0,1 +1,2 @@ | ||
| import { parseEnvNumber } from '12factor-env'; | ||
| import { Logger } from '@pgpmjs/logger'; | ||
@@ -9,8 +10,2 @@ import { LRUCache } from 'lru-cache'; | ||
| const SYS_EVENTS = ['SIGTERM']; | ||
| const parseEnvInt = (val, fallback) => { | ||
| if (!val) | ||
| return fallback; | ||
| const n = parseInt(val, 10); | ||
| return isNaN(n) ? fallback : n; | ||
| }; | ||
| /** | ||
@@ -25,4 +20,4 @@ * Read cache configuration from environment variables. | ||
| return { | ||
| max: parseEnvInt(process.env.PG_CACHE_MAX, 50), | ||
| ttl: parseEnvInt(process.env.PG_CACHE_TTL_MS, ONE_YEAR), | ||
| max: parseEnvNumber(process.env.PG_CACHE_MAX) ?? 50, | ||
| ttl: parseEnvNumber(process.env.PG_CACHE_TTL_MS) ?? ONE_YEAR, | ||
| }; | ||
@@ -29,0 +24,0 @@ } |
+4
-9
@@ -0,1 +1,2 @@ | ||
| import { parseEnvNumber } from '12factor-env'; | ||
| import pg from 'pg'; | ||
@@ -8,8 +9,2 @@ import { getPgEnvOptions } from 'pg-env'; | ||
| export const buildConnectionString = (user, password, host, port, database) => `postgres://${user}:${password}@${host}:${port}/${database}`; | ||
| const parseEnvInt = (val, fallback) => { | ||
| if (!val) | ||
| return fallback; | ||
| const n = parseInt(val, 10); | ||
| return isNaN(n) ? fallback : n; | ||
| }; | ||
| /** | ||
@@ -25,5 +20,5 @@ * Read per-pool configuration from environment variables. | ||
| return { | ||
| max: overrides?.max ?? parseEnvInt(process.env.PG_POOL_MAX, 5), | ||
| idleTimeoutMillis: overrides?.idleTimeoutMillis ?? parseEnvInt(process.env.PG_POOL_IDLE_TIMEOUT_MS, 30000), | ||
| connectionTimeoutMillis: overrides?.connectionTimeoutMillis ?? parseEnvInt(process.env.PG_POOL_CONNECTION_TIMEOUT_MS, 5000), | ||
| max: overrides?.max ?? parseEnvNumber(process.env.PG_POOL_MAX) ?? 5, | ||
| idleTimeoutMillis: overrides?.idleTimeoutMillis ?? parseEnvNumber(process.env.PG_POOL_IDLE_TIMEOUT_MS) ?? 30000, | ||
| connectionTimeoutMillis: overrides?.connectionTimeoutMillis ?? parseEnvNumber(process.env.PG_POOL_CONNECTION_TIMEOUT_MS) ?? 5000, | ||
| ...(overrides?.allowExitOnIdle !== undefined && { allowExitOnIdle: overrides.allowExitOnIdle }), | ||
@@ -30,0 +25,0 @@ }; |
+3
-8
@@ -5,2 +5,3 @@ "use strict"; | ||
| exports.getPgCacheConfig = getPgCacheConfig; | ||
| const _12factor_env_1 = require("12factor-env"); | ||
| const logger_1 = require("@pgpmjs/logger"); | ||
@@ -14,8 +15,2 @@ const lru_cache_1 = require("lru-cache"); | ||
| const SYS_EVENTS = ['SIGTERM']; | ||
| const parseEnvInt = (val, fallback) => { | ||
| if (!val) | ||
| return fallback; | ||
| const n = parseInt(val, 10); | ||
| return isNaN(n) ? fallback : n; | ||
| }; | ||
| /** | ||
@@ -30,4 +25,4 @@ * Read cache configuration from environment variables. | ||
| return { | ||
| max: parseEnvInt(process.env.PG_CACHE_MAX, 50), | ||
| ttl: parseEnvInt(process.env.PG_CACHE_TTL_MS, ONE_YEAR), | ||
| max: (0, _12factor_env_1.parseEnvNumber)(process.env.PG_CACHE_MAX) ?? 50, | ||
| ttl: (0, _12factor_env_1.parseEnvNumber)(process.env.PG_CACHE_TTL_MS) ?? ONE_YEAR, | ||
| }; | ||
@@ -34,0 +29,0 @@ } |
+5
-4
| { | ||
| "name": "pg-cache", | ||
| "version": "3.15.1", | ||
| "version": "3.15.2", | ||
| "author": "Constructive <developers@constructive.io>", | ||
@@ -32,7 +32,8 @@ "description": "PostgreSQL connection pool LRU cache manager", | ||
| "dependencies": { | ||
| "12factor-env": "^1.17.1", | ||
| "@pgpmjs/logger": "^2.14.0", | ||
| "@pgpmjs/types": "^2.35.0", | ||
| "@pgpmjs/types": "^2.35.1", | ||
| "lru-cache": "^11.2.7", | ||
| "pg": "^8.21.0", | ||
| "pg-env": "^1.18.0" | ||
| "pg-env": "^1.18.1" | ||
| }, | ||
@@ -52,3 +53,3 @@ "devDependencies": { | ||
| ], | ||
| "gitHead": "dd2accb683fe20c7278a0d58fd36a04a3b07ac63" | ||
| "gitHead": "e53a570a4a70987e82dc074bd73501971fd82828" | ||
| } |
+4
-9
@@ -8,2 +8,3 @@ "use strict"; | ||
| exports.getPgPoolConfig = getPgPoolConfig; | ||
| const _12factor_env_1 = require("12factor-env"); | ||
| const pg_1 = __importDefault(require("pg")); | ||
@@ -17,8 +18,2 @@ const pg_env_1 = require("pg-env"); | ||
| exports.buildConnectionString = buildConnectionString; | ||
| const parseEnvInt = (val, fallback) => { | ||
| if (!val) | ||
| return fallback; | ||
| const n = parseInt(val, 10); | ||
| return isNaN(n) ? fallback : n; | ||
| }; | ||
| /** | ||
@@ -34,5 +29,5 @@ * Read per-pool configuration from environment variables. | ||
| return { | ||
| max: overrides?.max ?? parseEnvInt(process.env.PG_POOL_MAX, 5), | ||
| idleTimeoutMillis: overrides?.idleTimeoutMillis ?? parseEnvInt(process.env.PG_POOL_IDLE_TIMEOUT_MS, 30000), | ||
| connectionTimeoutMillis: overrides?.connectionTimeoutMillis ?? parseEnvInt(process.env.PG_POOL_CONNECTION_TIMEOUT_MS, 5000), | ||
| max: overrides?.max ?? (0, _12factor_env_1.parseEnvNumber)(process.env.PG_POOL_MAX) ?? 5, | ||
| idleTimeoutMillis: overrides?.idleTimeoutMillis ?? (0, _12factor_env_1.parseEnvNumber)(process.env.PG_POOL_IDLE_TIMEOUT_MS) ?? 30000, | ||
| connectionTimeoutMillis: overrides?.connectionTimeoutMillis ?? (0, _12factor_env_1.parseEnvNumber)(process.env.PG_POOL_CONNECTION_TIMEOUT_MS) ?? 5000, | ||
| ...(overrides?.allowExitOnIdle !== undefined && { allowExitOnIdle: overrides.allowExitOnIdle }), | ||
@@ -39,0 +34,0 @@ }; |
42604
-0.54%6
20%747
-2.61%+ Added
+ Added
Updated
Updated