bullmq 5.46.1 → 5.47.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/flow-producer.js +1 -1
- package/dist/cjs/classes/flow-producer.js.map +1 -1
- package/dist/cjs/classes/job.js +11 -9
- package/dist/cjs/classes/job.js.map +1 -1
- package/dist/cjs/classes/scripts.js +4 -3
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/classes/worker.js.map +1 -1
- package/dist/cjs/commands/includes/moveParentToFailedIfNeeded.lua +3 -0
- package/dist/cjs/commands/includes/moveParentToWait.lua +49 -0
- package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +6 -51
- package/dist/cjs/commands/includes/removeParentDependencyKey.lua +5 -5
- package/dist/cjs/commands/moveStalledJobsToWait-9.lua +26 -30
- package/dist/cjs/commands/moveToFinished-14.lua +38 -30
- package/dist/cjs/commands/moveToWaitingChildren-8.lua +13 -8
- package/dist/cjs/scripts/addDelayedJob-6.js +24 -20
- package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/cjs/scripts/addJobScheduler-11.js +5 -5
- package/dist/cjs/scripts/addParentJob-4.js +24 -20
- package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
- package/dist/cjs/scripts/addPrioritizedJob-8.js +24 -20
- package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -1
- package/dist/cjs/scripts/addRepeatableJob-2.js +5 -5
- package/dist/cjs/scripts/addStandardJob-8.js +24 -20
- package/dist/cjs/scripts/addStandardJob-8.js.map +1 -1
- package/dist/cjs/scripts/cleanJobsInSet-3.js +5 -5
- package/dist/cjs/scripts/drain-5.js +5 -5
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +56 -54
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +67 -55
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/moveToWaitingChildren-8.js +43 -33
- package/dist/cjs/scripts/moveToWaitingChildren-8.js.map +1 -1
- package/dist/cjs/scripts/obliterate-2.js +5 -5
- package/dist/cjs/scripts/removeChildDependency-1.js +5 -5
- package/dist/cjs/scripts/removeJob-3.js +5 -5
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/flow-producer.js +1 -1
- package/dist/esm/classes/flow-producer.js.map +1 -1
- package/dist/esm/classes/job.js +11 -9
- package/dist/esm/classes/job.js.map +1 -1
- package/dist/esm/classes/scripts.js +4 -3
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/classes/worker.js.map +1 -1
- package/dist/esm/commands/includes/moveParentToFailedIfNeeded.lua +3 -0
- package/dist/esm/commands/includes/moveParentToWait.lua +49 -0
- package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +6 -51
- package/dist/esm/commands/includes/removeParentDependencyKey.lua +5 -5
- package/dist/esm/commands/moveStalledJobsToWait-9.lua +26 -30
- package/dist/esm/commands/moveToFinished-14.lua +38 -30
- package/dist/esm/commands/moveToWaitingChildren-8.lua +13 -8
- package/dist/esm/scripts/addDelayedJob-6.js +24 -20
- package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/esm/scripts/addJobScheduler-11.js +5 -5
- package/dist/esm/scripts/addParentJob-4.js +24 -20
- package/dist/esm/scripts/addParentJob-4.js.map +1 -1
- package/dist/esm/scripts/addPrioritizedJob-8.js +24 -20
- package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -1
- package/dist/esm/scripts/addRepeatableJob-2.js +5 -5
- package/dist/esm/scripts/addStandardJob-8.js +24 -20
- package/dist/esm/scripts/addStandardJob-8.js.map +1 -1
- package/dist/esm/scripts/cleanJobsInSet-3.js +5 -5
- package/dist/esm/scripts/drain-5.js +5 -5
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +56 -54
- package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +67 -55
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/moveToWaitingChildren-8.js +43 -33
- package/dist/esm/scripts/moveToWaitingChildren-8.js.map +1 -1
- package/dist/esm/scripts/obliterate-2.js +5 -5
- package/dist/esm/scripts/removeChildDependency-1.js +5 -5
- package/dist/esm/scripts/removeJob-3.js +5 -5
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/types/job-options.d.ts +12 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
@@ -40,6 +40,7 @@
|
|
40
40
|
opts - attempts max attempts
|
41
41
|
opts - maxMetricsSize
|
42
42
|
opts - fpof - fail parent on fail
|
43
|
+
opts - cpof - continue parent on fail
|
43
44
|
opts - idof - ignore dependency on fail
|
44
45
|
opts - rdof - remove dependency on fail
|
45
46
|
opts - name - worker name
|
@@ -64,6 +65,7 @@ local rcall = redis.call
|
|
64
65
|
--- @include "includes/getTargetQueueList"
|
65
66
|
--- @include "includes/moveJobFromPriorityToActive"
|
66
67
|
--- @include "includes/moveParentToFailedIfNeeded"
|
68
|
+
--- @include "includes/moveParentToWait"
|
67
69
|
--- @include "includes/moveParentToWaitIfNeeded"
|
68
70
|
--- @include "includes/prepareJobForProcessing"
|
69
71
|
--- @include "includes/promoteDelayedJobs"
|
@@ -81,7 +83,9 @@ local jobIdKey = KEYS[12]
|
|
81
83
|
if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
82
84
|
-- Make sure it does not have pending dependencies
|
83
85
|
-- It must happen before removing lock
|
84
|
-
if ARGV[5] == "completed" and
|
86
|
+
if ARGV[5] == "completed" and
|
87
|
+
not rcall("HGET", jobIdKey, "igdp") and -- check if we should ignore this check
|
88
|
+
rcall("SCARD", jobIdKey .. ":dependencies") ~= 0 then
|
85
89
|
return -4
|
86
90
|
end
|
87
91
|
|
@@ -117,7 +121,9 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
117
121
|
-- Remove from active list (if not active we shall return error)
|
118
122
|
local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)
|
119
123
|
|
120
|
-
if (numRemovedElements < 1) then
|
124
|
+
if (numRemovedElements < 1) then
|
125
|
+
return -3
|
126
|
+
end
|
121
127
|
|
122
128
|
local eventStreamKey = KEYS[4]
|
123
129
|
local metaKey = KEYS[9]
|
@@ -142,22 +148,25 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
142
148
|
if ARGV[5] == "completed" then
|
143
149
|
local dependenciesSet = parentKey .. ":dependencies"
|
144
150
|
if rcall("SREM", dependenciesSet, jobIdKey) == 1 then
|
145
|
-
updateParentDepsIfNeeded(parentKey, parentQueueKey,
|
146
|
-
|
147
|
-
ARGV[4], timestamp)
|
151
|
+
updateParentDepsIfNeeded(parentKey, parentQueueKey, dependenciesSet, parentId, jobIdKey, ARGV[4],
|
152
|
+
timestamp)
|
148
153
|
end
|
149
154
|
else
|
150
|
-
if opts['fpof'] then
|
155
|
+
if opts['fpof'] or opts['cpof'] then
|
151
156
|
local unsuccesssfulSet = parentKey .. ":unsuccessful"
|
152
157
|
rcall("ZADD", unsuccesssfulSet, timestamp, jobIdKey)
|
153
|
-
|
154
|
-
|
155
|
-
|
158
|
+
|
159
|
+
if opts['fpof'] then
|
160
|
+
moveParentToFailedIfNeeded(parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
161
|
+
elseif opts['cpof'] then
|
162
|
+
local failedSet = parentKey .. ":failed"
|
163
|
+
rcall("HSET", failedSet, jobIdKey, ARGV[4])
|
164
|
+
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
165
|
+
end
|
156
166
|
elseif opts['idof'] or opts['rdof'] then
|
157
167
|
local dependenciesSet = parentKey .. ":dependencies"
|
158
168
|
if rcall("SREM", dependenciesSet, jobIdKey) == 1 then
|
159
|
-
moveParentToWaitIfNeeded(parentQueueKey, dependenciesSet,
|
160
|
-
parentKey, parentId, timestamp)
|
169
|
+
moveParentToWaitIfNeeded(parentQueueKey, dependenciesSet, parentKey, parentId, timestamp)
|
161
170
|
if opts['idof'] then
|
162
171
|
local failedSet = parentKey .. ":failed"
|
163
172
|
rcall("HSET", failedSet, jobIdKey, ARGV[4])
|
@@ -195,13 +204,12 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
195
204
|
end
|
196
205
|
end
|
197
206
|
|
198
|
-
rcall("XADD", eventStreamKey, "*", "event", ARGV[5], "jobId", jobId, ARGV[3],
|
199
|
-
ARGV[4], "prev", "active")
|
207
|
+
rcall("XADD", eventStreamKey, "*", "event", ARGV[5], "jobId", jobId, ARGV[3], ARGV[4], "prev", "active")
|
200
208
|
|
201
209
|
if ARGV[5] == "failed" then
|
202
210
|
if tonumber(attemptsMade) >= tonumber(attempts) then
|
203
|
-
rcall("XADD", eventStreamKey, "*", "event", "retries-exhausted", "jobId",
|
204
|
-
|
211
|
+
rcall("XADD", eventStreamKey, "*", "event", "retries-exhausted", "jobId", jobId, "attemptsMade",
|
212
|
+
attemptsMade)
|
205
213
|
end
|
206
214
|
end
|
207
215
|
|
@@ -218,17 +226,21 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
218
226
|
|
219
227
|
local markerKey = KEYS[14]
|
220
228
|
-- Check if there are delayed jobs that can be promoted
|
221
|
-
promoteDelayedJobs(KEYS[7], markerKey, target, KEYS[3], eventStreamKey, prefix,
|
222
|
-
|
229
|
+
promoteDelayedJobs(KEYS[7], markerKey, target, KEYS[3], eventStreamKey, prefix, timestamp, KEYS[10],
|
230
|
+
isPausedOrMaxed)
|
223
231
|
|
224
232
|
local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
|
225
233
|
-- Check if we are rate limited first.
|
226
234
|
local expireTime = getRateLimitTTL(maxJobs, KEYS[6])
|
227
235
|
|
228
|
-
if expireTime > 0 then
|
236
|
+
if expireTime > 0 then
|
237
|
+
return {0, 0, expireTime, 0}
|
238
|
+
end
|
229
239
|
|
230
240
|
-- paused or maxed queue
|
231
|
-
if isPausedOrMaxed then
|
241
|
+
if isPausedOrMaxed then
|
242
|
+
return {0, 0, 0, 0}
|
243
|
+
end
|
232
244
|
|
233
245
|
jobId = rcall("RPOPLPUSH", KEYS[1], KEYS[2])
|
234
246
|
|
@@ -240,23 +252,19 @@ if rcall("EXISTS", jobIdKey) == 1 then -- Make sure job exists
|
|
240
252
|
-- If jobId is special ID 0:delay (delay greater than 0), then there is no job to process
|
241
253
|
-- but if ID is 0:0, then there is at least 1 prioritized job to process
|
242
254
|
if jobId == "0:0" then
|
243
|
-
jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2],
|
244
|
-
|
245
|
-
|
246
|
-
timestamp, maxJobs, markerKey,
|
247
|
-
opts)
|
255
|
+
jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2], KEYS[10])
|
256
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs,
|
257
|
+
markerKey, opts)
|
248
258
|
end
|
249
259
|
else
|
250
|
-
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId,
|
251
|
-
|
252
|
-
opts)
|
260
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs, markerKey,
|
261
|
+
opts)
|
253
262
|
end
|
254
263
|
else
|
255
264
|
jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2], KEYS[10])
|
256
265
|
if jobId then
|
257
|
-
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId,
|
258
|
-
|
259
|
-
opts)
|
266
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId, timestamp, maxJobs, markerKey,
|
267
|
+
opts)
|
260
268
|
end
|
261
269
|
end
|
262
270
|
|
@@ -37,6 +37,7 @@ local jobId = ARGV[4]
|
|
37
37
|
|
38
38
|
--- Includes
|
39
39
|
--- @include "includes/moveParentToFailedIfNeeded"
|
40
|
+
--- @include "includes/moveParentToWait"
|
40
41
|
--- @include "includes/moveParentToWaitIfNeeded"
|
41
42
|
--- @include "includes/removeDeduplicationKeyIfNeeded"
|
42
43
|
--- @include "includes/removeJobsOnFail"
|
@@ -75,18 +76,22 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
75
76
|
local opts = cjson.decode(rawOpts)
|
76
77
|
|
77
78
|
if rawParentData ~= false then
|
78
|
-
if opts['fpof'] then
|
79
|
+
if opts['fpof'] or opts['cpof'] then
|
79
80
|
local parentData = cjson.decode(rawParentData)
|
80
81
|
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
81
82
|
local parentUnsuccesssful = parentKey .. ":unsuccessful"
|
82
83
|
rcall("ZADD", parentUnsuccesssful, timestamp, jobKey)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
84
|
+
if opts['fpof'] then
|
85
|
+
moveParentToFailedIfNeeded(
|
86
|
+
parentData['queueKey'],
|
87
|
+
parentData['queueKey'] .. ':' .. parentData['id'],
|
88
|
+
parentData['id'],
|
89
|
+
jobKey,
|
90
|
+
timestamp
|
91
|
+
)
|
92
|
+
elseif opts['cpof'] then
|
93
|
+
moveParentToWait(parentData['queueKey'], parentKey, parentData['id'], timestamp)
|
94
|
+
end
|
90
95
|
elseif opts['idof'] or opts['rdof'] then
|
91
96
|
local parentData = cjson.decode(rawParentData)
|
92
97
|
local parentKey = parentData['queueKey'] .. ':' .. parentData['id']
|
@@ -159,9 +159,11 @@ end
|
|
159
159
|
]]
|
160
160
|
-- Includes
|
161
161
|
--[[
|
162
|
-
Validate and move parent to
|
162
|
+
Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
|
163
|
+
]]
|
164
|
+
--[[
|
165
|
+
Validate and move parent to a wait status (wait, prioritized or delayed)
|
163
166
|
]]
|
164
|
-
-- Includes
|
165
167
|
--[[
|
166
168
|
Function to add job in target list and add marker if needed.
|
167
169
|
]]
|
@@ -231,12 +233,9 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
231
233
|
end
|
232
234
|
return waitKey, false
|
233
235
|
end
|
234
|
-
local function
|
235
|
-
|
236
|
-
|
237
|
-
parentQueueKey .. ":waiting-children", parentId)
|
238
|
-
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
239
|
-
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
236
|
+
local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
237
|
+
local isParentWaitingChildren = rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
238
|
+
if isParentWaitingChildren > 0 then
|
240
239
|
local parentWaitKey = parentQueueKey .. ":wait"
|
241
240
|
local parentPausedKey = parentQueueKey .. ":paused"
|
242
241
|
local parentActiveKey = parentQueueKey .. ":active"
|
@@ -245,32 +244,37 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
245
244
|
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
246
245
|
local priority = tonumber(jobAttributes[1]) or 0
|
247
246
|
local delay = tonumber(jobAttributes[2]) or 0
|
247
|
+
-- ignore dependencies if any left
|
248
|
+
rcall("HSET", parentKey, "igdp", 1)
|
248
249
|
if delay > 0 then
|
249
250
|
local delayedTimestamp = tonumber(timestamp) + delay
|
250
251
|
local score = delayedTimestamp * 0x1000
|
251
252
|
local parentDelayedKey = parentQueueKey .. ":delayed"
|
252
253
|
rcall("ZADD", parentDelayedKey, score, parentId)
|
253
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed",
|
254
|
-
|
254
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
|
255
|
+
delayedTimestamp)
|
255
256
|
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
256
257
|
else
|
257
258
|
if priority == 0 then
|
258
|
-
local parentTarget, isParentPausedOrMaxed =
|
259
|
-
|
260
|
-
|
261
|
-
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
|
262
|
-
parentId)
|
259
|
+
local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
|
260
|
+
parentWaitKey, parentPausedKey)
|
261
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
263
262
|
else
|
264
263
|
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
265
|
-
addJobWithPriority(parentMarkerKey,
|
266
|
-
|
267
|
-
parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
|
264
|
+
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
265
|
+
parentQueueKey .. ":pc", isPausedOrMaxed)
|
268
266
|
end
|
269
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
|
270
|
-
|
267
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
268
|
+
"waiting-children")
|
271
269
|
end
|
272
270
|
end
|
273
271
|
end
|
272
|
+
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
273
|
+
local hasPendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
274
|
+
if hasPendingDependencies then
|
275
|
+
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
276
|
+
end
|
277
|
+
end
|
274
278
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
275
279
|
parentId, jobIdKey, returnvalue, timestamp )
|
276
280
|
local processedSet = parentKey .. ":processed"
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Xf,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -270,7 +270,7 @@ end
|
|
270
270
|
local getJobKeyPrefix = function (jobKey, jobId)
|
271
271
|
return string.sub(jobKey, 0, #jobKey - #jobId)
|
272
272
|
end
|
273
|
-
local function
|
273
|
+
local function _moveParentToWait(parentPrefix, parentId, emitEvent)
|
274
274
|
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
275
275
|
parentPrefix .. "wait", parentPrefix .. "paused")
|
276
276
|
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
@@ -298,10 +298,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
|
|
298
298
|
rcall("DEL", parentPrefix .. "de:" .. debounceId)
|
299
299
|
end
|
300
300
|
else
|
301
|
-
|
301
|
+
_moveParentToWait(parentPrefix, parentId)
|
302
302
|
end
|
303
303
|
else
|
304
|
-
|
304
|
+
_moveParentToWait(parentPrefix, parentId, true)
|
305
305
|
end
|
306
306
|
end
|
307
307
|
end
|
@@ -329,10 +329,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
|
|
329
329
|
rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
|
330
330
|
end
|
331
331
|
else
|
332
|
-
|
332
|
+
_moveParentToWait(parentPrefix, parentId)
|
333
333
|
end
|
334
334
|
else
|
335
|
-
|
335
|
+
_moveParentToWait(parentPrefix, parentId, true)
|
336
336
|
end
|
337
337
|
end
|
338
338
|
end
|
@@ -91,9 +91,11 @@ end
|
|
91
91
|
]]
|
92
92
|
-- Includes
|
93
93
|
--[[
|
94
|
-
Validate and move parent to
|
94
|
+
Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
|
95
|
+
]]
|
96
|
+
--[[
|
97
|
+
Validate and move parent to a wait status (wait, prioritized or delayed)
|
95
98
|
]]
|
96
|
-
-- Includes
|
97
99
|
--[[
|
98
100
|
Add delay marker if needed.
|
99
101
|
]]
|
@@ -187,12 +189,9 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
187
189
|
end
|
188
190
|
return waitKey, false
|
189
191
|
end
|
190
|
-
local function
|
191
|
-
|
192
|
-
|
193
|
-
parentQueueKey .. ":waiting-children", parentId)
|
194
|
-
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
195
|
-
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
192
|
+
local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
193
|
+
local isParentWaitingChildren = rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
194
|
+
if isParentWaitingChildren > 0 then
|
196
195
|
local parentWaitKey = parentQueueKey .. ":wait"
|
197
196
|
local parentPausedKey = parentQueueKey .. ":paused"
|
198
197
|
local parentActiveKey = parentQueueKey .. ":active"
|
@@ -201,32 +200,37 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
201
200
|
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
202
201
|
local priority = tonumber(jobAttributes[1]) or 0
|
203
202
|
local delay = tonumber(jobAttributes[2]) or 0
|
203
|
+
-- ignore dependencies if any left
|
204
|
+
rcall("HSET", parentKey, "igdp", 1)
|
204
205
|
if delay > 0 then
|
205
206
|
local delayedTimestamp = tonumber(timestamp) + delay
|
206
207
|
local score = delayedTimestamp * 0x1000
|
207
208
|
local parentDelayedKey = parentQueueKey .. ":delayed"
|
208
209
|
rcall("ZADD", parentDelayedKey, score, parentId)
|
209
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed",
|
210
|
-
|
210
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
|
211
|
+
delayedTimestamp)
|
211
212
|
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
212
213
|
else
|
213
214
|
if priority == 0 then
|
214
|
-
local parentTarget, isParentPausedOrMaxed =
|
215
|
-
|
216
|
-
|
217
|
-
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
|
218
|
-
parentId)
|
215
|
+
local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
|
216
|
+
parentWaitKey, parentPausedKey)
|
217
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
219
218
|
else
|
220
219
|
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
221
|
-
addJobWithPriority(parentMarkerKey,
|
222
|
-
|
223
|
-
parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
|
220
|
+
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
221
|
+
parentQueueKey .. ":pc", isPausedOrMaxed)
|
224
222
|
end
|
225
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
|
226
|
-
|
223
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
224
|
+
"waiting-children")
|
227
225
|
end
|
228
226
|
end
|
229
227
|
end
|
228
|
+
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
229
|
+
local hasPendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
230
|
+
if hasPendingDependencies then
|
231
|
+
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
232
|
+
end
|
233
|
+
end
|
230
234
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
231
235
|
parentId, jobIdKey, returnvalue, timestamp )
|
232
236
|
local processedSet = parentKey .. ":processed"
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addParentJob-4.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-4.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addParentJob-4.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-4.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoVf,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -153,9 +153,11 @@ end
|
|
153
153
|
]]
|
154
154
|
-- Includes
|
155
155
|
--[[
|
156
|
-
Validate and move parent to
|
156
|
+
Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
|
157
|
+
]]
|
158
|
+
--[[
|
159
|
+
Validate and move parent to a wait status (wait, prioritized or delayed)
|
157
160
|
]]
|
158
|
-
-- Includes
|
159
161
|
--[[
|
160
162
|
Add delay marker if needed.
|
161
163
|
]]
|
@@ -224,12 +226,9 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
224
226
|
end
|
225
227
|
return waitKey, false
|
226
228
|
end
|
227
|
-
local function
|
228
|
-
|
229
|
-
|
230
|
-
parentQueueKey .. ":waiting-children", parentId)
|
231
|
-
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
232
|
-
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
229
|
+
local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
230
|
+
local isParentWaitingChildren = rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
231
|
+
if isParentWaitingChildren > 0 then
|
233
232
|
local parentWaitKey = parentQueueKey .. ":wait"
|
234
233
|
local parentPausedKey = parentQueueKey .. ":paused"
|
235
234
|
local parentActiveKey = parentQueueKey .. ":active"
|
@@ -238,32 +237,37 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
238
237
|
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
239
238
|
local priority = tonumber(jobAttributes[1]) or 0
|
240
239
|
local delay = tonumber(jobAttributes[2]) or 0
|
240
|
+
-- ignore dependencies if any left
|
241
|
+
rcall("HSET", parentKey, "igdp", 1)
|
241
242
|
if delay > 0 then
|
242
243
|
local delayedTimestamp = tonumber(timestamp) + delay
|
243
244
|
local score = delayedTimestamp * 0x1000
|
244
245
|
local parentDelayedKey = parentQueueKey .. ":delayed"
|
245
246
|
rcall("ZADD", parentDelayedKey, score, parentId)
|
246
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed",
|
247
|
-
|
247
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
|
248
|
+
delayedTimestamp)
|
248
249
|
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
249
250
|
else
|
250
251
|
if priority == 0 then
|
251
|
-
local parentTarget, isParentPausedOrMaxed =
|
252
|
-
|
253
|
-
|
254
|
-
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
|
255
|
-
parentId)
|
252
|
+
local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
|
253
|
+
parentWaitKey, parentPausedKey)
|
254
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
256
255
|
else
|
257
256
|
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
258
|
-
addJobWithPriority(parentMarkerKey,
|
259
|
-
|
260
|
-
parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
|
257
|
+
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
258
|
+
parentQueueKey .. ":pc", isPausedOrMaxed)
|
261
259
|
end
|
262
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
|
263
|
-
|
260
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
261
|
+
"waiting-children")
|
264
262
|
end
|
265
263
|
end
|
266
264
|
end
|
265
|
+
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
266
|
+
local hasPendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
267
|
+
if hasPendingDependencies then
|
268
|
+
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
269
|
+
end
|
270
|
+
end
|
267
271
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
268
272
|
parentId, jobIdKey, returnvalue, timestamp )
|
269
273
|
local processedSet = parentKey .. ":processed"
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addPrioritizedJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addPrioritizedJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Vf,CAAC;AACF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,mBAAmB;IACzB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -97,7 +97,7 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
97
97
|
end
|
98
98
|
return waitKey, false
|
99
99
|
end
|
100
|
-
local function
|
100
|
+
local function _moveParentToWait(parentPrefix, parentId, emitEvent)
|
101
101
|
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
102
102
|
parentPrefix .. "wait", parentPrefix .. "paused")
|
103
103
|
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
@@ -125,10 +125,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
|
|
125
125
|
rcall("DEL", parentPrefix .. "de:" .. debounceId)
|
126
126
|
end
|
127
127
|
else
|
128
|
-
|
128
|
+
_moveParentToWait(parentPrefix, parentId)
|
129
129
|
end
|
130
130
|
else
|
131
|
-
|
131
|
+
_moveParentToWait(parentPrefix, parentId, true)
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
@@ -156,10 +156,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
|
|
156
156
|
rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
|
157
157
|
end
|
158
158
|
else
|
159
|
-
|
159
|
+
_moveParentToWait(parentPrefix, parentId)
|
160
160
|
end
|
161
161
|
else
|
162
|
-
|
162
|
+
_moveParentToWait(parentPrefix, parentId, true)
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|
@@ -137,9 +137,11 @@ end
|
|
137
137
|
]]
|
138
138
|
-- Includes
|
139
139
|
--[[
|
140
|
-
Validate and move parent to
|
140
|
+
Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
|
141
|
+
]]
|
142
|
+
--[[
|
143
|
+
Validate and move parent to a wait status (wait, prioritized or delayed)
|
141
144
|
]]
|
142
|
-
-- Includes
|
143
145
|
--[[
|
144
146
|
Add delay marker if needed.
|
145
147
|
]]
|
@@ -197,12 +199,9 @@ local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
|
|
197
199
|
end
|
198
200
|
return false
|
199
201
|
end
|
200
|
-
local function
|
201
|
-
|
202
|
-
|
203
|
-
parentQueueKey .. ":waiting-children", parentId)
|
204
|
-
if isParentActive and rcall("SCARD", parentDependenciesKey) == 0 then
|
205
|
-
rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
202
|
+
local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
203
|
+
local isParentWaitingChildren = rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
|
204
|
+
if isParentWaitingChildren > 0 then
|
206
205
|
local parentWaitKey = parentQueueKey .. ":wait"
|
207
206
|
local parentPausedKey = parentQueueKey .. ":paused"
|
208
207
|
local parentActiveKey = parentQueueKey .. ":active"
|
@@ -211,32 +210,37 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
211
210
|
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
212
211
|
local priority = tonumber(jobAttributes[1]) or 0
|
213
212
|
local delay = tonumber(jobAttributes[2]) or 0
|
213
|
+
-- ignore dependencies if any left
|
214
|
+
rcall("HSET", parentKey, "igdp", 1)
|
214
215
|
if delay > 0 then
|
215
216
|
local delayedTimestamp = tonumber(timestamp) + delay
|
216
217
|
local score = delayedTimestamp * 0x1000
|
217
218
|
local parentDelayedKey = parentQueueKey .. ":delayed"
|
218
219
|
rcall("ZADD", parentDelayedKey, score, parentId)
|
219
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed",
|
220
|
-
|
220
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
|
221
|
+
delayedTimestamp)
|
221
222
|
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
222
223
|
else
|
223
224
|
if priority == 0 then
|
224
|
-
local parentTarget, isParentPausedOrMaxed =
|
225
|
-
|
226
|
-
|
227
|
-
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
|
228
|
-
parentId)
|
225
|
+
local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
|
226
|
+
parentWaitKey, parentPausedKey)
|
227
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
229
228
|
else
|
230
229
|
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
231
|
-
addJobWithPriority(parentMarkerKey,
|
232
|
-
|
233
|
-
parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
|
230
|
+
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
231
|
+
parentQueueKey .. ":pc", isPausedOrMaxed)
|
234
232
|
end
|
235
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
|
236
|
-
|
233
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
234
|
+
"waiting-children")
|
237
235
|
end
|
238
236
|
end
|
239
237
|
end
|
238
|
+
local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
239
|
+
local hasPendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
240
|
+
if hasPendingDependencies then
|
241
|
+
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
242
|
+
end
|
243
|
+
end
|
240
244
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
241
245
|
parentId, jobIdKey, returnvalue, timestamp )
|
242
246
|
local processedSet = parentKey .. ":processed"
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addStandardJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addStandardJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkWf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -133,7 +133,7 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
133
133
|
end
|
134
134
|
return waitKey, false
|
135
135
|
end
|
136
|
-
local function
|
136
|
+
local function _moveParentToWait(parentPrefix, parentId, emitEvent)
|
137
137
|
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
138
138
|
parentPrefix .. "wait", parentPrefix .. "paused")
|
139
139
|
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
@@ -161,10 +161,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
|
|
161
161
|
rcall("DEL", parentPrefix .. "de:" .. debounceId)
|
162
162
|
end
|
163
163
|
else
|
164
|
-
|
164
|
+
_moveParentToWait(parentPrefix, parentId)
|
165
165
|
end
|
166
166
|
else
|
167
|
-
|
167
|
+
_moveParentToWait(parentPrefix, parentId, true)
|
168
168
|
end
|
169
169
|
end
|
170
170
|
end
|
@@ -192,10 +192,10 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
|
|
192
192
|
rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
|
193
193
|
end
|
194
194
|
else
|
195
|
-
|
195
|
+
_moveParentToWait(parentPrefix, parentId)
|
196
196
|
end
|
197
197
|
else
|
198
|
-
|
198
|
+
_moveParentToWait(parentPrefix, parentId, true)
|
199
199
|
end
|
200
200
|
end
|
201
201
|
end
|