graphile-cache 4.16.4 → 4.16.5
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/create-instance.d.ts +1 -0
- package/create-instance.js +12 -6
- package/esm/create-instance.js +12 -6
- package/package.json +3 -3
package/create-instance.d.ts
CHANGED
package/create-instance.js
CHANGED
|
@@ -33,7 +33,7 @@ const log = new logger_1.Logger('graphile-cache:create');
|
|
|
33
33
|
* so the estimate errs towards evicting early.
|
|
34
34
|
*/
|
|
35
35
|
const createGraphileInstance = async (opts) => {
|
|
36
|
-
const { preset, cacheKey, enableRealtime = false } = opts;
|
|
36
|
+
const { preset, cacheKey, enableRealtime = false, realtimeSchema } = opts;
|
|
37
37
|
const heapBefore = process.memoryUsage().heapUsed;
|
|
38
38
|
const pgl = (0, postgraphile_1.postgraphile)(preset);
|
|
39
39
|
const serv = pgl.createServ(v4_1.grafserv);
|
|
@@ -52,7 +52,7 @@ const createGraphileInstance = async (opts) => {
|
|
|
52
52
|
createdAt: Date.now(),
|
|
53
53
|
heapBytes,
|
|
54
54
|
};
|
|
55
|
-
if (enableRealtime) {
|
|
55
|
+
if (enableRealtime && realtimeSchema) {
|
|
56
56
|
try {
|
|
57
57
|
// Extract PgSubscriber and pool from the resolved preset's pgServices.
|
|
58
58
|
// The pool is the same instance managed by pg-cache (via getPgPool)
|
|
@@ -62,17 +62,17 @@ const createGraphileInstance = async (opts) => {
|
|
|
62
62
|
const pgSubscriber = pgService?.pgSubscriber ?? null;
|
|
63
63
|
const pool = pgService?.adaptorSettings?.pool ?? null;
|
|
64
64
|
if (!pgSubscriber) {
|
|
65
|
-
|
|
65
|
+
throw new Error(`PostGraphile[${cacheKey}] has no pgSubscriber for realtime`);
|
|
66
66
|
}
|
|
67
67
|
else if (!pool) {
|
|
68
|
-
|
|
68
|
+
throw new Error(`PostGraphile[${cacheKey}] has no pool in pgService for realtime`);
|
|
69
69
|
}
|
|
70
70
|
else {
|
|
71
71
|
const manager = new graphile_realtime_subscriptions_1.RealtimeManager({
|
|
72
72
|
pgSubscriber,
|
|
73
73
|
pool,
|
|
74
74
|
nodeId: `graphile-cache:${cacheKey}`,
|
|
75
|
-
schema:
|
|
75
|
+
schema: realtimeSchema,
|
|
76
76
|
});
|
|
77
77
|
await manager.start();
|
|
78
78
|
entry.realtimeManager = manager;
|
|
@@ -80,7 +80,13 @@ const createGraphileInstance = async (opts) => {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
catch (err) {
|
|
83
|
-
|
|
83
|
+
try {
|
|
84
|
+
await pgl.release();
|
|
85
|
+
}
|
|
86
|
+
catch (cleanupError) {
|
|
87
|
+
throw new AggregateError([err, cleanupError], `Realtime startup and cleanup failed for PostGraphile[${cacheKey}]`);
|
|
88
|
+
}
|
|
89
|
+
throw err;
|
|
84
90
|
}
|
|
85
91
|
}
|
|
86
92
|
return entry;
|
package/esm/create-instance.js
CHANGED
|
@@ -27,7 +27,7 @@ const log = new Logger('graphile-cache:create');
|
|
|
27
27
|
* so the estimate errs towards evicting early.
|
|
28
28
|
*/
|
|
29
29
|
export const createGraphileInstance = async (opts) => {
|
|
30
|
-
const { preset, cacheKey, enableRealtime = false } = opts;
|
|
30
|
+
const { preset, cacheKey, enableRealtime = false, realtimeSchema } = opts;
|
|
31
31
|
const heapBefore = process.memoryUsage().heapUsed;
|
|
32
32
|
const pgl = postgraphile(preset);
|
|
33
33
|
const serv = pgl.createServ(grafserv);
|
|
@@ -46,7 +46,7 @@ export const createGraphileInstance = async (opts) => {
|
|
|
46
46
|
createdAt: Date.now(),
|
|
47
47
|
heapBytes,
|
|
48
48
|
};
|
|
49
|
-
if (enableRealtime) {
|
|
49
|
+
if (enableRealtime && realtimeSchema) {
|
|
50
50
|
try {
|
|
51
51
|
// Extract PgSubscriber and pool from the resolved preset's pgServices.
|
|
52
52
|
// The pool is the same instance managed by pg-cache (via getPgPool)
|
|
@@ -56,17 +56,17 @@ export const createGraphileInstance = async (opts) => {
|
|
|
56
56
|
const pgSubscriber = pgService?.pgSubscriber ?? null;
|
|
57
57
|
const pool = pgService?.adaptorSettings?.pool ?? null;
|
|
58
58
|
if (!pgSubscriber) {
|
|
59
|
-
|
|
59
|
+
throw new Error(`PostGraphile[${cacheKey}] has no pgSubscriber for realtime`);
|
|
60
60
|
}
|
|
61
61
|
else if (!pool) {
|
|
62
|
-
|
|
62
|
+
throw new Error(`PostGraphile[${cacheKey}] has no pool in pgService for realtime`);
|
|
63
63
|
}
|
|
64
64
|
else {
|
|
65
65
|
const manager = new RealtimeManager({
|
|
66
66
|
pgSubscriber,
|
|
67
67
|
pool,
|
|
68
68
|
nodeId: `graphile-cache:${cacheKey}`,
|
|
69
|
-
schema:
|
|
69
|
+
schema: realtimeSchema,
|
|
70
70
|
});
|
|
71
71
|
await manager.start();
|
|
72
72
|
entry.realtimeManager = manager;
|
|
@@ -74,7 +74,13 @@ export const createGraphileInstance = async (opts) => {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
catch (err) {
|
|
77
|
-
|
|
77
|
+
try {
|
|
78
|
+
await pgl.release();
|
|
79
|
+
}
|
|
80
|
+
catch (cleanupError) {
|
|
81
|
+
throw new AggregateError([err, cleanupError], `Realtime startup and cleanup failed for PostGraphile[${cacheKey}]`);
|
|
82
|
+
}
|
|
83
|
+
throw err;
|
|
78
84
|
}
|
|
79
85
|
}
|
|
80
86
|
return entry;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphile-cache",
|
|
3
|
-
"version": "4.16.
|
|
3
|
+
"version": "4.16.5",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "PostGraphile v5 LRU cache with automatic pool cleanup integration",
|
|
6
6
|
"main": "index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@pgpmjs/logger": "^2.27.0",
|
|
34
34
|
"express": "^5.2.1",
|
|
35
35
|
"grafserv": "1.0.1",
|
|
36
|
-
"graphile-realtime-subscriptions": "^1.13.
|
|
36
|
+
"graphile-realtime-subscriptions": "^1.13.1",
|
|
37
37
|
"lru-cache": "^11.2.7",
|
|
38
38
|
"pg-cache": "^3.30.3",
|
|
39
39
|
"postgraphile": "5.1.4"
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"constructive",
|
|
54
54
|
"v5"
|
|
55
55
|
],
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "e9d6aa9a9cf617880c3f94336e57e71cb1385947"
|
|
57
57
|
}
|