@constructive-io/job-pg 0.3.20 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.js +6 -5
- package/package.json +4 -3
- package/src/index.ts +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.4.0](https://github.com/constructive-io/jobs/compare/@constructive-io/job-pg@0.3.21...@constructive-io/job-pg@0.4.0) (2026-01-18)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @constructive-io/job-pg
|
|
9
|
+
|
|
10
|
+
## [0.3.21](https://github.com/constructive-io/jobs/compare/@constructive-io/job-pg@0.3.20...@constructive-io/job-pg@0.3.21) (2026-01-18)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @constructive-io/job-pg
|
|
13
|
+
|
|
6
14
|
## [0.3.20](https://github.com/constructive-io/jobs/compare/@constructive-io/job-pg@0.3.19...@constructive-io/job-pg@0.3.20) (2026-01-09)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @constructive-io/job-pg
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable no-console */
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
const pg_1 = require("pg");
|
|
5
4
|
const job_utils_1 = require("@constructive-io/job-utils");
|
|
5
|
+
const logger_1 = require("@pgpmjs/logger");
|
|
6
6
|
// k8s only does SIGINT
|
|
7
7
|
// other events are bad for babel-watch
|
|
8
8
|
const SYS_EVENTS = [
|
|
@@ -26,16 +26,17 @@ function once(fn, context) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
const pgPoolConfig = (0, job_utils_1.getJobPgConfig)();
|
|
29
|
+
const logger = (0, logger_1.createLogger)('job-pg');
|
|
29
30
|
const end = (pool) => {
|
|
30
31
|
try {
|
|
31
32
|
// Pool has internal state flags, but they are not part of the public type
|
|
32
33
|
const state = pool;
|
|
33
34
|
if (state.ended || state.ending) {
|
|
34
|
-
|
|
35
|
+
logger.error('DO NOT CLOSE pool, why are you trying to call end() when already ended?');
|
|
35
36
|
return;
|
|
36
37
|
}
|
|
37
38
|
void pool.end();
|
|
38
|
-
|
|
39
|
+
logger.info('successfully closed pool.');
|
|
39
40
|
}
|
|
40
41
|
catch (e) {
|
|
41
42
|
process.stderr.write(String(e));
|
|
@@ -50,7 +51,7 @@ class PoolManager {
|
|
|
50
51
|
this.callbacks = [];
|
|
51
52
|
this._closed = false;
|
|
52
53
|
const closeOnce = once(async () => {
|
|
53
|
-
|
|
54
|
+
logger.info('closing pg pool manager...');
|
|
54
55
|
await this.close();
|
|
55
56
|
}, this);
|
|
56
57
|
SYS_EVENTS.forEach((event) => {
|
|
@@ -67,7 +68,7 @@ class PoolManager {
|
|
|
67
68
|
if (this._closed)
|
|
68
69
|
return;
|
|
69
70
|
for (const [fn, context, args] of this.callbacks) {
|
|
70
|
-
|
|
71
|
+
logger.info('closing fn', fn.name);
|
|
71
72
|
await fn.apply(context, args);
|
|
72
73
|
}
|
|
73
74
|
end(this.pgPool);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/job-pg",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "job pg",
|
|
5
5
|
"author": "Constructive <developers@constructive.io>",
|
|
6
6
|
"homepage": "https://github.com/constructive-io/jobs/tree/master/packages/job-pg#readme",
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
"url": "https://github.com/constructive-io/jobs/issues"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@constructive-io/job-utils": "^0.
|
|
31
|
+
"@constructive-io/job-utils": "^0.6.0",
|
|
32
|
+
"@pgpmjs/logger": "^1.4.0",
|
|
32
33
|
"pg": "8.16.3"
|
|
33
34
|
},
|
|
34
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "481b3a50b4eec2da6b376c4cd1868065e1e28edb"
|
|
35
36
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
|
|
3
1
|
import { Pool, PoolConfig } from 'pg';
|
|
4
2
|
import { getJobPgConfig } from '@constructive-io/job-utils';
|
|
3
|
+
import { createLogger } from '@pgpmjs/logger';
|
|
5
4
|
|
|
6
5
|
// k8s only does SIGINT
|
|
7
6
|
// other events are bad for babel-watch
|
|
@@ -33,6 +32,8 @@ function once<T extends (...args: unknown[]) => unknown>(
|
|
|
33
32
|
|
|
34
33
|
const pgPoolConfig: PoolConfig = getJobPgConfig() as PoolConfig;
|
|
35
34
|
|
|
35
|
+
const logger = createLogger('job-pg');
|
|
36
|
+
|
|
36
37
|
const end = (pool: Pool): void => {
|
|
37
38
|
try {
|
|
38
39
|
// Pool has internal state flags, but they are not part of the public type
|
|
@@ -41,13 +42,13 @@ const end = (pool: Pool): void => {
|
|
|
41
42
|
ending?: boolean;
|
|
42
43
|
};
|
|
43
44
|
if (state.ended || state.ending) {
|
|
44
|
-
|
|
45
|
+
logger.error(
|
|
45
46
|
'DO NOT CLOSE pool, why are you trying to call end() when already ended?'
|
|
46
47
|
);
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
50
|
void pool.end();
|
|
50
|
-
|
|
51
|
+
logger.info('successfully closed pool.');
|
|
51
52
|
} catch (e) {
|
|
52
53
|
process.stderr.write(String(e));
|
|
53
54
|
}
|
|
@@ -68,7 +69,7 @@ class PoolManager {
|
|
|
68
69
|
this._closed = false;
|
|
69
70
|
|
|
70
71
|
const closeOnce = once(async () => {
|
|
71
|
-
|
|
72
|
+
logger.info('closing pg pool manager...');
|
|
72
73
|
await this.close();
|
|
73
74
|
}, this);
|
|
74
75
|
|
|
@@ -89,7 +90,7 @@ class PoolManager {
|
|
|
89
90
|
if (this._closed) return;
|
|
90
91
|
|
|
91
92
|
for (const [fn, context, args] of this.callbacks) {
|
|
92
|
-
|
|
93
|
+
logger.info('closing fn', fn.name);
|
|
93
94
|
await fn.apply(context, args);
|
|
94
95
|
}
|
|
95
96
|
|