@zintrust/queue-redis 0.4.70 → 0.4.75
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/BullMQRedisQueue.js +11 -10
- package/dist/build-manifest.json +6 -6
- package/package.json +2 -2
package/dist/BullMQRedisQueue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cloudflare, createLockProvider, createRedisConnection, Env, ErrorFactory, generateUuid, getBullMQSafeQueueName, getLockProvider, Logger, queueConfig, registerLockProvider, resolveLockPrefix, ZintrustLang, } from '@zintrust/core';
|
|
1
|
+
import { Cloudflare, createLockProvider, createRedisConnection, Env, ErrorFactory, generateUuid, getBullMQSafeQueueName, getLockProvider, Logger, queueConfig, registerLockProvider, resolveDeduplicationLockKey, resolveLockPrefix, ZintrustLang, } from '@zintrust/core';
|
|
2
2
|
import { Queue } from 'bullmq';
|
|
3
3
|
import { HttpQueueDriver } from './HttpQueueDriver.js';
|
|
4
4
|
export const shouldUseHttpProxyDriver = () => {
|
|
@@ -264,8 +264,8 @@ export const BullMQRedisQueue = (() => {
|
|
|
264
264
|
const deduplicationId = String(deduplication.id).trim();
|
|
265
265
|
return deduplicationId.length > 0 ? deduplicationId : null;
|
|
266
266
|
};
|
|
267
|
-
const checkExistingLock = async (deduplicationId, provider, replace, queue, jobId) => {
|
|
268
|
-
const status = await provider.status(
|
|
267
|
+
const checkExistingLock = async (scopedDeduplicationKey, deduplicationId, provider, replace, queue, jobId) => {
|
|
268
|
+
const status = await provider.status(scopedDeduplicationKey);
|
|
269
269
|
if (status.exists && !replace) {
|
|
270
270
|
Logger.info('BullMQ: Job deduplicated', {
|
|
271
271
|
queue,
|
|
@@ -276,9 +276,9 @@ export const BullMQRedisQueue = (() => {
|
|
|
276
276
|
}
|
|
277
277
|
return false;
|
|
278
278
|
};
|
|
279
|
-
const acquireDeduplicationLock = async (deduplicationId, provider, ttl, queue, jobId) => {
|
|
279
|
+
const acquireDeduplicationLock = async (scopedDeduplicationKey, deduplicationId, provider, ttl, queue, jobId) => {
|
|
280
280
|
const lockOptions = ttl ? { ttl } : {};
|
|
281
|
-
const lock = await provider.acquire(
|
|
281
|
+
const lock = await provider.acquire(scopedDeduplicationKey, lockOptions);
|
|
282
282
|
if (!lock.acquired) {
|
|
283
283
|
Logger.info('BullMQ: Job deduplicated (lock collision)', {
|
|
284
284
|
queue,
|
|
@@ -294,10 +294,10 @@ export const BullMQRedisQueue = (() => {
|
|
|
294
294
|
});
|
|
295
295
|
return true;
|
|
296
296
|
};
|
|
297
|
-
const scheduleLockRelease = (
|
|
297
|
+
const scheduleLockRelease = (scopedDeduplicationKey, provider, ttl, releaseAfter) => {
|
|
298
298
|
const timeoutId = globalThis.setTimeout(() => {
|
|
299
299
|
provider.release({
|
|
300
|
-
key:
|
|
300
|
+
key: scopedDeduplicationKey,
|
|
301
301
|
ttl: ttl ?? 0,
|
|
302
302
|
acquired: true,
|
|
303
303
|
expires: new Date(Date.now() + (ttl ?? 0)),
|
|
@@ -325,6 +325,7 @@ export const BullMQRedisQueue = (() => {
|
|
|
325
325
|
return { payloadToSend: payloadData, shouldReturn: false };
|
|
326
326
|
}
|
|
327
327
|
const provider = getLockProviderForQueue(payloadData.uniqueVia);
|
|
328
|
+
const scopedDeduplicationKey = resolveDeduplicationLockKey(queue, deduplicationId);
|
|
328
329
|
const ttl = typeof deduplication.ttl === 'number' && deduplication.ttl > 0
|
|
329
330
|
? deduplication.ttl
|
|
330
331
|
: undefined;
|
|
@@ -332,12 +333,12 @@ export const BullMQRedisQueue = (() => {
|
|
|
332
333
|
const jobId = jobOptions.jobId ?? generateUuid();
|
|
333
334
|
jobOptions.jobId = jobId;
|
|
334
335
|
// Check existing lock
|
|
335
|
-
const hasExistingLock = await checkExistingLock(deduplicationId, provider, replace, queue, jobId);
|
|
336
|
+
const hasExistingLock = await checkExistingLock(scopedDeduplicationKey, deduplicationId, provider, replace, queue, jobId);
|
|
336
337
|
if (hasExistingLock) {
|
|
337
338
|
return { payloadToSend: payloadData, shouldReturn: true, returnValue: deduplicationId };
|
|
338
339
|
}
|
|
339
340
|
// Acquire lock
|
|
340
|
-
const lockAcquired = await acquireDeduplicationLock(deduplicationId, provider, ttl, queue, jobId);
|
|
341
|
+
const lockAcquired = await acquireDeduplicationLock(scopedDeduplicationKey, deduplicationId, provider, ttl, queue, jobId);
|
|
341
342
|
if (!lockAcquired) {
|
|
342
343
|
return { payloadToSend: payloadData, shouldReturn: true, returnValue: deduplicationId };
|
|
343
344
|
}
|
|
@@ -347,7 +348,7 @@ export const BullMQRedisQueue = (() => {
|
|
|
347
348
|
let payloadToSend = payloadData;
|
|
348
349
|
// Handle releaseAfter numeric
|
|
349
350
|
if (typeof deduplication.releaseAfter === 'number' && deduplication.releaseAfter > 0) {
|
|
350
|
-
scheduleLockRelease(
|
|
351
|
+
scheduleLockRelease(scopedDeduplicationKey, provider, ttl, deduplication.releaseAfter);
|
|
351
352
|
}
|
|
352
353
|
// Handle releaseAfter non-numeric
|
|
353
354
|
if (deduplication.releaseAfter !== undefined &&
|
package/dist/build-manifest.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/queue-redis",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"buildDate": "2026-04-
|
|
3
|
+
"version": "0.4.75",
|
|
4
|
+
"buildDate": "2026-04-07T17:14:28.165Z",
|
|
5
5
|
"buildEnvironment": {
|
|
6
6
|
"node": "v20.20.2",
|
|
7
7
|
"platform": "linux",
|
|
8
8
|
"arch": "x64"
|
|
9
9
|
},
|
|
10
10
|
"git": {
|
|
11
|
-
"commit": "
|
|
11
|
+
"commit": "f910e7ec",
|
|
12
12
|
"branch": "master"
|
|
13
13
|
},
|
|
14
14
|
"package": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"sha256": "52fb0f688cd17cc7d8e8128e60df6f5eea4c803282382ac75550e6aacee7cbb0"
|
|
30
30
|
},
|
|
31
31
|
"BullMQRedisQueue.js": {
|
|
32
|
-
"size":
|
|
33
|
-
"sha256": "
|
|
32
|
+
"size": 21579,
|
|
33
|
+
"sha256": "042803997f2f9895827ce34359bb62c80b2b889ab4ddc9cbbe191924a376684a"
|
|
34
34
|
},
|
|
35
35
|
"HttpQueueDriver.d.ts": {
|
|
36
36
|
"size": 835,
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"index.js": {
|
|
64
64
|
"size": 677,
|
|
65
|
-
"sha256": "
|
|
65
|
+
"sha256": "0b175d703cca21f8726f87a3ca5b7cd88d9561fe42f48fb14d71a137e63c7f7d"
|
|
66
66
|
},
|
|
67
67
|
"register.d.ts": {
|
|
68
68
|
"size": 170,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/queue-redis",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.75",
|
|
4
4
|
"description": "Redis queue driver for ZinTrust.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"node": ">=20.0.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@zintrust/core": "^0.4.
|
|
26
|
+
"@zintrust/core": "^0.4.74"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|