bullmq 3.13.4 → 3.14.1
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 +1 -1
- package/dist/cjs/classes/worker.js.map +1 -1
- package/dist/cjs/commands/addJob-8.lua +2 -2
- package/dist/cjs/commands/changeDelay-3.lua +2 -3
- package/dist/cjs/commands/getRanges-1.lua +1 -1
- package/dist/cjs/commands/includes/addDelayMarkerIfNeeded.lua +3 -3
- package/dist/cjs/commands/includes/cleanSet.lua +2 -2
- package/dist/cjs/commands/includes/getRateLimitTTL.lua +1 -1
- package/dist/cjs/commands/includes/promoteDelayedJobs.lua +4 -9
- package/dist/cjs/commands/includes/updateParentDepsIfNeeded.lua +0 -1
- package/dist/cjs/commands/isFinished-3.lua +3 -3
- package/dist/cjs/commands/moveToActive-9.lua +51 -46
- package/dist/cjs/commands/moveToDelayed-8.lua +22 -23
- package/dist/cjs/commands/moveToFinished-12.lua +3 -1
- package/dist/cjs/commands/pause-4.lua +8 -8
- package/dist/cjs/commands/promote-6.lua +7 -3
- package/dist/cjs/commands/removeRepeatable-2.lua +3 -0
- package/dist/cjs/commands/reprocessJob-6.lua +1 -1
- package/dist/cjs/commands/retryJob-8.lua +4 -5
- package/dist/cjs/commands/saveStacktrace-1.lua +2 -3
- package/dist/cjs/commands/updateData-1.lua +6 -2
- package/dist/cjs/commands/updateProgress-2.lua +6 -2
- package/dist/cjs/scripts/addJob-8.js +5 -5
- package/dist/cjs/scripts/changeDelay-3.js +2 -2
- package/dist/cjs/scripts/getRanges-1.js +1 -1
- package/dist/cjs/scripts/isFinished-3.js +3 -3
- package/dist/cjs/scripts/moveToActive-9.js +76 -76
- package/dist/cjs/scripts/moveToDelayed-8.js +29 -32
- package/dist/cjs/scripts/moveToDelayed-8.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-12.js +21 -23
- package/dist/cjs/scripts/moveToFinished-12.js.map +1 -1
- package/dist/cjs/scripts/pause-4.js +8 -8
- package/dist/cjs/scripts/promote-6.js +6 -3
- package/dist/cjs/scripts/promote-6.js.map +1 -1
- package/dist/cjs/scripts/removeRepeatable-2.js +2 -0
- package/dist/cjs/scripts/removeRepeatable-2.js.map +1 -1
- package/dist/cjs/scripts/reprocessJob-6.js +1 -1
- package/dist/cjs/scripts/retryJob-8.js +7 -10
- package/dist/cjs/scripts/retryJob-8.js.map +1 -1
- package/dist/cjs/scripts/saveStacktrace-1.js +1 -1
- package/dist/cjs/scripts/updateData-1.js +4 -1
- package/dist/cjs/scripts/updateData-1.js.map +1 -1
- package/dist/cjs/scripts/updateProgress-2.js +3 -0
- package/dist/cjs/scripts/updateProgress-2.js.map +1 -1
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/esm/classes/job.js +1 -1
- package/dist/esm/classes/worker.d.ts +2 -2
- package/dist/esm/classes/worker.js.map +1 -1
- package/dist/esm/commands/addJob-8.lua +2 -2
- package/dist/esm/commands/changeDelay-3.lua +2 -3
- package/dist/esm/commands/getRanges-1.lua +1 -1
- package/dist/esm/commands/includes/addDelayMarkerIfNeeded.lua +3 -3
- package/dist/esm/commands/includes/cleanSet.lua +2 -2
- package/dist/esm/commands/includes/getRateLimitTTL.lua +1 -1
- package/dist/esm/commands/includes/promoteDelayedJobs.lua +4 -9
- package/dist/esm/commands/includes/updateParentDepsIfNeeded.lua +0 -1
- package/dist/esm/commands/isFinished-3.lua +3 -3
- package/dist/esm/commands/moveToActive-9.lua +51 -46
- package/dist/esm/commands/moveToDelayed-8.lua +22 -23
- package/dist/esm/commands/moveToFinished-12.lua +3 -1
- package/dist/esm/commands/pause-4.lua +8 -8
- package/dist/esm/commands/promote-6.lua +7 -3
- package/dist/esm/commands/removeRepeatable-2.lua +3 -0
- package/dist/esm/commands/reprocessJob-6.lua +1 -1
- package/dist/esm/commands/retryJob-8.lua +4 -5
- package/dist/esm/commands/saveStacktrace-1.lua +2 -3
- package/dist/esm/commands/updateData-1.lua +6 -2
- package/dist/esm/commands/updateProgress-2.lua +6 -2
- package/dist/esm/scripts/addJob-8.js +5 -5
- package/dist/esm/scripts/changeDelay-3.js +2 -2
- package/dist/esm/scripts/getRanges-1.js +1 -1
- package/dist/esm/scripts/isFinished-3.js +3 -3
- package/dist/esm/scripts/moveToActive-9.js +76 -76
- package/dist/esm/scripts/moveToDelayed-8.js +29 -32
- package/dist/esm/scripts/moveToDelayed-8.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-12.js +21 -23
- package/dist/esm/scripts/moveToFinished-12.js.map +1 -1
- package/dist/esm/scripts/pause-4.js +8 -8
- package/dist/esm/scripts/promote-6.js +6 -3
- package/dist/esm/scripts/promote-6.js.map +1 -1
- package/dist/esm/scripts/removeRepeatable-2.js +2 -0
- package/dist/esm/scripts/removeRepeatable-2.js.map +1 -1
- package/dist/esm/scripts/reprocessJob-6.js +1 -1
- package/dist/esm/scripts/retryJob-8.js +7 -10
- package/dist/esm/scripts/retryJob-8.js.map +1 -1
- package/dist/esm/scripts/saveStacktrace-1.js +1 -1
- package/dist/esm/scripts/updateData-1.js +4 -1
- package/dist/esm/scripts/updateData-1.js.map +1 -1
- package/dist/esm/scripts/updateProgress-2.js +3 -0
- package/dist/esm/scripts/updateProgress-2.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -40,11 +40,11 @@ local function getNextDelayedTimestamp(delayedKey)
|
|
40
40
|
return nextTimestamp
|
41
41
|
end
|
42
42
|
end
|
43
|
-
local function addDelayMarkerIfNeeded(
|
44
|
-
if rcall("LLEN",
|
43
|
+
local function addDelayMarkerIfNeeded(targetKey, delayedKey)
|
44
|
+
if rcall("LLEN", targetKey) == 0 then
|
45
45
|
local nextTimestamp = getNextDelayedTimestamp(delayedKey)
|
46
46
|
if nextTimestamp ~= nil then
|
47
|
-
rcall("LPUSH",
|
47
|
+
rcall("LPUSH", targetKey, "0:" .. nextTimestamp)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -65,7 +65,6 @@ end
|
|
65
65
|
Events:
|
66
66
|
'waiting'
|
67
67
|
]]
|
68
|
-
local rcall = redis.call
|
69
68
|
-- Includes
|
70
69
|
--[[
|
71
70
|
Function to add job considering priority.
|
@@ -82,21 +81,19 @@ local function addJobWithPriority(priorityKey, priority, targetKey, jobId)
|
|
82
81
|
end
|
83
82
|
end
|
84
83
|
-- Try to get as much as 1000 jobs at once
|
85
|
-
local function promoteDelayedJobs(delayedKey,
|
86
|
-
|
84
|
+
local function promoteDelayedJobs(delayedKey, targetKey, priorityKey,
|
85
|
+
eventStreamKey, prefix, timestamp)
|
87
86
|
local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000, "LIMIT", 0, 1000)
|
88
87
|
if (#jobs > 0) then
|
89
88
|
rcall("ZREM", delayedKey, unpack(jobs))
|
90
|
-
-- check if we need to use push in paused instead of waiting
|
91
|
-
local target = getTargetQueueList(metaKey, waitKey, pausedKey)
|
92
89
|
for _, jobId in ipairs(jobs) do
|
93
90
|
local priority =
|
94
91
|
tonumber(rcall("HGET", prefix .. jobId, "priority")) or 0
|
95
92
|
if priority == 0 then
|
96
93
|
-- LIFO or FIFO
|
97
|
-
rcall("LPUSH",
|
94
|
+
rcall("LPUSH", targetKey, jobId)
|
98
95
|
else
|
99
|
-
addJobWithPriority(priorityKey, priority,
|
96
|
+
addJobWithPriority(priorityKey, priority, targetKey, jobId)
|
100
97
|
end
|
101
98
|
-- Emit waiting event
|
102
99
|
rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",
|
@@ -107,30 +104,30 @@ local function promoteDelayedJobs(delayedKey, waitKey, priorityKey, pausedKey,
|
|
107
104
|
end
|
108
105
|
local jobKey = KEYS[5]
|
109
106
|
if rcall("EXISTS", jobKey) == 1 then
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
end
|
118
|
-
end
|
119
|
-
local jobId = ARGV[4]
|
120
|
-
local score = tonumber(ARGV[3])
|
121
|
-
local delayedTimestamp = (score / 0x1000)
|
122
|
-
local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)
|
123
|
-
if (numRemovedElements < 1) then
|
124
|
-
return -3
|
107
|
+
local delayedKey = KEYS[4]
|
108
|
+
if ARGV[5] ~= "0" then
|
109
|
+
local lockKey = jobKey .. ':lock'
|
110
|
+
if rcall("GET", lockKey) == ARGV[5] then
|
111
|
+
rcall("DEL", lockKey)
|
112
|
+
else
|
113
|
+
return -2
|
125
114
|
end
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
115
|
+
end
|
116
|
+
local jobId = ARGV[4]
|
117
|
+
local score = tonumber(ARGV[3])
|
118
|
+
local delayedTimestamp = (score / 0x1000)
|
119
|
+
local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)
|
120
|
+
if numRemovedElements < 1 then
|
121
|
+
return -3
|
122
|
+
end
|
123
|
+
rcall("ZADD", delayedKey, score, jobId)
|
124
|
+
rcall("XADD", KEYS[6], "*", "event", "delayed", "jobId", jobId, "delay", delayedTimestamp)
|
125
|
+
-- Check if we need to push a marker job to wake up sleeping workers.
|
126
|
+
local target = getTargetQueueList(KEYS[8], KEYS[1], KEYS[7])
|
127
|
+
addDelayMarkerIfNeeded(target, delayedKey)
|
128
|
+
return 0
|
132
129
|
else
|
133
|
-
|
130
|
+
return -1
|
134
131
|
end
|
135
132
|
`;
|
136
133
|
export const moveToDelayed = {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToDelayed-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToDelayed-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToDelayed-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToDelayed-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmIf,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -195,7 +195,6 @@ end
|
|
195
195
|
Events:
|
196
196
|
'waiting'
|
197
197
|
]]
|
198
|
-
local rcall = redis.call
|
199
198
|
-- Includes
|
200
199
|
--[[
|
201
200
|
Function to add job considering priority.
|
@@ -211,33 +210,20 @@ local function addJobWithPriority(priorityKey, priority, targetKey, jobId)
|
|
211
210
|
rcall("RPUSH", targetKey, jobId)
|
212
211
|
end
|
213
212
|
end
|
214
|
-
--[[
|
215
|
-
Function to check for the meta.paused key to decide if we are paused or not
|
216
|
-
(since an empty list and !EXISTS are not really the same).
|
217
|
-
]]
|
218
|
-
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
219
|
-
if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
|
220
|
-
return waitKey
|
221
|
-
else
|
222
|
-
return pausedKey
|
223
|
-
end
|
224
|
-
end
|
225
213
|
-- Try to get as much as 1000 jobs at once
|
226
|
-
local function promoteDelayedJobs(delayedKey,
|
227
|
-
|
214
|
+
local function promoteDelayedJobs(delayedKey, targetKey, priorityKey,
|
215
|
+
eventStreamKey, prefix, timestamp)
|
228
216
|
local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000, "LIMIT", 0, 1000)
|
229
217
|
if (#jobs > 0) then
|
230
218
|
rcall("ZREM", delayedKey, unpack(jobs))
|
231
|
-
-- check if we need to use push in paused instead of waiting
|
232
|
-
local target = getTargetQueueList(metaKey, waitKey, pausedKey)
|
233
219
|
for _, jobId in ipairs(jobs) do
|
234
220
|
local priority =
|
235
221
|
tonumber(rcall("HGET", prefix .. jobId, "priority")) or 0
|
236
222
|
if priority == 0 then
|
237
223
|
-- LIFO or FIFO
|
238
|
-
rcall("LPUSH",
|
224
|
+
rcall("LPUSH", targetKey, jobId)
|
239
225
|
else
|
240
|
-
addJobWithPriority(priorityKey, priority,
|
226
|
+
addJobWithPriority(priorityKey, priority, targetKey, jobId)
|
241
227
|
end
|
242
228
|
-- Emit waiting event
|
243
229
|
rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",
|
@@ -269,6 +255,17 @@ end
|
|
269
255
|
local getJobKeyPrefix = function (jobKey, jobId)
|
270
256
|
return string.sub(jobKey, 0, #jobKey - #jobId)
|
271
257
|
end
|
258
|
+
--[[
|
259
|
+
Function to check for the meta.paused key to decide if we are paused or not
|
260
|
+
(since an empty list and !EXISTS are not really the same).
|
261
|
+
]]
|
262
|
+
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
263
|
+
if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
|
264
|
+
return waitKey
|
265
|
+
else
|
266
|
+
return pausedKey
|
267
|
+
end
|
268
|
+
end
|
272
269
|
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
273
270
|
local parentTarget = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait", parentPrefix .. "paused")
|
274
271
|
rcall("RPUSH", parentTarget, parentId)
|
@@ -376,11 +373,11 @@ end
|
|
376
373
|
Add delay marker if needed.
|
377
374
|
]]
|
378
375
|
-- Includes
|
379
|
-
local function addDelayMarkerIfNeeded(
|
380
|
-
if rcall("LLEN",
|
376
|
+
local function addDelayMarkerIfNeeded(targetKey, delayedKey)
|
377
|
+
if rcall("LLEN", targetKey) == 0 then
|
381
378
|
local nextTimestamp = getNextDelayedTimestamp(delayedKey)
|
382
379
|
if nextTimestamp ~= nil then
|
383
|
-
rcall("LPUSH",
|
380
|
+
rcall("LPUSH", targetKey, "0:" .. nextTimestamp)
|
384
381
|
end
|
385
382
|
end
|
386
383
|
end
|
@@ -418,7 +415,7 @@ local function getRateLimitTTL(opts, limiterKey)
|
|
418
415
|
if jobCounter ~= nil and jobCounter >= maxJobs then
|
419
416
|
local pttl = rcall("PTTL", limiterKey)
|
420
417
|
if pttl > 0 then
|
421
|
-
return pttl
|
418
|
+
return pttl
|
422
419
|
end
|
423
420
|
end
|
424
421
|
end
|
@@ -526,8 +523,9 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
526
523
|
-- Try to get next job to avoid an extra roundtrip if the queue is not closing,
|
527
524
|
-- and not rate limited.
|
528
525
|
if (ARGV[7] == "1") then
|
526
|
+
local target = getTargetQueueList(KEYS[11], KEYS[1], KEYS[8])
|
529
527
|
-- Check if there are delayed jobs that can be promoted
|
530
|
-
promoteDelayedJobs(KEYS[7],
|
528
|
+
promoteDelayedJobs(KEYS[7], target, KEYS[3],
|
531
529
|
KEYS[4], ARGV[8], timestamp)
|
532
530
|
-- Check if we are rate limited first.
|
533
531
|
local pttl = getRateLimitTTL(opts, KEYS[6])
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToFinished-12.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-12.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToFinished-12.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-12.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkjBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -1,13 +1,13 @@
|
|
1
1
|
const content = `--[[
|
2
2
|
Pauses or resumes a queue globably.
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
Input:
|
4
|
+
KEYS[1] 'wait' or 'paused''
|
5
|
+
KEYS[2] 'paused' or 'wait'
|
6
|
+
KEYS[3] 'meta'
|
7
|
+
KEYS[4] events stream key
|
8
|
+
ARGV[1] 'paused' or 'resumed'
|
9
|
+
Event:
|
10
|
+
publish paused or resumed event.
|
11
11
|
]]
|
12
12
|
local rcall = redis.call
|
13
13
|
if rcall("EXISTS", KEYS[1]) == 1 then
|
@@ -1,6 +1,6 @@
|
|
1
1
|
const content = `--[[
|
2
2
|
Promotes a job that is currently "delayed" to the "waiting" state
|
3
|
-
|
3
|
+
Input:
|
4
4
|
KEYS[1] 'delayed'
|
5
5
|
KEYS[2] 'wait'
|
6
6
|
KEYS[3] 'paused'
|
@@ -9,10 +9,13 @@ const content = `--[[
|
|
9
9
|
KEYS[6] 'event stream'
|
10
10
|
ARGV[1] queue.toKey('')
|
11
11
|
ARGV[2] jobId
|
12
|
-
|
12
|
+
Output:
|
13
|
+
0 - OK
|
14
|
+
-3 - Job not in delayed zset.
|
15
|
+
Events:
|
13
16
|
'waiting'
|
14
17
|
]]
|
15
|
-
local rcall = redis.call
|
18
|
+
local rcall = redis.call
|
16
19
|
local jobId = ARGV[2]
|
17
20
|
-- Includes
|
18
21
|
--[[
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"promote-6.js","sourceRoot":"","sources":["../../../src/scripts/promote-6.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"promote-6.js","sourceRoot":"","sources":["../../../src/scripts/promote-6.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAmEZ,CAAC;AACL,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,SAAS;IACf,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"removeRepeatable-2.js","sourceRoot":"","sources":["../../../src/scripts/removeRepeatable-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"removeRepeatable-2.js","sourceRoot":"","sources":["../../../src/scripts/removeRepeatable-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Bf,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,kBAAkB;IACxB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -12,7 +12,7 @@ const content = `--[[
|
|
12
12
|
ARGV[3] propVal - failedReason/returnvalue
|
13
13
|
ARGV[4] prev state - failed/completed
|
14
14
|
Output:
|
15
|
-
|
15
|
+
1 means the operation was a success
|
16
16
|
-1 means the job does not exist
|
17
17
|
-3 means the job was not found in the expected set.
|
18
18
|
]]
|
@@ -40,7 +40,6 @@ end
|
|
40
40
|
Events:
|
41
41
|
'waiting'
|
42
42
|
]]
|
43
|
-
local rcall = redis.call
|
44
43
|
-- Includes
|
45
44
|
--[[
|
46
45
|
Function to add job considering priority.
|
@@ -57,21 +56,19 @@ local function addJobWithPriority(priorityKey, priority, targetKey, jobId)
|
|
57
56
|
end
|
58
57
|
end
|
59
58
|
-- Try to get as much as 1000 jobs at once
|
60
|
-
local function promoteDelayedJobs(delayedKey,
|
61
|
-
|
59
|
+
local function promoteDelayedJobs(delayedKey, targetKey, priorityKey,
|
60
|
+
eventStreamKey, prefix, timestamp)
|
62
61
|
local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000, "LIMIT", 0, 1000)
|
63
62
|
if (#jobs > 0) then
|
64
63
|
rcall("ZREM", delayedKey, unpack(jobs))
|
65
|
-
-- check if we need to use push in paused instead of waiting
|
66
|
-
local target = getTargetQueueList(metaKey, waitKey, pausedKey)
|
67
64
|
for _, jobId in ipairs(jobs) do
|
68
65
|
local priority =
|
69
66
|
tonumber(rcall("HGET", prefix .. jobId, "priority")) or 0
|
70
67
|
if priority == 0 then
|
71
68
|
-- LIFO or FIFO
|
72
|
-
rcall("LPUSH",
|
69
|
+
rcall("LPUSH", targetKey, jobId)
|
73
70
|
else
|
74
|
-
addJobWithPriority(priorityKey, priority,
|
71
|
+
addJobWithPriority(priorityKey, priority, targetKey, jobId)
|
75
72
|
end
|
76
73
|
-- Emit waiting event
|
77
74
|
rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",
|
@@ -80,7 +77,8 @@ local function promoteDelayedJobs(delayedKey, waitKey, priorityKey, pausedKey,
|
|
80
77
|
end
|
81
78
|
end
|
82
79
|
end
|
83
|
-
|
80
|
+
local target = getTargetQueueList(KEYS[5], KEYS[2], KEYS[3])
|
81
|
+
promoteDelayedJobs(KEYS[7], target, KEYS[8], KEYS[6], ARGV[1], ARGV[2])
|
84
82
|
if rcall("EXISTS", KEYS[4]) == 1 then
|
85
83
|
if ARGV[5] ~= "0" then
|
86
84
|
local lockKey = KEYS[4] .. ':lock'
|
@@ -90,11 +88,10 @@ if rcall("EXISTS", KEYS[4]) == 1 then
|
|
90
88
|
return -2
|
91
89
|
end
|
92
90
|
end
|
93
|
-
local target = getTargetQueueList(KEYS[5], KEYS[2], KEYS[3])
|
94
91
|
rcall("LREM", KEYS[1], 0, ARGV[4])
|
95
92
|
rcall(ARGV[3], target, ARGV[4])
|
96
93
|
-- Emit waiting event
|
97
|
-
rcall("XADD", KEYS[6], "*", "event", "waiting", "jobId", ARGV[4], "prev", "failed")
|
94
|
+
rcall("XADD", KEYS[6], "*", "event", "waiting", "jobId", ARGV[4], "prev", "failed")
|
98
95
|
return 0
|
99
96
|
else
|
100
97
|
return -1
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"retryJob-8.js","sourceRoot":"","sources":["../../../src/scripts/retryJob-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"retryJob-8.js","sourceRoot":"","sources":["../../../src/scripts/retryJob-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkGf,CAAC;AACF,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,UAAU;IAChB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"updateData-1.js","sourceRoot":"","sources":["../../../src/scripts/updateData-1.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"updateData-1.js","sourceRoot":"","sources":["../../../src/scripts/updateData-1.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;CAgBf,CAAC;AACF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"updateProgress-2.js","sourceRoot":"","sources":["../../../src/scripts/updateProgress-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"updateProgress-2.js","sourceRoot":"","sources":["../../../src/scripts/updateProgress-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;CAqBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|