@zintrust/queue-monitor 0.1.27
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/README.md +38 -0
- package/dist/api/workerClient.d.ts +20 -0
- package/dist/api/workerClient.js +45 -0
- package/dist/build-manifest.json +120 -0
- package/dist/config/queueMonitor.d.ts +18 -0
- package/dist/config/queueMonitor.js +21 -0
- package/dist/config/workerConfig.d.ts +3 -0
- package/dist/config/workerConfig.js +19 -0
- package/dist/connection.d.ts +2 -0
- package/dist/connection.js +1 -0
- package/dist/dashboard-ui.d.ts +5 -0
- package/dist/dashboard-ui.js +657 -0
- package/dist/driver.d.ts +14 -0
- package/dist/driver.js +115 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.js +275 -0
- package/dist/metrics.d.ts +24 -0
- package/dist/metrics.js +77 -0
- package/dist/routes/workers.d.ts +10 -0
- package/dist/routes/workers.js +20 -0
- package/dist/worker.d.ts +7 -0
- package/dist/worker.js +25 -0
- package/dist/workers-ui.d.ts +7 -0
- package/dist/workers-ui.js +655 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @zintrust/queue-monitor
|
|
2
|
+
|
|
3
|
+
Queue monitoring scaffolding for ZinTrust.
|
|
4
|
+
|
|
5
|
+
- Docs: https://zintrust.com/queue
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i @zintrust/queue-monitor
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { QueueMonitor, type IRouter } from '@zintrust/core';
|
|
17
|
+
import { QueueMonitor as QueueMonitorPlugin } from '@zintrust/queue-monitor';
|
|
18
|
+
|
|
19
|
+
const monitor = QueueMonitorPlugin.create({
|
|
20
|
+
basePath: '/queue-monitor',
|
|
21
|
+
middleware: ['auth'],
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export function registerRoutes(router: IRouter): void {
|
|
25
|
+
monitor.registerRoutes(router);
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## When to use
|
|
30
|
+
|
|
31
|
+
- ✅ Use `@zintrust/queue-monitor` if you need full queue management (enqueue + process + monitor + retry)
|
|
32
|
+
- ✅✅ Use `@zintrust/queue-redis` if you only need to **enqueue jobs** and another service will process them
|
|
33
|
+
|
|
34
|
+
**Note:** The monitor package can do everything queue-redis does, plus much more. So if you install `@zintrust/queue-monitor`, there's no need for `@zintrust/queue-redis`.
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
This package and its dependencies are MIT licensed, permitting free commercial use.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type WorkerApiResponse<T> = {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
error?: string;
|
|
4
|
+
} & T;
|
|
5
|
+
export declare const WorkerClient: Readonly<{
|
|
6
|
+
listWorkers(): Promise<string[]>;
|
|
7
|
+
getWorker(name: string): Promise<unknown>;
|
|
8
|
+
getStatus(name: string): Promise<unknown>;
|
|
9
|
+
getHealth(name: string): Promise<unknown>;
|
|
10
|
+
startWorker(name: string): Promise<WorkerApiResponse<{
|
|
11
|
+
message?: string;
|
|
12
|
+
}>>;
|
|
13
|
+
stopWorker(name: string): Promise<WorkerApiResponse<{
|
|
14
|
+
message?: string;
|
|
15
|
+
}>>;
|
|
16
|
+
restartWorker(name: string): Promise<WorkerApiResponse<{
|
|
17
|
+
message?: string;
|
|
18
|
+
}>>;
|
|
19
|
+
}>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ErrorFactory, Logger } from '@zintrust/core';
|
|
2
|
+
import { WorkerConfig } from '../config/workerConfig';
|
|
3
|
+
const requestJson = async (path, options = {}) => {
|
|
4
|
+
const baseUrl = WorkerConfig.getWorkerBaseUrl();
|
|
5
|
+
const url = `${baseUrl}${path}`;
|
|
6
|
+
const response = await fetch(url, {
|
|
7
|
+
...options,
|
|
8
|
+
headers: {
|
|
9
|
+
'Content-Type': 'application/json',
|
|
10
|
+
...options.headers,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
if (!response.ok) {
|
|
14
|
+
Logger.error('Worker API request failed', { url, status: response.status });
|
|
15
|
+
throw ErrorFactory.createWorkerError(`Worker API request failed (${response.status})`);
|
|
16
|
+
}
|
|
17
|
+
return (await response.json());
|
|
18
|
+
};
|
|
19
|
+
export const WorkerClient = Object.freeze({
|
|
20
|
+
async listWorkers() {
|
|
21
|
+
const response = await requestJson('/api/workers');
|
|
22
|
+
return response.workers ?? [];
|
|
23
|
+
},
|
|
24
|
+
async getWorker(name) {
|
|
25
|
+
const response = await requestJson(`/api/workers/${name}`);
|
|
26
|
+
return response.worker;
|
|
27
|
+
},
|
|
28
|
+
async getStatus(name) {
|
|
29
|
+
const response = await requestJson(`/api/workers/${name}/status`);
|
|
30
|
+
return response.status;
|
|
31
|
+
},
|
|
32
|
+
async getHealth(name) {
|
|
33
|
+
const response = await requestJson(`/api/workers/${name}/health`);
|
|
34
|
+
return response.health;
|
|
35
|
+
},
|
|
36
|
+
async startWorker(name) {
|
|
37
|
+
return requestJson(`/api/workers/${name}/start`, { method: 'POST' });
|
|
38
|
+
},
|
|
39
|
+
async stopWorker(name) {
|
|
40
|
+
return requestJson(`/api/workers/${name}/stop`, { method: 'POST' });
|
|
41
|
+
},
|
|
42
|
+
async restartWorker(name) {
|
|
43
|
+
return requestJson(`/api/workers/${name}/restart`, { method: 'POST' });
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zintrust/queue-monitor",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"buildDate": "2026-01-28T12:31:01.364Z",
|
|
5
|
+
"buildEnvironment": {
|
|
6
|
+
"node": "v22.20.0",
|
|
7
|
+
"platform": "darwin",
|
|
8
|
+
"arch": "arm64"
|
|
9
|
+
},
|
|
10
|
+
"git": {
|
|
11
|
+
"commit": "2d1585bf",
|
|
12
|
+
"branch": "dev"
|
|
13
|
+
},
|
|
14
|
+
"package": {
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20.0.0"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": [
|
|
19
|
+
"bullmq",
|
|
20
|
+
"ioredis"
|
|
21
|
+
],
|
|
22
|
+
"peerDependencies": [
|
|
23
|
+
"@zintrust/core"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"files": {
|
|
27
|
+
"api/workerClient.d.ts": {
|
|
28
|
+
"size": 597,
|
|
29
|
+
"sha256": "1d712bfa9127aa2df4f1fbd0efbb6d84069e1888ed73aca5542a41eee865d4bb"
|
|
30
|
+
},
|
|
31
|
+
"api/workerClient.js": {
|
|
32
|
+
"size": 1626,
|
|
33
|
+
"sha256": "7a41c5e560fe5e2248e94dadf06a751c8f0c8dd04a8ef699410a668782c9c3f0"
|
|
34
|
+
},
|
|
35
|
+
"build-manifest.json": {
|
|
36
|
+
"size": 3572,
|
|
37
|
+
"sha256": "155b1749c79e6afe4075a44bf59aaa8e7997c68a4aef412dbcd23a2bdf2d42c8"
|
|
38
|
+
},
|
|
39
|
+
"config/queueMonitor.d.ts": {
|
|
40
|
+
"size": 407,
|
|
41
|
+
"sha256": "4541f47e64c8ede1bfd8fc0cb7edb76c4e885311b28b1f51c9be7639e5d87eca"
|
|
42
|
+
},
|
|
43
|
+
"config/queueMonitor.js": {
|
|
44
|
+
"size": 689,
|
|
45
|
+
"sha256": "0b95e6b65d4b6ffdd69788cdfd19e0e76400a39ad69dce018d8827a3b298e419"
|
|
46
|
+
},
|
|
47
|
+
"config/workerConfig.d.ts": {
|
|
48
|
+
"size": 86,
|
|
49
|
+
"sha256": "b669205d50c8844455a2d9b34a54f48a71118eb6ac99bad5372683ab666f5a22"
|
|
50
|
+
},
|
|
51
|
+
"config/workerConfig.js": {
|
|
52
|
+
"size": 628,
|
|
53
|
+
"sha256": "ca1c6dbaa751893f0e6b7c8a7fd41a80f7d5e8fc9aaaa4877ca12821bb25f56f"
|
|
54
|
+
},
|
|
55
|
+
"connection.d.ts": {
|
|
56
|
+
"size": 107,
|
|
57
|
+
"sha256": "653b300a25df08a2380bdc74ea38342190771386cb1847dc92802e6eef88a88f"
|
|
58
|
+
},
|
|
59
|
+
"connection.js": {
|
|
60
|
+
"size": 56,
|
|
61
|
+
"sha256": "1d4e9b5f2a03e0a3885d578276eb5c6a05c50ce4a2d84b241e68fe6ace76e7dd"
|
|
62
|
+
},
|
|
63
|
+
"dashboard-ui.d.ts": {
|
|
64
|
+
"size": 175,
|
|
65
|
+
"sha256": "b07a5a2d27f2839c693bd76a0b3060b57ec7b62e3b97b5c253bce747680f50eb"
|
|
66
|
+
},
|
|
67
|
+
"dashboard-ui.js": {
|
|
68
|
+
"size": 28875,
|
|
69
|
+
"sha256": "d7e1239f91755043102a82dbc08b092a67f23625116d5e6573cb4d1124af1af5"
|
|
70
|
+
},
|
|
71
|
+
"driver.d.ts": {
|
|
72
|
+
"size": 712,
|
|
73
|
+
"sha256": "bfb0c3c914519c0bc988ab4d5be2275da165fc4ed977c72e73f90e6dcf4b1667"
|
|
74
|
+
},
|
|
75
|
+
"driver.js": {
|
|
76
|
+
"size": 3957,
|
|
77
|
+
"sha256": "7894338fb4e1f1a5e785f50da96f165bcb32ec1155883a07068c29c0c4c09fd9"
|
|
78
|
+
},
|
|
79
|
+
"index.d.ts": {
|
|
80
|
+
"size": 1932,
|
|
81
|
+
"sha256": "e9f05b27068667aaaf31d4ab55f1ed871a53a4c0692cc0833ca288f18f662d70"
|
|
82
|
+
},
|
|
83
|
+
"index.js": {
|
|
84
|
+
"size": 10761,
|
|
85
|
+
"sha256": "db68589bff2508da316758204495a075ffc2555e391d348da2609687cca55b66"
|
|
86
|
+
},
|
|
87
|
+
"metrics.d.ts": {
|
|
88
|
+
"size": 795,
|
|
89
|
+
"sha256": "73e93750749cc70a972794a956bcb2a8127289127287893b8f1850d80e20df7d"
|
|
90
|
+
},
|
|
91
|
+
"metrics.js": {
|
|
92
|
+
"size": 2920,
|
|
93
|
+
"sha256": "b552cb906fcdec5aa2408b17815157f1aa19d409278fc68d091a77cec63e2950"
|
|
94
|
+
},
|
|
95
|
+
"routes/workers.d.ts": {
|
|
96
|
+
"size": 477,
|
|
97
|
+
"sha256": "cfcc3527c47d1a796a3ced2d4777b339dd767f7feb3ecc66c5ce0a91d8ff1bc8"
|
|
98
|
+
},
|
|
99
|
+
"routes/workers.js": {
|
|
100
|
+
"size": 895,
|
|
101
|
+
"sha256": "a2e73b5879c5f572005b0b2b2aae6e19cefaefee91c07b3a44f95703b86c4cb3"
|
|
102
|
+
},
|
|
103
|
+
"worker.d.ts": {
|
|
104
|
+
"size": 332,
|
|
105
|
+
"sha256": "97cddbc991c6e6724950090cd92f06671932ab848c16dd94a030d9fba3fbae26"
|
|
106
|
+
},
|
|
107
|
+
"worker.js": {
|
|
108
|
+
"size": 823,
|
|
109
|
+
"sha256": "fb9c348f6599d402ab656885a7c98410b396e29942e2d8e8fcbdbcf1315f6e40"
|
|
110
|
+
},
|
|
111
|
+
"workers-ui.d.ts": {
|
|
112
|
+
"size": 214,
|
|
113
|
+
"sha256": "4f5fd3bbd077d0dee2cc6c73d2c736fc52119b0d3a5f4a1878a4f3d3d3edf299"
|
|
114
|
+
},
|
|
115
|
+
"workers-ui.js": {
|
|
116
|
+
"size": 24928,
|
|
117
|
+
"sha256": "ba2c5cbf890fe875cc5336c76bd29b146089bc8ba3a70de4a2c383f395f9be73"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queue Monitor Configuration (default override)
|
|
3
|
+
*
|
|
4
|
+
* Keep this file declarative:
|
|
5
|
+
* - Core owns env parsing/default logic.
|
|
6
|
+
* - Projects can override config by editing values below.
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
basePath: string;
|
|
11
|
+
middleware: string[];
|
|
12
|
+
redis: {
|
|
13
|
+
host: string;
|
|
14
|
+
port: number;
|
|
15
|
+
password: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Env } from '@zintrust/core';
|
|
2
|
+
/**
|
|
3
|
+
* Queue Monitor Configuration (default override)
|
|
4
|
+
*
|
|
5
|
+
* Keep this file declarative:
|
|
6
|
+
* - Core owns env parsing/default logic.
|
|
7
|
+
* - Projects can override config by editing values below.
|
|
8
|
+
*/
|
|
9
|
+
export default {
|
|
10
|
+
enabled: Env.getBool('QUEUE_MONITOR_ENABLED', true),
|
|
11
|
+
basePath: Env.get('QUEUE_MONITOR_BASE_PATH', '/queue-monitor'),
|
|
12
|
+
middleware: Env.get('QUEUE_MONITOR_MIDDLEWARE', 'auth')
|
|
13
|
+
.split(',')
|
|
14
|
+
.map((m) => m.trim())
|
|
15
|
+
.filter((m) => m.length > 0),
|
|
16
|
+
redis: {
|
|
17
|
+
host: Env.get('REDIS_HOST', 'localhost'),
|
|
18
|
+
port: Env.getInt('REDIS_PORT', 6379),
|
|
19
|
+
password: Env.get('REDIS_PASSWORD', ''),
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Env } from '@zintrust/core';
|
|
2
|
+
const normalizeBaseUrl = (value) => {
|
|
3
|
+
let end = value.length;
|
|
4
|
+
while (end > 0 && value.charAt(end - 1) === '/') {
|
|
5
|
+
end--;
|
|
6
|
+
}
|
|
7
|
+
return value.slice(0, end);
|
|
8
|
+
};
|
|
9
|
+
const withHttpScheme = (value) => value.startsWith('http://') || value.startsWith('https://') ? value : `http://${value}`;
|
|
10
|
+
const resolveWorkerApiUrl = () => {
|
|
11
|
+
const workerApiUrl = Env.get('WORKER_API_URL');
|
|
12
|
+
if (workerApiUrl) {
|
|
13
|
+
return normalizeBaseUrl(withHttpScheme(workerApiUrl));
|
|
14
|
+
}
|
|
15
|
+
return '';
|
|
16
|
+
};
|
|
17
|
+
export const WorkerConfig = Object.freeze({
|
|
18
|
+
getWorkerBaseUrl: resolveWorkerApiUrl,
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createRedisConnection } from '@zintrust/core';
|