@zintrust/queue-monitor 2.2.0 → 2.4.1
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/dist/build-manifest.json +129 -0
- package/dist/driver.js +74 -16
- package/package.json +9 -3
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zintrust/queue-monitor",
|
|
3
|
+
"version": "2.4.1",
|
|
4
|
+
"buildDate": "2026-05-31T11:37:21.551Z",
|
|
5
|
+
"buildEnvironment": {
|
|
6
|
+
"node": "v22.22.1",
|
|
7
|
+
"platform": "darwin",
|
|
8
|
+
"arch": "arm64"
|
|
9
|
+
},
|
|
10
|
+
"git": {
|
|
11
|
+
"commit": "e97b7b3d",
|
|
12
|
+
"branch": "release"
|
|
13
|
+
},
|
|
14
|
+
"package": {
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20.0.0"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": [
|
|
19
|
+
"bullmq",
|
|
20
|
+
"ioredis"
|
|
21
|
+
],
|
|
22
|
+
"peerDependencies": [
|
|
23
|
+
"@zintrust/core",
|
|
24
|
+
"@zintrust/redis-rpc"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"files": {
|
|
28
|
+
"BrandFavicon.d.ts": {
|
|
29
|
+
"size": 81,
|
|
30
|
+
"sha256": "0f477b645fb3df6d3f52ced87c3c0f7dc942e5f4c4710f24866eca3b2e411fb9"
|
|
31
|
+
},
|
|
32
|
+
"BrandFavicon.js": {
|
|
33
|
+
"size": 721,
|
|
34
|
+
"sha256": "33e57f6cec15b8dcb5886ca92644139d2e3ca1789aae1c3a4a066d75a273a6bb"
|
|
35
|
+
},
|
|
36
|
+
"QueueMonitoringService.d.ts": {
|
|
37
|
+
"size": 1698,
|
|
38
|
+
"sha256": "fcd19d80f3fc77b1318594bf45f13afed54febc4334d3aa6be975d3fe3bb73f2"
|
|
39
|
+
},
|
|
40
|
+
"QueueMonitoringService.js": {
|
|
41
|
+
"size": 8935,
|
|
42
|
+
"sha256": "c099e8922dd5642bce33a7db4b4a98641cab16e45a4ab76f989ef76a1178700e"
|
|
43
|
+
},
|
|
44
|
+
"build-manifest.json": {
|
|
45
|
+
"size": 3730,
|
|
46
|
+
"sha256": "f8860c23ea4936ad934d716cd6c818a959056530306a18d2dbe017cd25ef8044"
|
|
47
|
+
},
|
|
48
|
+
"connection.d.ts": {
|
|
49
|
+
"size": 287,
|
|
50
|
+
"sha256": "dcc6ea45e59b0a2e8844b27f466dff4849618c06b74aae62a99c8edd772d0db0"
|
|
51
|
+
},
|
|
52
|
+
"connection.js": {
|
|
53
|
+
"size": 178,
|
|
54
|
+
"sha256": "ff387351f5b8c7c14a7f2ef817fbbb065ad677faffcb47e5e8ddc4b064747e5b"
|
|
55
|
+
},
|
|
56
|
+
"dashboard-index.d.ts": {
|
|
57
|
+
"size": 183,
|
|
58
|
+
"sha256": "9d7c7fc63fe2919de0584d3f3d0ef74166d834af0a68caca2fe6fe64340652b9"
|
|
59
|
+
},
|
|
60
|
+
"dashboard-index.js": {
|
|
61
|
+
"size": 183,
|
|
62
|
+
"sha256": "9d7c7fc63fe2919de0584d3f3d0ef74166d834af0a68caca2fe6fe64340652b9"
|
|
63
|
+
},
|
|
64
|
+
"dashboard-ui.d.ts": {
|
|
65
|
+
"size": 219,
|
|
66
|
+
"sha256": "5140191207b5620500ac5e1edacefed65956a1ad88739695d545ea7d2b405243"
|
|
67
|
+
},
|
|
68
|
+
"dashboard-ui.js": {
|
|
69
|
+
"size": 53927,
|
|
70
|
+
"sha256": "71bab126f20aea1165ee3aa3c82e896ebd89b1f1a815ef2716cd884b846ab34f"
|
|
71
|
+
},
|
|
72
|
+
"driver-index.d.ts": {
|
|
73
|
+
"size": 287,
|
|
74
|
+
"sha256": "915a41bc57b3a5d826832bd4a899861ddbfd15a66ab04f7a599454a248222480"
|
|
75
|
+
},
|
|
76
|
+
"driver-index.js": {
|
|
77
|
+
"size": 184,
|
|
78
|
+
"sha256": "fb91df973acd13a88cca443e50ecdd34944c66e1a1d48333f63099079a00f3c9"
|
|
79
|
+
},
|
|
80
|
+
"driver.d.ts": {
|
|
81
|
+
"size": 1236,
|
|
82
|
+
"sha256": "91f705031e1abd9049e93c49a2cdd00552f41c4693f2f79fb3fbeeb6c67ac85a"
|
|
83
|
+
},
|
|
84
|
+
"driver.js": {
|
|
85
|
+
"size": 9763,
|
|
86
|
+
"sha256": "3f12f43c1b67091588dfcbbed70d39d046f88e4699db4c1cf4ee6f442b5b87dd"
|
|
87
|
+
},
|
|
88
|
+
"index.d.ts": {
|
|
89
|
+
"size": 2344,
|
|
90
|
+
"sha256": "370b578ca6412fbdbb2f6966c0899a4c9d6d1ab08defe48a9004564124b1f45e"
|
|
91
|
+
},
|
|
92
|
+
"index.js": {
|
|
93
|
+
"size": 16079,
|
|
94
|
+
"sha256": "4e6d97afc428b9f3438be08711c79ea66711038a8d93c28e7074754a8b35ba4d"
|
|
95
|
+
},
|
|
96
|
+
"metrics-index.d.ts": {
|
|
97
|
+
"size": 239,
|
|
98
|
+
"sha256": "b68d7ca4d15e2380bc7a57e8ff6b00eb19a9f49417f7df88ff20b93cd2aeb00d"
|
|
99
|
+
},
|
|
100
|
+
"metrics-index.js": {
|
|
101
|
+
"size": 171,
|
|
102
|
+
"sha256": "53e858995605858b819f2c48c701e3b8f7d028ec51c1b4814c46284c7fb3989e"
|
|
103
|
+
},
|
|
104
|
+
"metrics.d.ts": {
|
|
105
|
+
"size": 913,
|
|
106
|
+
"sha256": "c68b254af229871ae8d4ad5c2aca00108c07465e0abb336a68a9c2023d2d5776"
|
|
107
|
+
},
|
|
108
|
+
"metrics.js": {
|
|
109
|
+
"size": 3526,
|
|
110
|
+
"sha256": "bec6d546c15a4040eaf637feb974799db85cbdf34a7cb077f7b407da31181f11"
|
|
111
|
+
},
|
|
112
|
+
"runtime-index.d.ts": {
|
|
113
|
+
"size": 2230,
|
|
114
|
+
"sha256": "b4608f964f6c5cdb5469eb320683fee827734adcf1d03ea931766405451f35df"
|
|
115
|
+
},
|
|
116
|
+
"runtime-index.js": {
|
|
117
|
+
"size": 8924,
|
|
118
|
+
"sha256": "494757d540fe57507ac59ef2935ad683cb14fa57dbe188ffe3e6dd9fe3cb1ea9"
|
|
119
|
+
},
|
|
120
|
+
"worker.d.ts": {
|
|
121
|
+
"size": 338,
|
|
122
|
+
"sha256": "6bb39529c68675846d1877b34ccb2fa2bbe9bc56a223388add24e239f24ddfc3"
|
|
123
|
+
},
|
|
124
|
+
"worker.js": {
|
|
125
|
+
"size": 1239,
|
|
126
|
+
"sha256": "46f116eb169fca1dc6dfd48d299001635c48a2da8d6e10115a98fcd33187b53e"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
package/dist/driver.js
CHANGED
|
@@ -4,6 +4,75 @@ import { Logger } from '@zintrust/core/logger';
|
|
|
4
4
|
import { getBullMQSafeQueueName } from '@zintrust/core/redis';
|
|
5
5
|
import { Queue } from 'bullmq';
|
|
6
6
|
import { createRedisConnection } from './connection.js';
|
|
7
|
+
const REDIS_RPC_PACKAGE = '@zintrust/redis-rpc';
|
|
8
|
+
const shouldUseRedisRpcMonitorDriver = () => Env.USE_REDIS_PROXY === true && Env.get('REDIS_RPC_URL', '').trim() !== '';
|
|
9
|
+
const resolveRpcBaseUrl = () => {
|
|
10
|
+
const configured = Env.get('REDIS_RPC_URL', '').trim();
|
|
11
|
+
if (configured.length > 0)
|
|
12
|
+
return configured;
|
|
13
|
+
const host = Env.get('REDIS_RPC_HOST', '127.0.0.1').trim() || '127.0.0.1';
|
|
14
|
+
const port = Env.getInt('REDIS_RPC_PORT', 8794);
|
|
15
|
+
return `http://${host}:${port}`;
|
|
16
|
+
};
|
|
17
|
+
const createRpcClient = async () => {
|
|
18
|
+
try {
|
|
19
|
+
const mod = (await import(REDIS_RPC_PACKAGE));
|
|
20
|
+
return mod.createRedisRpcClient({
|
|
21
|
+
baseUrl: resolveRpcBaseUrl(),
|
|
22
|
+
secret: Env.get('REDIS_RPC_SECRET', Env.get('REDIS_PROXY_SECRET', Env.APP_KEY)),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
throw ErrorFactory.createConfigError('@zintrust/redis-rpc is required when USE_REDIS_PROXY=true and REDIS_RPC_URL is configured', error);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const createRedisRpcDriver = () => {
|
|
30
|
+
const enqueue = async (name, payload, options) => {
|
|
31
|
+
const client = await createRpcClient();
|
|
32
|
+
const result = await client.queue('add', {
|
|
33
|
+
target: name,
|
|
34
|
+
args: ['default', payload, options ?? {}],
|
|
35
|
+
});
|
|
36
|
+
if (result.id === undefined || result.id === null) {
|
|
37
|
+
throw ErrorFactory.createTryCatchError(`Queue job id missing for ${name}`);
|
|
38
|
+
}
|
|
39
|
+
return String(result.id);
|
|
40
|
+
};
|
|
41
|
+
return Object.freeze({
|
|
42
|
+
enqueue,
|
|
43
|
+
async getJob(queueName, jobId) {
|
|
44
|
+
const client = await createRpcClient();
|
|
45
|
+
return (await client.queue('getJob', { target: queueName, args: [jobId] }));
|
|
46
|
+
},
|
|
47
|
+
async getJobCounts(queueName) {
|
|
48
|
+
const client = await createRpcClient();
|
|
49
|
+
return client.queue('getJobCounts', { target: queueName });
|
|
50
|
+
},
|
|
51
|
+
async getJobCountsMany(queueNames) {
|
|
52
|
+
const client = await createRpcClient();
|
|
53
|
+
const snapshot = await client.monitor('getSnapshot', { args: [queueNames] });
|
|
54
|
+
return snapshot.queues ?? [];
|
|
55
|
+
},
|
|
56
|
+
async getRecentJobs(queueName, limit = 100) {
|
|
57
|
+
const client = await createRpcClient();
|
|
58
|
+
return (await client.monitor('getRecentJobsForQueue', {
|
|
59
|
+
args: [queueName, limit],
|
|
60
|
+
}));
|
|
61
|
+
},
|
|
62
|
+
async retryJob(queueName, jobId) {
|
|
63
|
+
const client = await createRpcClient();
|
|
64
|
+
return client.queue('retryJob', { target: queueName, args: [jobId] });
|
|
65
|
+
},
|
|
66
|
+
async getQueues() {
|
|
67
|
+
const client = await createRpcClient();
|
|
68
|
+
const snapshot = await client.monitor('getSnapshot');
|
|
69
|
+
return (snapshot.queues ?? []).map((queue) => queue.name);
|
|
70
|
+
},
|
|
71
|
+
async close() {
|
|
72
|
+
await Promise.resolve();
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
};
|
|
7
76
|
async function enrichJobsWithState(jobs) {
|
|
8
77
|
await Promise.all(jobs.map(async (job) => {
|
|
9
78
|
try {
|
|
@@ -46,23 +115,12 @@ async function discoverQueuesFromRedis(redis, inMemoryQueues) {
|
|
|
46
115
|
}
|
|
47
116
|
// eslint-disable-next-line max-lines-per-function
|
|
48
117
|
export const createBullMQDriver = (config) => {
|
|
118
|
+
if (shouldUseRedisRpcMonitorDriver())
|
|
119
|
+
return createRedisRpcDriver();
|
|
49
120
|
const queues = new Map();
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (requireDirectForScripts) {
|
|
54
|
-
redis = {
|
|
55
|
-
host: config.host,
|
|
56
|
-
port: config.port,
|
|
57
|
-
db: config.db,
|
|
58
|
-
password: config.password,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
redis = createRedisConnection(config, 3, {
|
|
63
|
-
subsystem: 'queue-monitor',
|
|
64
|
-
});
|
|
65
|
-
}
|
|
121
|
+
const redis = createRedisConnection(config, 3, {
|
|
122
|
+
subsystem: 'queue-monitor',
|
|
123
|
+
});
|
|
66
124
|
const getQueue = (name) => {
|
|
67
125
|
if (!queues.has(name)) {
|
|
68
126
|
const prefix = getBullMQSafeQueueName();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/queue-monitor",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "Queue monitoring package for ZinTrust with BullMQ and Redis.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -36,7 +36,13 @@
|
|
|
36
36
|
"node": ">=20.0.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@zintrust/core": "*"
|
|
39
|
+
"@zintrust/core": "*",
|
|
40
|
+
"@zintrust/redis-rpc": "*"
|
|
41
|
+
},
|
|
42
|
+
"peerDependenciesMeta": {
|
|
43
|
+
"@zintrust/redis-rpc": {
|
|
44
|
+
"optional": true
|
|
45
|
+
}
|
|
40
46
|
},
|
|
41
47
|
"publishConfig": {
|
|
42
48
|
"access": "public"
|
|
@@ -56,4 +62,4 @@
|
|
|
56
62
|
"bullmq": "^5.77.6",
|
|
57
63
|
"ioredis": "^5.11.0"
|
|
58
64
|
}
|
|
59
|
-
}
|
|
65
|
+
}
|