bullmq 4.17.0 → 5.1.0
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 +3 -10
- package/dist/cjs/classes/flow-producer.js.map +1 -1
- package/dist/cjs/classes/job.js +21 -11
- package/dist/cjs/classes/job.js.map +1 -1
- package/dist/cjs/classes/queue-base.js +2 -9
- package/dist/cjs/classes/queue-base.js.map +1 -1
- package/dist/cjs/classes/queue-events.js +3 -1
- package/dist/cjs/classes/queue-events.js.map +1 -1
- package/dist/cjs/classes/queue-keys.js +1 -0
- package/dist/cjs/classes/queue-keys.js.map +1 -1
- package/dist/cjs/classes/queue.js +1 -1
- package/dist/cjs/classes/redis-connection.js +9 -7
- package/dist/cjs/classes/redis-connection.js.map +1 -1
- package/dist/cjs/classes/repeat.js +22 -5
- package/dist/cjs/classes/repeat.js.map +1 -1
- package/dist/cjs/classes/scripts.js +34 -34
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/classes/worker.js +27 -32
- package/dist/cjs/classes/worker.js.map +1 -1
- package/dist/cjs/commands/{addDelayedJob-7.lua → addDelayedJob-6.lua} +18 -22
- package/dist/cjs/commands/addParentJob-4.lua +0 -2
- package/dist/{esm/commands/addPrioritizedJob-8.lua → cjs/commands/addPrioritizedJob-7.lua} +18 -24
- package/dist/cjs/commands/{addStandardJob-6.lua → addStandardJob-7.lua} +6 -2
- package/dist/cjs/commands/changePriority-6.lua +57 -0
- package/dist/cjs/commands/getCounts-1.lua +1 -0
- package/dist/cjs/commands/getRanges-1.lua +1 -0
- package/dist/cjs/commands/includes/addDelayMarkerIfNeeded.lua +5 -19
- package/dist/cjs/commands/includes/addJobWithPriority.lua +3 -7
- package/dist/cjs/commands/includes/checkStalledJobs.lua +1 -1
- package/dist/cjs/commands/includes/isQueuePaused.lua +7 -0
- package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +39 -30
- package/dist/cjs/commands/includes/prepareJobForProcessing.lua +1 -1
- package/dist/cjs/commands/includes/promoteDelayedJobs.lua +7 -4
- package/dist/{esm/commands/moveToActive-10.lua → cjs/commands/moveToActive-11.lua} +18 -29
- package/dist/cjs/commands/moveToDelayed-7.lua +77 -0
- package/dist/cjs/commands/{moveToFinished-13.lua → moveToFinished-14.lua} +29 -22
- package/dist/cjs/commands/moveToWaitingChildren-4.lua +7 -4
- package/dist/cjs/commands/pause-7.lua +41 -0
- package/dist/cjs/commands/promote-8.lua +60 -0
- package/dist/cjs/commands/{retryJob-9.lua → retryJob-10.lua} +16 -11
- package/dist/cjs/scripts/{addDelayedJob-7.js → addDelayedJob-6.js} +77 -88
- package/dist/cjs/scripts/{moveToActive-10.js.map → addDelayedJob-6.js.map} +1 -1
- package/dist/cjs/scripts/addParentJob-4.js +51 -61
- package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
- package/dist/cjs/scripts/{addPrioritizedJob-8.js → addPrioritizedJob-7.js} +80 -93
- package/dist/cjs/scripts/addPrioritizedJob-7.js.map +1 -0
- package/dist/cjs/scripts/{addStandardJob-6.js → addStandardJob-7.js} +58 -63
- package/dist/cjs/scripts/addStandardJob-7.js.map +1 -0
- package/dist/cjs/scripts/changePriority-6.js +85 -0
- package/dist/cjs/scripts/changePriority-6.js.map +1 -0
- package/dist/cjs/scripts/getCounts-1.js +1 -0
- package/dist/cjs/scripts/getCounts-1.js.map +1 -1
- package/dist/cjs/scripts/getRanges-1.js +1 -0
- package/dist/cjs/scripts/getRanges-1.js.map +1 -1
- package/dist/cjs/scripts/index.js +10 -10
- package/dist/cjs/scripts/index.js.map +1 -1
- package/dist/cjs/scripts/moveStalledJobsToWait-8.js +1 -0
- package/dist/cjs/scripts/moveStalledJobsToWait-8.js.map +1 -1
- package/dist/cjs/scripts/{moveToActive-10.js → moveToActive-11.js} +30 -48
- package/dist/cjs/scripts/moveToActive-11.js.map +1 -0
- package/dist/cjs/scripts/moveToDelayed-7.js +103 -0
- package/dist/cjs/scripts/moveToDelayed-7.js.map +1 -0
- package/dist/cjs/scripts/{moveToFinished-13.js → moveToFinished-14.js} +89 -88
- package/dist/cjs/scripts/{moveToFinished-13.js.map → moveToFinished-14.js.map} +1 -1
- package/dist/cjs/scripts/moveToWaitingChildren-4.js +6 -3
- package/dist/cjs/scripts/moveToWaitingChildren-4.js.map +1 -1
- package/dist/cjs/scripts/pause-7.js +67 -0
- package/dist/cjs/scripts/pause-7.js.map +1 -0
- package/dist/cjs/scripts/promote-8.js +79 -0
- package/dist/cjs/scripts/promote-8.js.map +1 -0
- package/dist/cjs/scripts/{retryJob-9.js → retryJob-10.js} +26 -32
- package/dist/cjs/scripts/retryJob-10.js.map +1 -0
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/esm/classes/flow-producer.js +3 -10
- package/dist/esm/classes/flow-producer.js.map +1 -1
- package/dist/esm/classes/job.d.ts +5 -0
- package/dist/esm/classes/job.js +21 -11
- package/dist/esm/classes/job.js.map +1 -1
- package/dist/esm/classes/queue-base.js +2 -9
- package/dist/esm/classes/queue-base.js.map +1 -1
- package/dist/esm/classes/queue-events.js +3 -1
- package/dist/esm/classes/queue-events.js.map +1 -1
- package/dist/esm/classes/queue-keys.js +1 -0
- package/dist/esm/classes/queue-keys.js.map +1 -1
- package/dist/esm/classes/queue.d.ts +1 -1
- package/dist/esm/classes/queue.js +1 -1
- package/dist/esm/classes/redis-connection.js +9 -7
- package/dist/esm/classes/redis-connection.js.map +1 -1
- package/dist/esm/classes/repeat.js +22 -5
- package/dist/esm/classes/repeat.js.map +1 -1
- package/dist/esm/classes/scripts.d.ts +4 -4
- package/dist/esm/classes/scripts.js +34 -34
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/classes/worker.d.ts +1 -1
- package/dist/esm/classes/worker.js +27 -32
- package/dist/esm/classes/worker.js.map +1 -1
- package/dist/esm/commands/{addDelayedJob-7.lua → addDelayedJob-6.lua} +18 -22
- package/dist/esm/commands/addParentJob-4.lua +0 -2
- package/dist/{cjs/commands/addPrioritizedJob-8.lua → esm/commands/addPrioritizedJob-7.lua} +18 -24
- package/dist/esm/commands/{addStandardJob-6.lua → addStandardJob-7.lua} +6 -2
- package/dist/esm/commands/changePriority-6.lua +57 -0
- package/dist/esm/commands/getCounts-1.lua +1 -0
- package/dist/esm/commands/getRanges-1.lua +1 -0
- package/dist/esm/commands/includes/addDelayMarkerIfNeeded.lua +5 -19
- package/dist/esm/commands/includes/addJobWithPriority.lua +3 -7
- package/dist/esm/commands/includes/checkStalledJobs.lua +1 -1
- package/dist/esm/commands/includes/isQueuePaused.lua +7 -0
- package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +39 -30
- package/dist/esm/commands/includes/prepareJobForProcessing.lua +1 -1
- package/dist/esm/commands/includes/promoteDelayedJobs.lua +7 -4
- package/dist/{cjs/commands/moveToActive-10.lua → esm/commands/moveToActive-11.lua} +18 -29
- package/dist/esm/commands/moveToDelayed-7.lua +77 -0
- package/dist/esm/commands/{moveToFinished-13.lua → moveToFinished-14.lua} +29 -22
- package/dist/esm/commands/moveToWaitingChildren-4.lua +7 -4
- package/dist/esm/commands/pause-7.lua +41 -0
- package/dist/esm/commands/promote-8.lua +60 -0
- package/dist/esm/commands/{retryJob-9.lua → retryJob-10.lua} +16 -11
- package/dist/esm/interfaces/job-json.d.ts +4 -1
- package/dist/esm/interfaces/minimal-job.d.ts +3 -0
- package/dist/esm/interfaces/queue-options.d.ts +1 -1
- package/dist/esm/interfaces/repeat-options.d.ts +7 -0
- package/dist/esm/scripts/{addDelayedJob-7.js → addDelayedJob-6.js} +77 -88
- package/dist/esm/scripts/{moveToActive-10.js.map → addDelayedJob-6.js.map} +1 -1
- package/dist/esm/scripts/addParentJob-4.js +51 -61
- package/dist/esm/scripts/addParentJob-4.js.map +1 -1
- package/dist/esm/scripts/{addPrioritizedJob-8.js → addPrioritizedJob-7.js} +80 -93
- package/dist/esm/scripts/addPrioritizedJob-7.js.map +1 -0
- package/dist/esm/scripts/{addStandardJob-6.js → addStandardJob-7.js} +58 -63
- package/dist/esm/scripts/addStandardJob-7.js.map +1 -0
- package/dist/esm/scripts/changePriority-6.js +82 -0
- package/dist/esm/scripts/changePriority-6.js.map +1 -0
- package/dist/esm/scripts/getCounts-1.js +1 -0
- package/dist/esm/scripts/getCounts-1.js.map +1 -1
- package/dist/esm/scripts/getRanges-1.js +1 -0
- package/dist/esm/scripts/getRanges-1.js.map +1 -1
- package/dist/esm/scripts/index.d.ts +10 -10
- package/dist/esm/scripts/index.js +10 -10
- package/dist/esm/scripts/index.js.map +1 -1
- package/dist/esm/scripts/moveStalledJobsToWait-8.js +1 -0
- package/dist/esm/scripts/moveStalledJobsToWait-8.js.map +1 -1
- package/dist/esm/scripts/{moveToActive-10.js → moveToActive-11.js} +30 -48
- package/dist/esm/scripts/moveToActive-11.js.map +1 -0
- package/dist/esm/scripts/moveToDelayed-7.js +100 -0
- package/dist/esm/scripts/moveToDelayed-7.js.map +1 -0
- package/dist/esm/scripts/{moveToFinished-13.js → moveToFinished-14.js} +89 -88
- package/dist/esm/scripts/{moveToFinished-13.js.map → moveToFinished-14.js.map} +1 -1
- package/dist/esm/scripts/moveToWaitingChildren-4.js +6 -3
- package/dist/esm/scripts/moveToWaitingChildren-4.js.map +1 -1
- package/dist/esm/scripts/pause-7.js +64 -0
- package/dist/esm/scripts/pause-7.js.map +1 -0
- package/dist/esm/scripts/promote-8.js +76 -0
- package/dist/esm/scripts/promote-8.js.map +1 -0
- package/dist/esm/scripts/{retryJob-9.js → retryJob-10.js} +26 -32
- package/dist/esm/scripts/retryJob-10.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/dist/cjs/commands/changePriority-5.lua +0 -52
- package/dist/cjs/commands/includes/addPriorityMarkerIfNeeded.lua +0 -12
- package/dist/cjs/commands/moveToDelayed-8.lua +0 -72
- package/dist/cjs/commands/pause-5.lua +0 -36
- package/dist/cjs/commands/promote-7.lua +0 -57
- package/dist/cjs/scripts/addDelayedJob-7.js.map +0 -1
- package/dist/cjs/scripts/addPrioritizedJob-8.js.map +0 -1
- package/dist/cjs/scripts/addStandardJob-6.js.map +0 -1
- package/dist/cjs/scripts/changePriority-5.js +0 -87
- package/dist/cjs/scripts/changePriority-5.js.map +0 -1
- package/dist/cjs/scripts/moveToDelayed-8.js +0 -168
- package/dist/cjs/scripts/moveToDelayed-8.js.map +0 -1
- package/dist/cjs/scripts/pause-5.js +0 -48
- package/dist/cjs/scripts/pause-5.js.map +0 -1
- package/dist/cjs/scripts/promote-7.js +0 -87
- package/dist/cjs/scripts/promote-7.js.map +0 -1
- package/dist/cjs/scripts/retryJob-9.js.map +0 -1
- package/dist/esm/commands/changePriority-5.lua +0 -52
- package/dist/esm/commands/includes/addPriorityMarkerIfNeeded.lua +0 -12
- package/dist/esm/commands/moveToDelayed-8.lua +0 -72
- package/dist/esm/commands/pause-5.lua +0 -36
- package/dist/esm/commands/promote-7.lua +0 -57
- package/dist/esm/scripts/addDelayedJob-7.js.map +0 -1
- package/dist/esm/scripts/addPrioritizedJob-8.js.map +0 -1
- package/dist/esm/scripts/addStandardJob-6.js.map +0 -1
- package/dist/esm/scripts/changePriority-5.js +0 -84
- package/dist/esm/scripts/changePriority-5.js.map +0 -1
- package/dist/esm/scripts/moveToDelayed-8.js +0 -165
- package/dist/esm/scripts/moveToDelayed-8.js.map +0 -1
- package/dist/esm/scripts/pause-5.js +0 -45
- package/dist/esm/scripts/pause-5.js.map +0 -1
- package/dist/esm/scripts/promote-7.js +0 -84
- package/dist/esm/scripts/promote-7.js.map +0 -1
- package/dist/esm/scripts/retryJob-9.js.map +0 -1
- /package/dist/esm/scripts/{addDelayedJob-7.d.ts → addDelayedJob-6.d.ts} +0 -0
- /package/dist/esm/scripts/{addPrioritizedJob-8.d.ts → addPrioritizedJob-7.d.ts} +0 -0
- /package/dist/esm/scripts/{addStandardJob-6.d.ts → addStandardJob-7.d.ts} +0 -0
- /package/dist/esm/scripts/{changePriority-5.d.ts → changePriority-6.d.ts} +0 -0
- /package/dist/esm/scripts/{moveToActive-10.d.ts → moveToActive-11.d.ts} +0 -0
- /package/dist/esm/scripts/{moveToDelayed-8.d.ts → moveToDelayed-7.d.ts} +0 -0
- /package/dist/esm/scripts/{moveToFinished-13.d.ts → moveToFinished-14.d.ts} +0 -0
- /package/dist/esm/scripts/{pause-5.d.ts → pause-7.d.ts} +0 -0
- /package/dist/esm/scripts/{promote-7.d.ts → promote-8.d.ts} +0 -0
- /package/dist/esm/scripts/{retryJob-9.d.ts → retryJob-10.d.ts} +0 -0
@@ -13,15 +13,16 @@ const content = `--[[
|
|
13
13
|
-- Rate limiting
|
14
14
|
KEYS[6] rate limiter key
|
15
15
|
KEYS[7] delayed key
|
16
|
-
--
|
16
|
+
-- Delayed jobs
|
17
17
|
KEYS[8] paused key
|
18
18
|
KEYS[9] meta key
|
19
19
|
KEYS[10] pc priority counter
|
20
|
+
-- Marker
|
21
|
+
KEYS[11] marker key
|
20
22
|
-- Arguments
|
21
23
|
ARGV[1] key prefix
|
22
24
|
ARGV[2] timestamp
|
23
|
-
ARGV[3]
|
24
|
-
ARGV[4] opts
|
25
|
+
ARGV[3] opts
|
25
26
|
opts - token - lock token
|
26
27
|
opts - lockDuration
|
27
28
|
opts - limiter
|
@@ -31,7 +32,7 @@ local waitKey = KEYS[1]
|
|
31
32
|
local activeKey = KEYS[2]
|
32
33
|
local rateLimiterKey = KEYS[6]
|
33
34
|
local delayedKey = KEYS[7]
|
34
|
-
local opts = cmsgpack.unpack(ARGV[
|
35
|
+
local opts = cmsgpack.unpack(ARGV[3])
|
35
36
|
-- Includes
|
36
37
|
--[[
|
37
38
|
Function to return the next delayed job timestamp.
|
@@ -142,7 +143,7 @@ local function prepareJobForProcessing(keys, keyPrefix, targetKey, jobId, proces
|
|
142
143
|
end
|
143
144
|
rcall("XADD", keys[4], "*", "event", "active", "jobId", jobId, "prev", "waiting")
|
144
145
|
rcall("HSET", jobKey, "processedOn", processedOn)
|
145
|
-
rcall("HINCRBY", jobKey, "
|
146
|
+
rcall("HINCRBY", jobKey, "ats", 1)
|
146
147
|
return {rcall("HGETALL", jobKey), jobId, 0, 0} -- get job data
|
147
148
|
end
|
148
149
|
--[[
|
@@ -155,29 +156,17 @@ end
|
|
155
156
|
--[[
|
156
157
|
Function to add job considering priority.
|
157
158
|
]]
|
158
|
-
|
159
|
-
--[[
|
160
|
-
Function priority marker to wait if needed
|
161
|
-
in order to wake up our workers and to respect priority
|
162
|
-
order as much as possible
|
163
|
-
]]
|
164
|
-
local function addPriorityMarkerIfNeeded(waitKey)
|
165
|
-
local waitLen = rcall("LLEN", waitKey)
|
166
|
-
if waitLen == 0 then
|
167
|
-
rcall("LPUSH", waitKey, "0:0")
|
168
|
-
end
|
169
|
-
end
|
170
|
-
local function addJobWithPriority(waitKey, prioritizedKey, priority, paused, jobId, priorityCounterKey)
|
159
|
+
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
|
171
160
|
local prioCounter = rcall("INCR", priorityCounterKey)
|
172
161
|
local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
|
173
162
|
rcall("ZADD", prioritizedKey, score, jobId)
|
174
|
-
if not
|
175
|
-
|
163
|
+
if not isPaused then
|
164
|
+
rcall("ZADD", markerKey, 0, "0")
|
176
165
|
end
|
177
166
|
end
|
178
167
|
-- Try to get as much as 1000 jobs at once
|
179
|
-
local function promoteDelayedJobs(delayedKey,
|
180
|
-
eventStreamKey, prefix, timestamp,
|
168
|
+
local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,
|
169
|
+
eventStreamKey, prefix, timestamp, priorityCounterKey, isPaused)
|
181
170
|
local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000, "LIMIT", 0, 1000)
|
182
171
|
if (#jobs > 0) then
|
183
172
|
rcall("ZREM", delayedKey, unpack(jobs))
|
@@ -188,9 +177,12 @@ local function promoteDelayedJobs(delayedKey, waitKey, targetKey, prioritizedKey
|
|
188
177
|
if priority == 0 then
|
189
178
|
-- LIFO or FIFO
|
190
179
|
rcall("LPUSH", targetKey, jobId)
|
180
|
+
if not isPaused then
|
181
|
+
rcall("ZADD", markerKey, 0, "0")
|
182
|
+
end
|
191
183
|
else
|
192
|
-
addJobWithPriority(
|
193
|
-
jobId, priorityCounterKey)
|
184
|
+
addJobWithPriority(markerKey, prioritizedKey, priority,
|
185
|
+
jobId, priorityCounterKey, isPaused)
|
194
186
|
end
|
195
187
|
-- Emit waiting event
|
196
188
|
rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",
|
@@ -201,31 +193,21 @@ local function promoteDelayedJobs(delayedKey, waitKey, targetKey, prioritizedKey
|
|
201
193
|
end
|
202
194
|
local target, paused = getTargetQueueList(KEYS[9], waitKey, KEYS[8])
|
203
195
|
-- Check if there are delayed jobs that we can move to wait.
|
204
|
-
|
205
|
-
|
196
|
+
local markerKey = KEYS[11]
|
197
|
+
promoteDelayedJobs(delayedKey, markerKey, target, KEYS[3], KEYS[4], ARGV[1],
|
198
|
+
ARGV[2], KEYS[10], paused)
|
206
199
|
local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
|
207
200
|
local expireTime = getRateLimitTTL(maxJobs, rateLimiterKey)
|
208
|
-
|
209
|
-
if
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
-- Check if we are rate limited first.
|
218
|
-
if expireTime > 0 then return {0, 0, expireTime, 0} end
|
219
|
-
-- paused queue
|
220
|
-
if paused then return {0, 0, 0, 0} end
|
221
|
-
-- no job ID, try non-blocking move from wait to active
|
201
|
+
-- Check if we are rate limited first.
|
202
|
+
if expireTime > 0 then return {0, 0, expireTime, 0} end
|
203
|
+
-- paused queue
|
204
|
+
if paused then return {0, 0, 0, 0} end
|
205
|
+
-- no job ID, try non-blocking move from wait to active
|
206
|
+
local jobId = rcall("RPOPLPUSH", waitKey, activeKey)
|
207
|
+
-- Markers in waitlist DEPRECATED in v5: Will be completely removed in v6.
|
208
|
+
if jobId and string.sub(jobId, 1, 2) == "0:" then
|
209
|
+
rcall("LREM", activeKey, 1, jobId)
|
222
210
|
jobId = rcall("RPOPLPUSH", waitKey, activeKey)
|
223
|
-
-- Since it is possible that between a call to BRPOPLPUSH and moveToActive
|
224
|
-
-- another script puts a new maker in wait, we need to check again.
|
225
|
-
if jobId and string.sub(jobId, 1, 2) == "0:" then
|
226
|
-
rcall("LREM", activeKey, 1, jobId)
|
227
|
-
jobId = rcall("RPOPLPUSH", waitKey, activeKey)
|
228
|
-
end
|
229
211
|
end
|
230
212
|
if jobId then
|
231
213
|
return prepareJobForProcessing(KEYS, ARGV[1], target, jobId, ARGV[2],
|
@@ -245,6 +227,6 @@ return {0, 0, 0, 0}
|
|
245
227
|
export const moveToActive = {
|
246
228
|
name: 'moveToActive',
|
247
229
|
content,
|
248
|
-
keys:
|
230
|
+
keys: 11,
|
249
231
|
};
|
250
|
-
//# sourceMappingURL=moveToActive-
|
232
|
+
//# sourceMappingURL=moveToActive-11.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"moveToActive-11.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-11.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiOf,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -0,0 +1,100 @@
|
|
1
|
+
const content = `--[[
|
2
|
+
Moves job from active to delayed set.
|
3
|
+
Input:
|
4
|
+
KEYS[1] marker key
|
5
|
+
KEYS[2] active key
|
6
|
+
KEYS[3] prioritized key
|
7
|
+
KEYS[4] delayed key
|
8
|
+
KEYS[5] job key
|
9
|
+
KEYS[6] events stream
|
10
|
+
KEYS[7] meta key
|
11
|
+
ARGV[1] key prefix
|
12
|
+
ARGV[2] timestamp
|
13
|
+
ARGV[3] delayedTimestamp
|
14
|
+
ARGV[4] the id of the job
|
15
|
+
ARGV[5] queue token
|
16
|
+
ARGV[6] delay value
|
17
|
+
ARGV[7] skip attempt
|
18
|
+
Output:
|
19
|
+
0 - OK
|
20
|
+
-1 - Missing job.
|
21
|
+
-3 - Job not in active set.
|
22
|
+
Events:
|
23
|
+
- delayed key.
|
24
|
+
]]
|
25
|
+
local rcall = redis.call
|
26
|
+
-- Includes
|
27
|
+
--[[
|
28
|
+
Add delay marker if needed.
|
29
|
+
]]
|
30
|
+
-- Includes
|
31
|
+
--[[
|
32
|
+
Function to return the next delayed job timestamp.
|
33
|
+
]]
|
34
|
+
local function getNextDelayedTimestamp(delayedKey)
|
35
|
+
local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
|
36
|
+
if #result then
|
37
|
+
local nextTimestamp = tonumber(result[2])
|
38
|
+
if (nextTimestamp ~= nil) then
|
39
|
+
nextTimestamp = nextTimestamp / 0x1000
|
40
|
+
end
|
41
|
+
return nextTimestamp
|
42
|
+
end
|
43
|
+
end
|
44
|
+
local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
45
|
+
local nextTimestamp = getNextDelayedTimestamp(delayedKey)
|
46
|
+
if nextTimestamp ~= nil then
|
47
|
+
-- Replace the score of the marker with the newest known
|
48
|
+
-- next timestamp.
|
49
|
+
rcall("ZADD", markerKey, nextTimestamp, "0")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
--[[
|
53
|
+
Function to check for the meta.paused key to decide if we are paused or not
|
54
|
+
(since an empty list and !EXISTS are not really the same).
|
55
|
+
]]
|
56
|
+
local function isQueuePaused(queueMetaKey)
|
57
|
+
return rcall("HEXISTS", queueMetaKey, "paused") == 1
|
58
|
+
end
|
59
|
+
local jobKey = KEYS[5]
|
60
|
+
local metaKey = KEYS[7]
|
61
|
+
if rcall("EXISTS", jobKey) == 1 then
|
62
|
+
local delayedKey = KEYS[4]
|
63
|
+
if ARGV[5] ~= "0" then
|
64
|
+
local lockKey = jobKey .. ':lock'
|
65
|
+
if rcall("GET", lockKey) == ARGV[5] then
|
66
|
+
rcall("DEL", lockKey)
|
67
|
+
else
|
68
|
+
return -2
|
69
|
+
end
|
70
|
+
end
|
71
|
+
local jobId = ARGV[4]
|
72
|
+
local score = tonumber(ARGV[3])
|
73
|
+
local delayedTimestamp = (score / 0x1000)
|
74
|
+
local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)
|
75
|
+
if numRemovedElements < 1 then return -3 end
|
76
|
+
if ARGV[7] == "0" then
|
77
|
+
rcall("HINCRBY", jobKey, "atm", 1)
|
78
|
+
end
|
79
|
+
rcall("HSET", jobKey, "delay", ARGV[6])
|
80
|
+
local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents") or 10000
|
81
|
+
rcall("ZADD", delayedKey, score, jobId)
|
82
|
+
rcall("XADD", KEYS[6], "MAXLEN", "~", maxEvents, "*", "event", "delayed",
|
83
|
+
"jobId", jobId, "delay", delayedTimestamp)
|
84
|
+
-- Check if we need to push a marker job to wake up sleeping workers.
|
85
|
+
local isPaused = isQueuePaused(metaKey)
|
86
|
+
if not isPaused then
|
87
|
+
local markerKey = KEYS[1]
|
88
|
+
addDelayMarkerIfNeeded(markerKey, delayedKey)
|
89
|
+
end
|
90
|
+
return 0
|
91
|
+
else
|
92
|
+
return -1
|
93
|
+
end
|
94
|
+
`;
|
95
|
+
export const moveToDelayed = {
|
96
|
+
name: 'moveToDelayed',
|
97
|
+
content,
|
98
|
+
keys: 7,
|
99
|
+
};
|
100
|
+
//# sourceMappingURL=moveToDelayed-7.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"moveToDelayed-7.js","sourceRoot":"","sources":["../../../src/scripts/moveToDelayed-7.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Ff,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -18,20 +18,19 @@ const content = `--[[
|
|
18
18
|
KEYS[11] completed/failed key
|
19
19
|
KEYS[12] jobId key
|
20
20
|
KEYS[13] metrics key
|
21
|
+
KEYS[14] marker key
|
21
22
|
ARGV[1] jobId
|
22
23
|
ARGV[2] timestamp
|
23
24
|
ARGV[3] msg property returnvalue / failedReason
|
24
25
|
ARGV[4] return value / failed reason
|
25
26
|
ARGV[5] target (completed/failed)
|
26
|
-
ARGV[6]
|
27
|
-
ARGV[7]
|
28
|
-
ARGV[8]
|
29
|
-
ARGV[9] opts
|
27
|
+
ARGV[6] fetch next?
|
28
|
+
ARGV[7] keys prefix
|
29
|
+
ARGV[8] opts
|
30
30
|
opts - token - lock token
|
31
31
|
opts - keepJobs
|
32
32
|
opts - lockDuration - lock duration in milliseconds
|
33
33
|
opts - attempts max attempts
|
34
|
-
opts - attemptsMade
|
35
34
|
opts - maxMetricsSize
|
36
35
|
opts - fpof - fail parent on fail
|
37
36
|
opts - rdof - remove dependency on fail
|
@@ -187,7 +186,7 @@ local function prepareJobForProcessing(keys, keyPrefix, targetKey, jobId, proces
|
|
187
186
|
end
|
188
187
|
rcall("XADD", keys[4], "*", "event", "active", "jobId", jobId, "prev", "waiting")
|
189
188
|
rcall("HSET", jobKey, "processedOn", processedOn)
|
190
|
-
rcall("HINCRBY", jobKey, "
|
189
|
+
rcall("HINCRBY", jobKey, "ats", 1)
|
191
190
|
return {rcall("HGETALL", jobKey), jobId, 0, 0} -- get job data
|
192
191
|
end
|
193
192
|
--[[
|
@@ -200,49 +199,32 @@ end
|
|
200
199
|
-- Includes
|
201
200
|
--[[
|
202
201
|
Add delay marker if needed.
|
203
|
-
]]
|
202
|
+
]]
|
204
203
|
-- Includes
|
205
|
-
local function addDelayMarkerIfNeeded(
|
206
|
-
local waitLen = rcall("LLEN", targetKey)
|
207
|
-
if waitLen <= 1 then
|
204
|
+
local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
208
205
|
local nextTimestamp = getNextDelayedTimestamp(delayedKey)
|
209
206
|
if nextTimestamp ~= nil then
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
local marker = rcall("LINDEX", targetKey, 0)
|
214
|
-
local oldTimestamp = tonumber(marker:sub(3))
|
215
|
-
if oldTimestamp and oldTimestamp > nextTimestamp then
|
216
|
-
rcall("LSET", targetKey, 0, "0:" .. nextTimestamp)
|
217
|
-
end
|
218
|
-
else
|
219
|
-
-- if there is no marker, then we need to add one
|
220
|
-
rcall("LPUSH", targetKey, "0:" .. nextTimestamp)
|
221
|
-
end
|
207
|
+
-- Replace the score of the marker with the newest known
|
208
|
+
-- next timestamp.
|
209
|
+
rcall("ZADD", markerKey, nextTimestamp, "0")
|
222
210
|
end
|
223
|
-
end
|
224
211
|
end
|
225
212
|
--[[
|
226
|
-
Function to
|
213
|
+
Function to check for the meta.paused key to decide if we are paused or not
|
214
|
+
(since an empty list and !EXISTS are not really the same).
|
227
215
|
]]
|
228
|
-
|
216
|
+
local function isQueuePaused(queueMetaKey)
|
217
|
+
return rcall("HEXISTS", queueMetaKey, "paused") == 1
|
218
|
+
end
|
229
219
|
--[[
|
230
|
-
Function
|
231
|
-
in order to wake up our workers and to respect priority
|
232
|
-
order as much as possible
|
220
|
+
Function to add job considering priority.
|
233
221
|
]]
|
234
|
-
local function
|
235
|
-
local waitLen = rcall("LLEN", waitKey)
|
236
|
-
if waitLen == 0 then
|
237
|
-
rcall("LPUSH", waitKey, "0:0")
|
238
|
-
end
|
239
|
-
end
|
240
|
-
local function addJobWithPriority(waitKey, prioritizedKey, priority, paused, jobId, priorityCounterKey)
|
222
|
+
local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
|
241
223
|
local prioCounter = rcall("INCR", priorityCounterKey)
|
242
224
|
local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
|
243
225
|
rcall("ZADD", prioritizedKey, score, jobId)
|
244
|
-
if not
|
245
|
-
|
226
|
+
if not isPaused then
|
227
|
+
rcall("ZADD", markerKey, 0, "0")
|
246
228
|
end
|
247
229
|
end
|
248
230
|
--[[
|
@@ -256,35 +238,44 @@ local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
|
|
256
238
|
return pausedKey, true
|
257
239
|
end
|
258
240
|
end
|
259
|
-
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
241
|
+
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
242
|
+
parentKey, parentId, timestamp)
|
243
|
+
local isParentActive = rcall("ZSCORE",
|
244
|
+
parentQueueKey .. ":waiting-children", parentId)
|
245
|
+
if rcall("SCARD", parentDependenciesKey) == 0 and isParentActive then
|
246
|
+
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
247
|
+
local parentWaitKey = parentQueueKey .. ":wait"
|
248
|
+
local parentPausedKey = parentQueueKey .. ":paused"
|
249
|
+
local parentMetaKey = parentQueueKey .. ":meta"
|
250
|
+
local parentMarkerKey = parentQueueKey .. ":marker"
|
251
|
+
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
252
|
+
local priority = tonumber(jobAttributes[1]) or 0
|
253
|
+
local delay = tonumber(jobAttributes[2]) or 0
|
254
|
+
if delay > 0 then
|
255
|
+
local delayedTimestamp = tonumber(timestamp) + delay
|
256
|
+
local score = delayedTimestamp * 0x1000
|
257
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
258
|
+
rcall("ZADD", parentDelayedKey, score, parentId)
|
259
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed",
|
260
|
+
"jobId", parentId, "delay", delayedTimestamp)
|
261
|
+
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
262
|
+
else
|
263
|
+
if priority == 0 then
|
264
|
+
local parentTarget, _paused =
|
265
|
+
getTargetQueueList(parentMetaKey, parentWaitKey,
|
266
|
+
parentPausedKey)
|
267
|
+
rcall("RPUSH", parentTarget, parentId)
|
268
|
+
rcall("ZADD", parentMarkerKey, 0, "0")
|
269
|
+
else
|
270
|
+
local isPaused = isQueuePaused(parentMetaKey)
|
271
|
+
addJobWithPriority(parentMarkerKey,
|
272
|
+
parentQueueKey .. ":prioritized", priority,
|
273
|
+
parentId, parentQueueKey .. ":pc", isPaused)
|
274
|
+
end
|
275
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
|
276
|
+
"jobId", parentId, "prev", "waiting-children")
|
277
|
+
end
|
286
278
|
end
|
287
|
-
end
|
288
279
|
end
|
289
280
|
local function moveParentFromWaitingChildrenToFailed( parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
290
281
|
if rcall("ZREM", parentQueueKey .. ":waiting-children", parentId) == 1 then
|
@@ -323,8 +314,8 @@ end
|
|
323
314
|
]]
|
324
315
|
-- Includes
|
325
316
|
-- Try to get as much as 1000 jobs at once
|
326
|
-
local function promoteDelayedJobs(delayedKey,
|
327
|
-
eventStreamKey, prefix, timestamp,
|
317
|
+
local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,
|
318
|
+
eventStreamKey, prefix, timestamp, priorityCounterKey, isPaused)
|
328
319
|
local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000, "LIMIT", 0, 1000)
|
329
320
|
if (#jobs > 0) then
|
330
321
|
rcall("ZREM", delayedKey, unpack(jobs))
|
@@ -335,9 +326,12 @@ local function promoteDelayedJobs(delayedKey, waitKey, targetKey, prioritizedKey
|
|
335
326
|
if priority == 0 then
|
336
327
|
-- LIFO or FIFO
|
337
328
|
rcall("LPUSH", targetKey, jobId)
|
329
|
+
if not isPaused then
|
330
|
+
rcall("ZADD", markerKey, 0, "0")
|
331
|
+
end
|
338
332
|
else
|
339
|
-
addJobWithPriority(
|
340
|
-
jobId, priorityCounterKey)
|
333
|
+
addJobWithPriority(markerKey, prioritizedKey, priority,
|
334
|
+
jobId, priorityCounterKey, isPaused)
|
341
335
|
end
|
342
336
|
-- Emit waiting event
|
343
337
|
rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",
|
@@ -492,10 +486,9 @@ local function getRateLimitTTL(maxJobs, rateLimiterKey)
|
|
492
486
|
end
|
493
487
|
local jobIdKey = KEYS[12]
|
494
488
|
if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
495
|
-
local opts = cmsgpack.unpack(ARGV[
|
489
|
+
local opts = cmsgpack.unpack(ARGV[8])
|
496
490
|
local token = opts['token']
|
497
491
|
local attempts = opts['attempts']
|
498
|
-
local attemptsMade = opts['attemptsMade']
|
499
492
|
local maxMetricsSize = opts['maxMetricsSize']
|
500
493
|
local maxCount = opts['keepJobs']['count']
|
501
494
|
local maxAge = opts['keepJobs']['age']
|
@@ -532,8 +525,9 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
532
525
|
-- Remove from active list (if not active we shall return error)
|
533
526
|
local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)
|
534
527
|
if (numRemovedElements < 1) then return -3 end
|
528
|
+
local metaKey = KEYS[9]
|
535
529
|
-- Trim events before emiting them to avoid trimming events emitted in this script
|
536
|
-
trimEvents(
|
530
|
+
trimEvents(metaKey, KEYS[4])
|
537
531
|
-- If job has a parent we need to
|
538
532
|
-- 1) remove this job id from parents dependencies
|
539
533
|
-- 2) move the job Id to parent "processed" set
|
@@ -554,16 +548,18 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
554
548
|
else
|
555
549
|
if opts['fpof'] then
|
556
550
|
moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
|
557
|
-
|
551
|
+
parentId, jobIdKey,
|
552
|
+
timestamp)
|
558
553
|
elseif opts['rdof'] then
|
559
554
|
local dependenciesSet = parentKey .. ":dependencies"
|
560
555
|
if rcall("SREM", dependenciesSet, jobIdKey) == 1 then
|
561
556
|
moveParentToWaitIfNeeded(parentQueueKey, dependenciesSet,
|
562
|
-
|
557
|
+
parentKey, parentId, timestamp)
|
563
558
|
end
|
564
559
|
end
|
565
560
|
end
|
566
561
|
end
|
562
|
+
local attemptsMade = rcall("HINCRBY", jobIdKey, "atm", 1)
|
567
563
|
-- Remove job?
|
568
564
|
if maxCount ~= 0 then
|
569
565
|
local targetSet = KEYS[11]
|
@@ -572,7 +568,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
572
568
|
rcall("HMSET", jobIdKey, ARGV[3], ARGV[4], "finishedOn", timestamp)
|
573
569
|
-- "returnvalue" / "failedReason" and "finishedOn"
|
574
570
|
-- Remove old jobs?
|
575
|
-
local prefix = ARGV[
|
571
|
+
local prefix = ARGV[7]
|
576
572
|
if maxAge ~= nil then
|
577
573
|
removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix)
|
578
574
|
end
|
@@ -599,11 +595,11 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
599
595
|
end
|
600
596
|
-- Try to get next job to avoid an extra roundtrip if the queue is not closing,
|
601
597
|
-- and not rate limited.
|
602
|
-
if (ARGV[
|
603
|
-
local target, paused = getTargetQueueList(
|
598
|
+
if (ARGV[6] == "1") then
|
599
|
+
local target, paused = getTargetQueueList(metaKey, KEYS[1], KEYS[8])
|
604
600
|
-- Check if there are delayed jobs that can be promoted
|
605
|
-
promoteDelayedJobs(KEYS[7], KEYS[
|
606
|
-
|
601
|
+
promoteDelayedJobs(KEYS[7], KEYS[14], target, KEYS[3], KEYS[4], ARGV[7],
|
602
|
+
timestamp, KEYS[10], paused)
|
607
603
|
local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
|
608
604
|
-- Check if we are rate limited first.
|
609
605
|
local expireTime = getRateLimitTTL(maxJobs, KEYS[6])
|
@@ -612,24 +608,29 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
612
608
|
if paused then return {0, 0, 0, 0} end
|
613
609
|
jobId = rcall("RPOPLPUSH", KEYS[1], KEYS[2])
|
614
610
|
if jobId then
|
611
|
+
-- Markers in waitlist DEPRECATED in v5: Remove in v6.
|
615
612
|
if string.sub(jobId, 1, 2) == "0:" then
|
616
613
|
rcall("LREM", KEYS[2], 1, jobId)
|
617
614
|
-- If jobId is special ID 0:delay (delay greater than 0), then there is no job to process
|
618
615
|
-- but if ID is 0:0, then there is at least 1 prioritized job to process
|
619
616
|
if jobId == "0:0" then
|
620
|
-
jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2],
|
621
|
-
|
622
|
-
|
617
|
+
jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2],
|
618
|
+
KEYS[10])
|
619
|
+
return prepareJobForProcessing(KEYS, ARGV[7], target, jobId,
|
620
|
+
timestamp, maxJobs,
|
621
|
+
expireTime, opts)
|
623
622
|
end
|
624
623
|
else
|
625
|
-
return prepareJobForProcessing(KEYS, ARGV[
|
626
|
-
|
624
|
+
return prepareJobForProcessing(KEYS, ARGV[7], target, jobId,
|
625
|
+
timestamp, maxJobs, expireTime,
|
626
|
+
opts)
|
627
627
|
end
|
628
628
|
else
|
629
629
|
jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2], KEYS[10])
|
630
630
|
if jobId then
|
631
|
-
return prepareJobForProcessing(KEYS, ARGV[
|
632
|
-
|
631
|
+
return prepareJobForProcessing(KEYS, ARGV[7], target, jobId,
|
632
|
+
timestamp, maxJobs, expireTime,
|
633
|
+
opts)
|
633
634
|
end
|
634
635
|
end
|
635
636
|
-- Return the timestamp for the next delayed job if any.
|
@@ -658,6 +659,6 @@ end
|
|
658
659
|
export const moveToFinished = {
|
659
660
|
name: 'moveToFinished',
|
660
661
|
content,
|
661
|
-
keys:
|
662
|
+
keys: 14,
|
662
663
|
};
|
663
|
-
//# sourceMappingURL=moveToFinished-
|
664
|
+
//# sourceMappingURL=moveToFinished-14.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToFinished-
|
1
|
+
{"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAipBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -17,7 +17,8 @@ const content = `--[[
|
|
17
17
|
-3 - Job not in active set
|
18
18
|
]]
|
19
19
|
local rcall = redis.call
|
20
|
-
local function moveToWaitingChildren (activeKey, waitingChildrenKey, jobId, timestamp,
|
20
|
+
local function moveToWaitingChildren (activeKey, waitingChildrenKey, jobId, timestamp,
|
21
|
+
lockKey, jobKey, token)
|
21
22
|
if token ~= "0" then
|
22
23
|
if rcall("GET", lockKey) == token then
|
23
24
|
rcall("DEL", lockKey)
|
@@ -36,12 +37,14 @@ end
|
|
36
37
|
if rcall("EXISTS", KEYS[4]) == 1 then
|
37
38
|
if ARGV[2] ~= "" then
|
38
39
|
if rcall("SISMEMBER", KEYS[4] .. ":dependencies", ARGV[2]) ~= 0 then
|
39
|
-
return moveToWaitingChildren(KEYS[2], KEYS[3], ARGV[4], ARGV[3], KEYS[1],
|
40
|
+
return moveToWaitingChildren(KEYS[2], KEYS[3], ARGV[4], ARGV[3], KEYS[1], KEYS[4],
|
41
|
+
ARGV[1])
|
40
42
|
end
|
41
43
|
return 1
|
42
44
|
else
|
43
45
|
if rcall("SCARD", KEYS[4] .. ":dependencies") ~= 0 then
|
44
|
-
return moveToWaitingChildren(KEYS[2], KEYS[3], ARGV[4], ARGV[3], KEYS[1],
|
46
|
+
return moveToWaitingChildren(KEYS[2], KEYS[3], ARGV[4], ARGV[3], KEYS[1], KEYS[4],
|
47
|
+
ARGV[1])
|
45
48
|
end
|
46
49
|
return 1
|
47
50
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToWaitingChildren-4.js","sourceRoot":"","sources":["../../../src/scripts/moveToWaitingChildren-4.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToWaitingChildren-4.js","sourceRoot":"","sources":["../../../src/scripts/moveToWaitingChildren-4.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDf,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|