bullmq 6.3.13 → 6.3.15
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/redis-queue-backend.js +2 -0
- package/dist/cjs/commands/{reprocessJob-7.lua → reprocessJob-9.lua} +11 -1
- package/dist/cjs/scripts/index.js +1 -1
- package/dist/cjs/scripts/{reprocessJob-7.js → reprocessJob-9.js} +27 -2
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/redis-queue-backend.js +2 -0
- package/dist/esm/commands/{reprocessJob-7.lua → reprocessJob-9.lua} +11 -1
- package/dist/esm/scripts/index.d.ts +1 -1
- package/dist/esm/scripts/index.js +1 -1
- package/dist/esm/scripts/{reprocessJob-7.js → reprocessJob-9.js} +27 -2
- 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 +2 -2
- /package/dist/esm/scripts/{reprocessJob-7.d.ts → reprocessJob-9.d.ts} +0 -0
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
KEYS[5] meta
|
|
10
10
|
KEYS[6] active key
|
|
11
11
|
KEYS[7] marker key
|
|
12
|
+
KEYS[8] prioritized key
|
|
13
|
+
KEYS[9] priority counter key
|
|
12
14
|
|
|
13
15
|
ARGV[1] job.id
|
|
14
16
|
ARGV[2] (job.opts.lifo ? 'R' : 'L') + 'PUSH'
|
|
@@ -26,6 +28,7 @@ local rcall = redis.call;
|
|
|
26
28
|
|
|
27
29
|
-- Includes
|
|
28
30
|
--- @include "includes/addJobInTargetList"
|
|
31
|
+
--- @include "includes/addJobWithPriority"
|
|
29
32
|
--- @include "includes/getOrSetMaxEvents"
|
|
30
33
|
--- @include "includes/isQueuePausedOrMaxed"
|
|
31
34
|
--- @include "includes/moveChildBackToParentDependencies"
|
|
@@ -47,7 +50,14 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
|
47
50
|
rcall("HDEL", jobKey, "finishedOn", "processedOn", ARGV[3], unpack(attributesToRemove))
|
|
48
51
|
|
|
49
52
|
local isPausedOrMaxed = isQueuePausedOrMaxed(KEYS[5], KEYS[6])
|
|
50
|
-
|
|
53
|
+
local priority = tonumber(rcall("HGET", jobKey, "priority")) or 0
|
|
54
|
+
|
|
55
|
+
-- Standard or priority add
|
|
56
|
+
if priority == 0 then
|
|
57
|
+
addJobInTargetList(KEYS[4], KEYS[7], ARGV[2], isPausedOrMaxed, jobId)
|
|
58
|
+
else
|
|
59
|
+
addJobWithPriority(KEYS[7], KEYS[8], priority, jobId, KEYS[9], isPausedOrMaxed)
|
|
60
|
+
end
|
|
51
61
|
|
|
52
62
|
moveChildBackToParentDependencies(jobKey, ARGV[4])
|
|
53
63
|
|
|
@@ -41,7 +41,7 @@ export * from './removeJob-2';
|
|
|
41
41
|
export * from './removeJobScheduler-3';
|
|
42
42
|
export * from './removeOrphanedJobs-1';
|
|
43
43
|
export * from './removeUnprocessedChildren-2';
|
|
44
|
-
export * from './reprocessJob-
|
|
44
|
+
export * from './reprocessJob-9';
|
|
45
45
|
export * from './retryJob-11';
|
|
46
46
|
export * from './saveStacktrace-1';
|
|
47
47
|
export * from './updateData-1';
|
|
@@ -41,7 +41,7 @@ export * from './removeJob-2';
|
|
|
41
41
|
export * from './removeJobScheduler-3';
|
|
42
42
|
export * from './removeOrphanedJobs-1';
|
|
43
43
|
export * from './removeUnprocessedChildren-2';
|
|
44
|
-
export * from './reprocessJob-
|
|
44
|
+
export * from './reprocessJob-9';
|
|
45
45
|
export * from './retryJob-11';
|
|
46
46
|
export * from './saveStacktrace-1';
|
|
47
47
|
export * from './updateData-1';
|
|
@@ -8,6 +8,8 @@ const content = `--[[
|
|
|
8
8
|
KEYS[5] meta
|
|
9
9
|
KEYS[6] active key
|
|
10
10
|
KEYS[7] marker key
|
|
11
|
+
KEYS[8] prioritized key
|
|
12
|
+
KEYS[9] priority counter key
|
|
11
13
|
ARGV[1] job.id
|
|
12
14
|
ARGV[2] (job.opts.lifo ? 'R' : 'L') + 'PUSH'
|
|
13
15
|
ARGV[3] propVal - failedReason/returnvalue
|
|
@@ -37,6 +39,23 @@ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed
|
|
|
37
39
|
rcall(pushCmd, targetKey, jobId)
|
|
38
40
|
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
|
39
41
|
end
|
|
42
|
+
--[[
|
|
43
|
+
Function to add job considering priority.
|
|
44
|
+
]]
|
|
45
|
+
-- Includes
|
|
46
|
+
--[[
|
|
47
|
+
Function to get priority score.
|
|
48
|
+
]]
|
|
49
|
+
local function getPriorityScore(priority, priorityCounterKey)
|
|
50
|
+
local prioCounter = rcall("INCR", priorityCounterKey)
|
|
51
|
+
return priority * 0x100000000 + prioCounter % 0x100000000
|
|
52
|
+
end
|
|
53
|
+
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
|
|
54
|
+
isPausedOrMaxed)
|
|
55
|
+
local score = getPriorityScore(priority, priorityCounterKey)
|
|
56
|
+
rcall("ZADD", prioritizedKey, score, jobId)
|
|
57
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
|
58
|
+
end
|
|
40
59
|
--[[
|
|
41
60
|
Function to get max events value or set by default 10000.
|
|
42
61
|
]]
|
|
@@ -96,7 +115,13 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
|
96
115
|
end
|
|
97
116
|
rcall("HDEL", jobKey, "finishedOn", "processedOn", ARGV[3], unpack(attributesToRemove))
|
|
98
117
|
local isPausedOrMaxed = isQueuePausedOrMaxed(KEYS[5], KEYS[6])
|
|
99
|
-
|
|
118
|
+
local priority = tonumber(rcall("HGET", jobKey, "priority")) or 0
|
|
119
|
+
-- Standard or priority add
|
|
120
|
+
if priority == 0 then
|
|
121
|
+
addJobInTargetList(KEYS[4], KEYS[7], ARGV[2], isPausedOrMaxed, jobId)
|
|
122
|
+
else
|
|
123
|
+
addJobWithPriority(KEYS[7], KEYS[8], priority, jobId, KEYS[9], isPausedOrMaxed)
|
|
124
|
+
end
|
|
100
125
|
moveChildBackToParentDependencies(jobKey, ARGV[4])
|
|
101
126
|
local maxEvents = getOrSetMaxEvents(KEYS[5])
|
|
102
127
|
-- Emit waiting event
|
|
@@ -113,5 +138,5 @@ end
|
|
|
113
138
|
export const reprocessJob = {
|
|
114
139
|
name: 'reprocessJob',
|
|
115
140
|
content,
|
|
116
|
-
keys:
|
|
141
|
+
keys: 9,
|
|
117
142
|
};
|