bullmq 5.80.0 → 5.80.2
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/job.js +6 -4
- package/dist/cjs/commands/includes/getJobSchedulerEveryNextMillis.lua +18 -11
- package/dist/cjs/scripts/addJobScheduler-11.js +18 -11
- 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/job.d.ts +5 -3
- package/dist/esm/classes/job.js +6 -4
- package/dist/esm/commands/includes/getJobSchedulerEveryNextMillis.lua +18 -11
- package/dist/esm/interfaces/base-job-options.d.ts +5 -3
- package/dist/esm/scripts/addJobScheduler-11.js +18 -11
- 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 +5 -5
package/dist/cjs/classes/job.js
CHANGED
|
@@ -9,7 +9,7 @@ const backoffs_1 = require("./backoffs");
|
|
|
9
9
|
const unrecoverable_error_1 = require("./errors/unrecoverable-error");
|
|
10
10
|
const enums_1 = require("../enums");
|
|
11
11
|
const logger = (0, util_1.debuglog)('bull');
|
|
12
|
-
exports.PRIORITY_LIMIT = 2 ** 21;
|
|
12
|
+
exports.PRIORITY_LIMIT = 2 ** 21 - 1;
|
|
13
13
|
/**
|
|
14
14
|
* Job
|
|
15
15
|
*
|
|
@@ -59,9 +59,11 @@ class Job {
|
|
|
59
59
|
*/
|
|
60
60
|
this.delay = 0;
|
|
61
61
|
/**
|
|
62
|
-
* Ranges from 0
|
|
63
|
-
*
|
|
64
|
-
*
|
|
62
|
+
* Ranges from 0 to 2 097 151. `0` means no explicit priority, and jobs with
|
|
63
|
+
* no explicit priority are processed before prioritized jobs. For prioritized
|
|
64
|
+
* jobs, lower numbers are processed before higher numbers. Note that using
|
|
65
|
+
* priorities has a slight impact on performance, so do not use it if not
|
|
66
|
+
* required.
|
|
65
67
|
* @defaultValue 0
|
|
66
68
|
*/
|
|
67
69
|
this.priority = 0;
|
|
@@ -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
|
|
|
@@ -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
|
|
@@ -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
|