bullmq 5.80.1 → 5.80.3
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/cjs/classes/flow-producer.js +16 -4
- package/dist/cjs/commands/addDelayedJob-6.lua +2 -2
- package/dist/cjs/commands/addParentJob-6.lua +2 -2
- package/dist/cjs/commands/addPrioritizedJob-9.lua +2 -2
- package/dist/cjs/commands/addStandardJob-9.lua +2 -2
- package/dist/cjs/commands/includes/getJobSchedulerEveryNextMillis.lua +18 -11
- package/dist/cjs/scripts/addDelayedJob-6.js +2 -2
- package/dist/cjs/scripts/addJobScheduler-11.js +18 -11
- package/dist/cjs/scripts/addParentJob-6.js +2 -2
- package/dist/cjs/scripts/addPrioritizedJob-9.js +2 -2
- package/dist/cjs/scripts/addStandardJob-9.js +2 -2
- package/dist/cjs/scripts/updateJobScheduler-12.js +18 -11
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/flow-producer.d.ts +2 -3
- package/dist/esm/classes/flow-producer.js +16 -4
- package/dist/esm/commands/addDelayedJob-6.lua +2 -2
- package/dist/esm/commands/addParentJob-6.lua +2 -2
- package/dist/esm/commands/addPrioritizedJob-9.lua +2 -2
- package/dist/esm/commands/addStandardJob-9.lua +2 -2
- package/dist/esm/commands/includes/getJobSchedulerEveryNextMillis.lua +18 -11
- package/dist/esm/scripts/addDelayedJob-6.js +2 -2
- package/dist/esm/scripts/addJobScheduler-11.js +18 -11
- package/dist/esm/scripts/addParentJob-6.js +2 -2
- package/dist/esm/scripts/addPrioritizedJob-9.js +2 -2
- package/dist/esm/scripts/addStandardJob-9.js +2 -2
- package/dist/esm/scripts/updateJobScheduler-12.js +18 -11
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +13 -13
|
@@ -115,6 +115,9 @@ class FlowProducer extends events_1.EventEmitter {
|
|
|
115
115
|
if (typeof jobId === 'string') {
|
|
116
116
|
jobsTree.job.id = jobId;
|
|
117
117
|
}
|
|
118
|
+
else if (typeof jobId === 'number') {
|
|
119
|
+
jobsTree.job.id = jobId.toString();
|
|
120
|
+
}
|
|
118
121
|
}
|
|
119
122
|
return jobsTree;
|
|
120
123
|
});
|
|
@@ -144,9 +147,8 @@ class FlowProducer extends events_1.EventEmitter {
|
|
|
144
147
|
* Whenever the children of a given parent are completed, the parent
|
|
145
148
|
* will be processed, being able to access the children's result data.
|
|
146
149
|
*
|
|
147
|
-
* All Jobs can be in different queues, either children or parents
|
|
148
|
-
*
|
|
149
|
-
* be added to the queues, or it succeeds and all jobs will be added.
|
|
150
|
+
* All Jobs can be in different queues, either children or parents.
|
|
151
|
+
* If a flow fails to be added, other flows in the batch may still be added.
|
|
150
152
|
*
|
|
151
153
|
* @param flows - an array of objects with a tree-like structure where children jobs
|
|
152
154
|
* will be processed before their parents.
|
|
@@ -158,6 +160,7 @@ class FlowProducer extends events_1.EventEmitter {
|
|
|
158
160
|
const client = await this.connection.client;
|
|
159
161
|
const multi = client.multi();
|
|
160
162
|
return (0, utils_1.trace)(this.telemetry, enums_1.SpanKind.PRODUCER, '', 'addBulkFlows', '', async (span) => {
|
|
163
|
+
var _a, _b;
|
|
161
164
|
span === null || span === void 0 ? void 0 : span.setAttributes({
|
|
162
165
|
[enums_1.TelemetryAttributes.BulkCount]: flows.length,
|
|
163
166
|
[enums_1.TelemetryAttributes.BulkNames]: flows
|
|
@@ -172,9 +175,18 @@ class FlowProducer extends events_1.EventEmitter {
|
|
|
172
175
|
continue;
|
|
173
176
|
}
|
|
174
177
|
const [err, jobId] = result;
|
|
175
|
-
if (
|
|
178
|
+
if (err) {
|
|
179
|
+
throw err;
|
|
180
|
+
}
|
|
181
|
+
if (typeof jobId === 'number' && jobId < 0) {
|
|
182
|
+
throw this.toFlowError(jobId, (0, utils_1.getParentKey)((_b = (_a = flows[index]) === null || _a === void 0 ? void 0 : _a.opts) === null || _b === void 0 ? void 0 : _b.parent));
|
|
183
|
+
}
|
|
184
|
+
if (typeof jobId === 'string') {
|
|
176
185
|
jobsTrees[index].job.id = jobId;
|
|
177
186
|
}
|
|
187
|
+
else if (typeof jobId === 'number') {
|
|
188
|
+
jobsTrees[index].job.id = jobId.toString();
|
|
189
|
+
}
|
|
178
190
|
}
|
|
179
191
|
return jobsTrees;
|
|
180
192
|
});
|
|
@@ -76,7 +76,7 @@ local parentDependenciesKey = args[6]
|
|
|
76
76
|
local timestamp = args[4]
|
|
77
77
|
|
|
78
78
|
if args[2] == "" then
|
|
79
|
-
jobId = jobCounter
|
|
79
|
+
jobId = jobCounter .. "" -- convert to string
|
|
80
80
|
jobIdKey = args[1] .. jobId
|
|
81
81
|
else
|
|
82
82
|
jobId = args[2]
|
|
@@ -105,4 +105,4 @@ if parentDependenciesKey ~= nil then
|
|
|
105
105
|
rcall("SADD", parentDependenciesKey, jobIdKey)
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
-
return jobId
|
|
108
|
+
return jobId
|
|
@@ -71,7 +71,7 @@ local maxEvents = getOrSetMaxEvents(metaKey)
|
|
|
71
71
|
local parentDependenciesKey = args[6]
|
|
72
72
|
local timestamp = args[4]
|
|
73
73
|
if args[2] == "" then
|
|
74
|
-
jobId = jobCounter
|
|
74
|
+
jobId = jobCounter .. "" -- convert to string
|
|
75
75
|
jobIdKey = args[1] .. jobId
|
|
76
76
|
else
|
|
77
77
|
jobId = args[2]
|
|
@@ -107,4 +107,4 @@ if parentDependenciesKey ~= nil then
|
|
|
107
107
|
rcall("SADD", parentDependenciesKey, jobIdKey)
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
return jobId
|
|
110
|
+
return jobId
|
|
@@ -78,7 +78,7 @@ local maxEvents = getOrSetMaxEvents(metaKey)
|
|
|
78
78
|
local parentDependenciesKey = args[6]
|
|
79
79
|
local timestamp = args[4]
|
|
80
80
|
if args[2] == "" then
|
|
81
|
-
jobId = jobCounter
|
|
81
|
+
jobId = jobCounter .. "" -- convert to string
|
|
82
82
|
jobIdKey = args[1] .. jobId
|
|
83
83
|
else
|
|
84
84
|
jobId = args[2]
|
|
@@ -115,4 +115,4 @@ if parentDependenciesKey ~= nil then
|
|
|
115
115
|
rcall("SADD", parentDependenciesKey, jobIdKey)
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
-
return jobId
|
|
118
|
+
return jobId
|
|
@@ -82,7 +82,7 @@ local maxEvents = getOrSetMaxEvents(metaKey)
|
|
|
82
82
|
local parentDependenciesKey = args[6]
|
|
83
83
|
local timestamp = args[4]
|
|
84
84
|
if args[2] == "" then
|
|
85
|
-
jobId = jobCounter
|
|
85
|
+
jobId = jobCounter .. "" -- convert to string
|
|
86
86
|
jobIdKey = args[1] .. jobId
|
|
87
87
|
else
|
|
88
88
|
jobId = args[2]
|
|
@@ -120,4 +120,4 @@ if parentDependenciesKey ~= nil then
|
|
|
120
120
|
rcall("SADD", parentDependenciesKey, jobIdKey)
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
-
return jobId
|
|
123
|
+
return jobId
|
|
@@ -9,25 +9,32 @@ local function getJobSchedulerEveryNextMillis(prevMillis, every, now, offset, st
|
|
|
9
9
|
nextMillis = tonumber(startDate)
|
|
10
10
|
nextMillis = nextMillis > now and nextMillis or now
|
|
11
11
|
else
|
|
12
|
-
nextMillis = now
|
|
13
|
-
-- For the first iteration with no startDate and an explicit
|
|
14
|
-
-- offset, align nextMillis to the next offset slot strictly
|
|
15
|
-
-- after now. Without this the user-supplied offset is
|
|
16
|
-
-- recorded but ignored, and the first job fires at now
|
|
17
|
-
-- instead of the next aligned timestamp (issue #3705).
|
|
18
12
|
if offset and offset > 0 then
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
-- Align to the next slot that respects the offset
|
|
14
|
+
nextMillis = math.floor(now / every) * every + offset
|
|
15
|
+
if nextMillis <= now then
|
|
16
|
+
nextMillis = nextMillis + every
|
|
22
17
|
end
|
|
23
|
-
|
|
18
|
+
else
|
|
19
|
+
nextMillis = now
|
|
24
20
|
end
|
|
25
21
|
end
|
|
26
22
|
else
|
|
27
23
|
nextMillis = prevMillis + every
|
|
28
24
|
-- check if we may have missed some iterations
|
|
29
25
|
if nextMillis < now then
|
|
30
|
-
|
|
26
|
+
-- Use the same offset-aware alignment as the initial branch
|
|
27
|
+
-- above so a non-zero offset is preserved across catch-ups
|
|
28
|
+
-- instead of being flattened to (slot + every). When the
|
|
29
|
+
-- aligned slot is itself still in the past, advance by one
|
|
30
|
+
-- full interval; otherwise the aligned slot is the next
|
|
31
|
+
-- iteration.
|
|
32
|
+
local aligned = math.floor(now / every) * every + (offset or 0)
|
|
33
|
+
if aligned <= now then
|
|
34
|
+
nextMillis = aligned + every
|
|
35
|
+
else
|
|
36
|
+
nextMillis = aligned
|
|
37
|
+
end
|
|
31
38
|
end
|
|
32
39
|
end
|
|
33
40
|
|
|
@@ -546,7 +546,7 @@ local opts = cmsgpack.unpack(ARGV[3])
|
|
|
546
546
|
local parentDependenciesKey = args[6]
|
|
547
547
|
local timestamp = args[4]
|
|
548
548
|
if args[2] == "" then
|
|
549
|
-
jobId = jobCounter
|
|
549
|
+
jobId = jobCounter .. "" -- convert to string
|
|
550
550
|
jobIdKey = args[1] .. jobId
|
|
551
551
|
else
|
|
552
552
|
jobId = args[2]
|
|
@@ -570,7 +570,7 @@ addDelayedJob(jobId, delayedKey, eventsKey, timestamp, maxEvents, KEYS[1], delay
|
|
|
570
570
|
if parentDependenciesKey ~= nil then
|
|
571
571
|
rcall("SADD", parentDependenciesKey, jobIdKey)
|
|
572
572
|
end
|
|
573
|
-
return jobId
|
|
573
|
+
return jobId
|
|
574
574
|
`;
|
|
575
575
|
exports.addDelayedJob = {
|
|
576
576
|
name: 'addDelayedJob',
|
|
@@ -443,25 +443,32 @@ local function getJobSchedulerEveryNextMillis(prevMillis, every, now, offset, st
|
|
|
443
443
|
nextMillis = tonumber(startDate)
|
|
444
444
|
nextMillis = nextMillis > now and nextMillis or now
|
|
445
445
|
else
|
|
446
|
-
nextMillis = now
|
|
447
|
-
-- For the first iteration with no startDate and an explicit
|
|
448
|
-
-- offset, align nextMillis to the next offset slot strictly
|
|
449
|
-
-- after now. Without this the user-supplied offset is
|
|
450
|
-
-- recorded but ignored, and the first job fires at now
|
|
451
|
-
-- instead of the next aligned timestamp (issue #3705).
|
|
452
446
|
if offset and offset > 0 then
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
447
|
+
-- Align to the next slot that respects the offset
|
|
448
|
+
nextMillis = math.floor(now / every) * every + offset
|
|
449
|
+
if nextMillis <= now then
|
|
450
|
+
nextMillis = nextMillis + every
|
|
456
451
|
end
|
|
457
|
-
|
|
452
|
+
else
|
|
453
|
+
nextMillis = now
|
|
458
454
|
end
|
|
459
455
|
end
|
|
460
456
|
else
|
|
461
457
|
nextMillis = prevMillis + every
|
|
462
458
|
-- check if we may have missed some iterations
|
|
463
459
|
if nextMillis < now then
|
|
464
|
-
|
|
460
|
+
-- Use the same offset-aware alignment as the initial branch
|
|
461
|
+
-- above so a non-zero offset is preserved across catch-ups
|
|
462
|
+
-- instead of being flattened to (slot + every). When the
|
|
463
|
+
-- aligned slot is itself still in the past, advance by one
|
|
464
|
+
-- full interval; otherwise the aligned slot is the next
|
|
465
|
+
-- iteration.
|
|
466
|
+
local aligned = math.floor(now / every) * every + (offset or 0)
|
|
467
|
+
if aligned <= now then
|
|
468
|
+
nextMillis = aligned + every
|
|
469
|
+
else
|
|
470
|
+
nextMillis = aligned
|
|
471
|
+
end
|
|
465
472
|
end
|
|
466
473
|
end
|
|
467
474
|
if not offset or offset == 0 then
|
|
@@ -436,7 +436,7 @@ local maxEvents = getOrSetMaxEvents(metaKey)
|
|
|
436
436
|
local parentDependenciesKey = args[6]
|
|
437
437
|
local timestamp = args[4]
|
|
438
438
|
if args[2] == "" then
|
|
439
|
-
jobId = jobCounter
|
|
439
|
+
jobId = jobCounter .. "" -- convert to string
|
|
440
440
|
jobIdKey = args[1] .. jobId
|
|
441
441
|
else
|
|
442
442
|
jobId = args[2]
|
|
@@ -467,7 +467,7 @@ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
|
|
467
467
|
if parentDependenciesKey ~= nil then
|
|
468
468
|
rcall("SADD", parentDependenciesKey, jobIdKey)
|
|
469
469
|
end
|
|
470
|
-
return jobId
|
|
470
|
+
return jobId
|
|
471
471
|
`;
|
|
472
472
|
exports.addParentJob = {
|
|
473
473
|
name: 'addParentJob',
|
|
@@ -509,7 +509,7 @@ local maxEvents = getOrSetMaxEvents(metaKey)
|
|
|
509
509
|
local parentDependenciesKey = args[6]
|
|
510
510
|
local timestamp = args[4]
|
|
511
511
|
if args[2] == "" then
|
|
512
|
-
jobId = jobCounter
|
|
512
|
+
jobId = jobCounter .. "" -- convert to string
|
|
513
513
|
jobIdKey = args[1] .. jobId
|
|
514
514
|
else
|
|
515
515
|
jobId = args[2]
|
|
@@ -540,7 +540,7 @@ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",
|
|
|
540
540
|
if parentDependenciesKey ~= nil then
|
|
541
541
|
rcall("SADD", parentDependenciesKey, jobIdKey)
|
|
542
542
|
end
|
|
543
|
-
return jobId
|
|
543
|
+
return jobId
|
|
544
544
|
`;
|
|
545
545
|
exports.addPrioritizedJob = {
|
|
546
546
|
name: 'addPrioritizedJob',
|
|
@@ -513,7 +513,7 @@ local maxEvents = getOrSetMaxEvents(metaKey)
|
|
|
513
513
|
local parentDependenciesKey = args[6]
|
|
514
514
|
local timestamp = args[4]
|
|
515
515
|
if args[2] == "" then
|
|
516
|
-
jobId = jobCounter
|
|
516
|
+
jobId = jobCounter .. "" -- convert to string
|
|
517
517
|
jobIdKey = args[1] .. jobId
|
|
518
518
|
else
|
|
519
519
|
jobId = args[2]
|
|
@@ -544,7 +544,7 @@ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",
|
|
|
544
544
|
if parentDependenciesKey ~= nil then
|
|
545
545
|
rcall("SADD", parentDependenciesKey, jobIdKey)
|
|
546
546
|
end
|
|
547
|
-
return jobId
|
|
547
|
+
return jobId
|
|
548
548
|
`;
|
|
549
549
|
exports.addStandardJob = {
|
|
550
550
|
name: 'addStandardJob',
|
|
@@ -249,25 +249,32 @@ local function getJobSchedulerEveryNextMillis(prevMillis, every, now, offset, st
|
|
|
249
249
|
nextMillis = tonumber(startDate)
|
|
250
250
|
nextMillis = nextMillis > now and nextMillis or now
|
|
251
251
|
else
|
|
252
|
-
nextMillis = now
|
|
253
|
-
-- For the first iteration with no startDate and an explicit
|
|
254
|
-
-- offset, align nextMillis to the next offset slot strictly
|
|
255
|
-
-- after now. Without this the user-supplied offset is
|
|
256
|
-
-- recorded but ignored, and the first job fires at now
|
|
257
|
-
-- instead of the next aligned timestamp (issue #3705).
|
|
258
252
|
if offset and offset > 0 then
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
253
|
+
-- Align to the next slot that respects the offset
|
|
254
|
+
nextMillis = math.floor(now / every) * every + offset
|
|
255
|
+
if nextMillis <= now then
|
|
256
|
+
nextMillis = nextMillis + every
|
|
262
257
|
end
|
|
263
|
-
|
|
258
|
+
else
|
|
259
|
+
nextMillis = now
|
|
264
260
|
end
|
|
265
261
|
end
|
|
266
262
|
else
|
|
267
263
|
nextMillis = prevMillis + every
|
|
268
264
|
-- check if we may have missed some iterations
|
|
269
265
|
if nextMillis < now then
|
|
270
|
-
|
|
266
|
+
-- Use the same offset-aware alignment as the initial branch
|
|
267
|
+
-- above so a non-zero offset is preserved across catch-ups
|
|
268
|
+
-- instead of being flattened to (slot + every). When the
|
|
269
|
+
-- aligned slot is itself still in the past, advance by one
|
|
270
|
+
-- full interval; otherwise the aligned slot is the next
|
|
271
|
+
-- iteration.
|
|
272
|
+
local aligned = math.floor(now / every) * every + (offset or 0)
|
|
273
|
+
if aligned <= now then
|
|
274
|
+
nextMillis = aligned + every
|
|
275
|
+
else
|
|
276
|
+
nextMillis = aligned
|
|
277
|
+
end
|
|
271
278
|
end
|
|
272
279
|
end
|
|
273
280
|
if not offset or offset == 0 then
|