@zintrust/zedgi 3.0.2 → 3.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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Logger } from '@zintrust/core/logger';
|
|
2
|
+
import { isWaitingJobState } from '@zintrust/queue-monitor/driver';
|
|
2
3
|
import { ZedgiRuntime } from './ZedgiRuntime.js';
|
|
3
4
|
const createZedgiEnqueue = (getQueueConfig) => async (name, payload, options) => {
|
|
4
5
|
try {
|
|
@@ -67,6 +68,35 @@ const createZedgiRetryJob = (getQueueConfig) => async (queueName, jobId) => {
|
|
|
67
68
|
throw error;
|
|
68
69
|
}
|
|
69
70
|
};
|
|
71
|
+
const waitingStateRejection = (state) => ({
|
|
72
|
+
ok: false,
|
|
73
|
+
status: 'not_waiting',
|
|
74
|
+
reason: `Job is ${typeof state === 'string' && state.trim() !== '' ? state : 'unknown'}, not waiting`,
|
|
75
|
+
});
|
|
76
|
+
const createZedgiDeleteWaitingJob = (getQueueConfig) => async (queueName, jobId) => {
|
|
77
|
+
const queue = ZedgiRuntime.queue(queueName, getQueueConfig());
|
|
78
|
+
const job = (await queue.getJob(jobId));
|
|
79
|
+
if (!job)
|
|
80
|
+
return { ok: false, status: 'missing' };
|
|
81
|
+
if (!isWaitingJobState(job.state))
|
|
82
|
+
return waitingStateRejection(job.state);
|
|
83
|
+
await queue.removeJob(jobId);
|
|
84
|
+
return { ok: true, status: 'removed' };
|
|
85
|
+
};
|
|
86
|
+
const createZedgiRequeueWaitingJob = (getQueueConfig) => async (queueName, jobId) => {
|
|
87
|
+
const queue = ZedgiRuntime.queue(queueName, getQueueConfig());
|
|
88
|
+
const job = (await queue.getJob(jobId));
|
|
89
|
+
if (!job)
|
|
90
|
+
return { ok: false, status: 'missing' };
|
|
91
|
+
if (!isWaitingJobState(job.state))
|
|
92
|
+
return waitingStateRejection(job.state);
|
|
93
|
+
const opts = { ...job.opts };
|
|
94
|
+
delete opts['jobId'];
|
|
95
|
+
await queue.removeJob(jobId);
|
|
96
|
+
const added = await queue.add(job.name ?? `${queueName}-job`, job.data ?? {}, opts);
|
|
97
|
+
const newJobId = added?.id !== undefined && added.id !== null ? String(added.id) : undefined;
|
|
98
|
+
return { ok: true, status: 'requeued', newJobId };
|
|
99
|
+
};
|
|
70
100
|
const createZedgiRecoverActiveJob = (getQueueConfig) => async (queueName, jobId) => {
|
|
71
101
|
try {
|
|
72
102
|
const queue = ZedgiRuntime.queue(queueName, getQueueConfig());
|
|
@@ -121,6 +151,8 @@ const createZedgiMonitorDriver = (config) => {
|
|
|
121
151
|
getRecentJobs: createZedgiGetRecentJobs(getQueueConfig),
|
|
122
152
|
retryJob: createZedgiRetryJob(getQueueConfig),
|
|
123
153
|
recoverActiveJob: createZedgiRecoverActiveJob(getQueueConfig),
|
|
154
|
+
deleteWaitingJob: createZedgiDeleteWaitingJob(getQueueConfig),
|
|
155
|
+
requeueWaitingJob: createZedgiRequeueWaitingJob(getQueueConfig),
|
|
124
156
|
getQueues: createZedgiGetQueues(getQueueConfig),
|
|
125
157
|
close: createZedgiClose(),
|
|
126
158
|
};
|
package/dist/ZedgiQueueDriver.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Env } from '@zintrust/core/config';
|
|
2
|
+
import { ErrorFactory } from '@zintrust/core/errors';
|
|
2
3
|
import { generateUuid } from '@zintrust/core/utils';
|
|
3
4
|
import { ZedgiRuntime } from './ZedgiRuntime.js';
|
|
4
5
|
const resolveRequestedJobId = (payload) => {
|
|
@@ -40,7 +41,7 @@ const callQueueRpc = async (config, queueName, method, payload) => {
|
|
|
40
41
|
...payload,
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
|
-
throw
|
|
44
|
+
throw ErrorFactory.createConfigError('Zedgi Redis RPC hook support is required for queue consumption');
|
|
44
45
|
};
|
|
45
46
|
const createDriver = (config) => {
|
|
46
47
|
const queue = (name) => ZedgiRuntime.queue(name, config);
|
package/dist/ZedgiRuntime.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export declare const ZedgiRuntime: Readonly<{
|
|
|
7
7
|
redis(config?: Partial<ZedgiRedisCacheConfig | ZedgiQueueConfig>): import("@zedgi/zedgi-client").RedisClient;
|
|
8
8
|
queue(name: string, config?: Partial<ZedgiQueueConfig | ZedgiRedisCacheConfig>): Readonly<{
|
|
9
9
|
add: (jobName: string, data?: unknown, opts?: Record<string, unknown>) => Promise<import("@zedgi/zedgi-client").QueueJob | null>;
|
|
10
|
+
dequeue: (visibilityTimeoutMs?: number) => Promise<import("@zedgi/zedgi-client").QueueJob | null>;
|
|
11
|
+
ack: (id: string, returnValue?: unknown) => Promise<boolean>;
|
|
12
|
+
fail: (id: string, reason?: string) => Promise<boolean>;
|
|
10
13
|
getJob: (id: string) => Promise<import("@zedgi/zedgi-client").QueueJob | null>;
|
|
11
14
|
getJobs: (states?: string[], start?: number, end?: number, asc?: boolean) => Promise<(import("@zedgi/zedgi-client").QueueJob | null)[]>;
|
|
12
15
|
getJobCounts: (...types: string[]) => Promise<Record<string, number>>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zintrust/zedgi",
|
|
3
|
+
"version": "3.4.0",
|
|
4
|
+
"buildDate": "2026-11-06T08:30:55.508Z",
|
|
5
|
+
"buildEnvironment": {
|
|
6
|
+
"node": "v22.23.4",
|
|
7
|
+
"platform": "linux",
|
|
8
|
+
"arch": "x64"
|
|
9
|
+
},
|
|
10
|
+
"git": {
|
|
11
|
+
"commit": "9c0f52bc",
|
|
12
|
+
"branch": "master"
|
|
13
|
+
},
|
|
14
|
+
"package": {
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20.0.0"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": [
|
|
19
|
+
"@zedgi/zedgi-client"
|
|
20
|
+
],
|
|
21
|
+
"peerDependencies": [
|
|
22
|
+
"@zintrust/core"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"files": {
|
|
26
|
+
"ZedgiCacheDriver.d.ts": {
|
|
27
|
+
"size": 213,
|
|
28
|
+
"sha256": "8d90873a95474d3c6461f0a4a5c79ecd3ea4a1b66e1e36caa890675ee6238d25"
|
|
29
|
+
},
|
|
30
|
+
"ZedgiCacheDriver.js": {
|
|
31
|
+
"size": 2063,
|
|
32
|
+
"sha256": "76cfb566a2f7ea53ae0431fdfac904bfb44665fe12267909a717027dc5460ed1"
|
|
33
|
+
},
|
|
34
|
+
"ZedgiDatabaseAdapter.d.ts": {
|
|
35
|
+
"size": 225,
|
|
36
|
+
"sha256": "b7eb5ad57871368e387e7782656b8cb24a4435d66320ad81d691ec5ff9b2daa8"
|
|
37
|
+
},
|
|
38
|
+
"ZedgiDatabaseAdapter.js": {
|
|
39
|
+
"size": 4344,
|
|
40
|
+
"sha256": "67b543a3c3aa778a30a33138223d73810885592c34046d56311e56480f981bd7"
|
|
41
|
+
},
|
|
42
|
+
"ZedgiMonitorDriver.d.ts": {
|
|
43
|
+
"size": 329,
|
|
44
|
+
"sha256": "b8a6a38f6a987f3ba1142e44075bd161e9381d159dff77d6a1f70c0eb063a3a9"
|
|
45
|
+
},
|
|
46
|
+
"ZedgiMonitorDriver.js": {
|
|
47
|
+
"size": 6435,
|
|
48
|
+
"sha256": "9e9b3242387faca5fe3e63c535d63f2c857a866a7b605694262a6241aed1a5fb"
|
|
49
|
+
},
|
|
50
|
+
"ZedgiQueueDriver.d.ts": {
|
|
51
|
+
"size": 203,
|
|
52
|
+
"sha256": "3c53da5178ad6cb7a6f7b38faec8046027374c02dc2a6737d611dcda7504f9f1"
|
|
53
|
+
},
|
|
54
|
+
"ZedgiQueueDriver.js": {
|
|
55
|
+
"size": 3822,
|
|
56
|
+
"sha256": "f2ef4cb1eae6820c8c23fc6d7a7c619d6644f42e04193a1130531fe886226b9a"
|
|
57
|
+
},
|
|
58
|
+
"ZedgiRedisExecutor.d.ts": {
|
|
59
|
+
"size": 295,
|
|
60
|
+
"sha256": "9fbcc47ef25549ff15bc958863e78257e6098c0fa7234517bb9b3e85d6de8838"
|
|
61
|
+
},
|
|
62
|
+
"ZedgiRedisExecutor.js": {
|
|
63
|
+
"size": 681,
|
|
64
|
+
"sha256": "c5defa05f4e6e4764f1d7328c9e8df8c2a727741e08fac27c1155aeb7400f380"
|
|
65
|
+
},
|
|
66
|
+
"ZedgiRuntime.d.ts": {
|
|
67
|
+
"size": 2443,
|
|
68
|
+
"sha256": "87d907f78ac191bf728b405621305eabc4bcdf0f5898c8cee2d609878a7fd278"
|
|
69
|
+
},
|
|
70
|
+
"ZedgiRuntime.js": {
|
|
71
|
+
"size": 7031,
|
|
72
|
+
"sha256": "61132c4a4a3d73e230b84d5612434f51f2cc2adc4a2588f85398500e494b53b8"
|
|
73
|
+
},
|
|
74
|
+
"index.d.ts": {
|
|
75
|
+
"size": 455,
|
|
76
|
+
"sha256": "91891bce604051300c6e9bfa1a0d1d4583fbbf9abb1c4c657dd2c142af8d5a82"
|
|
77
|
+
},
|
|
78
|
+
"index.js": {
|
|
79
|
+
"size": 494,
|
|
80
|
+
"sha256": "a8ba1e5a964a0b41e9a9bc1e1749811b4e6d2db0e2e8d2183e41e70985889d76"
|
|
81
|
+
},
|
|
82
|
+
"register.d.ts": {
|
|
83
|
+
"size": 617,
|
|
84
|
+
"sha256": "119d77308db3a17052926c95ea145d580a3ebecd57f69429cc1c07af89d83ac9"
|
|
85
|
+
},
|
|
86
|
+
"register.js": {
|
|
87
|
+
"size": 2516,
|
|
88
|
+
"sha256": "45eb897f2c8b34a3953a19fda2697fd3ef09e5d64aee8d858d936b06d4298ef1"
|
|
89
|
+
},
|
|
90
|
+
"types.d.ts": {
|
|
91
|
+
"size": 2264,
|
|
92
|
+
"sha256": "a4569ebd08c6068c9f9ab8327427627cbcc630532d429a0cd2483273c58f1505"
|
|
93
|
+
},
|
|
94
|
+
"types.js": {
|
|
95
|
+
"size": 11,
|
|
96
|
+
"sha256": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/zedgi",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Zedgi HTTPS transport drivers for ZinTrust cache, database, and queue.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"adapter"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@zedgi/zedgi-client": "^1.
|
|
41
|
+
"@zedgi/zedgi-client": "^1.1.1"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsc -p tsconfig.json",
|
|
45
45
|
"prepublishOnly": "npm run build"
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}
|