bullmq 5.49.0 → 5.49.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/classes/flow-producer.js +1 -0
- package/dist/cjs/classes/flow-producer.js.map +1 -1
- package/dist/cjs/classes/job.js +3 -0
- package/dist/cjs/classes/job.js.map +1 -1
- package/dist/cjs/classes/worker.js +4 -0
- package/dist/cjs/classes/worker.js.map +1 -1
- package/dist/cjs/commands/includes/moveChildFromDependenciesIfNeeded.lua +15 -31
- package/dist/cjs/commands/includes/moveParentToWait.lua +32 -33
- package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +8 -4
- package/dist/cjs/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
- package/dist/cjs/commands/includes/updateParentDepsIfNeeded.lua +2 -2
- package/dist/cjs/commands/moveStalledJobsToWait-9.lua +0 -2
- package/dist/cjs/commands/moveToFinished-14.lua +5 -3
- package/dist/cjs/commands/moveToWaitingChildren-8.lua +0 -2
- package/dist/cjs/scripts/addDelayedJob-6.js +51 -37
- package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/cjs/scripts/addParentJob-4.js +51 -37
- package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
- package/dist/cjs/scripts/addPrioritizedJob-8.js +51 -37
- package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -1
- package/dist/cjs/scripts/addStandardJob-8.js +51 -37
- package/dist/cjs/scripts/addStandardJob-8.js.map +1 -1
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +64 -61
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +69 -63
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/moveToWaitingChildren-8.js +64 -61
- package/dist/cjs/scripts/moveToWaitingChildren-8.js.map +1 -1
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/flow-producer.js +1 -0
- 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 +3 -0
- package/dist/esm/classes/job.js.map +1 -1
- package/dist/esm/classes/worker.js +5 -1
- package/dist/esm/classes/worker.js.map +1 -1
- package/dist/esm/commands/includes/moveChildFromDependenciesIfNeeded.lua +15 -31
- package/dist/esm/commands/includes/moveParentToWait.lua +32 -33
- package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +8 -4
- package/dist/esm/commands/includes/moveParentToWaitIfNoPendingDependencies.lua +13 -0
- package/dist/esm/commands/includes/updateParentDepsIfNeeded.lua +2 -2
- package/dist/esm/commands/moveStalledJobsToWait-9.lua +0 -2
- package/dist/esm/commands/moveToFinished-14.lua +5 -3
- package/dist/esm/commands/moveToWaitingChildren-8.lua +0 -2
- package/dist/esm/interfaces/job-json.d.ts +1 -0
- package/dist/esm/scripts/addDelayedJob-6.js +51 -37
- package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/esm/scripts/addParentJob-4.js +51 -37
- package/dist/esm/scripts/addParentJob-4.js.map +1 -1
- package/dist/esm/scripts/addPrioritizedJob-8.js +51 -37
- package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -1
- package/dist/esm/scripts/addStandardJob-8.js +51 -37
- package/dist/esm/scripts/addStandardJob-8.js.map +1 -1
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +64 -61
- package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +69 -63
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/moveToWaitingChildren-8.js +64 -61
- package/dist/esm/scripts/moveToWaitingChildren-8.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
@@ -161,12 +161,19 @@ end
|
|
161
161
|
Validate and move or add dependencies to parent.
|
162
162
|
]]
|
163
163
|
-- Includes
|
164
|
+
--[[
|
165
|
+
Validate and move parent to a wait status (waiting, delayed or prioritized)
|
166
|
+
if no pending dependencies.
|
167
|
+
]]
|
168
|
+
-- Includes
|
164
169
|
--[[
|
165
170
|
Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
|
166
171
|
]]
|
172
|
+
-- Includes
|
167
173
|
--[[
|
168
|
-
|
174
|
+
Move parent to a wait status (wait, prioritized or delayed)
|
169
175
|
]]
|
176
|
+
-- Includes
|
170
177
|
--[[
|
171
178
|
Function to add job in target list and add marker if needed.
|
172
179
|
]]
|
@@ -237,52 +244,59 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
237
244
|
return waitKey, false
|
238
245
|
end
|
239
246
|
local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
240
|
-
local
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
247
|
+
local parentWaitKey = parentQueueKey .. ":wait"
|
248
|
+
local parentPausedKey = parentQueueKey .. ":paused"
|
249
|
+
local parentActiveKey = parentQueueKey .. ":active"
|
250
|
+
local parentMetaKey = parentQueueKey .. ":meta"
|
251
|
+
local parentMarkerKey = parentQueueKey .. ":marker"
|
252
|
+
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
253
|
+
local priority = tonumber(jobAttributes[1]) or 0
|
254
|
+
local delay = tonumber(jobAttributes[2]) or 0
|
255
|
+
-- ignore dependencies if any left
|
256
|
+
rcall("HSET", parentKey, "igdp", 1)
|
257
|
+
if delay > 0 then
|
258
|
+
local delayedTimestamp = tonumber(timestamp) + delay
|
259
|
+
local score = delayedTimestamp * 0x1000
|
260
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
261
|
+
rcall("ZADD", parentDelayedKey, score, parentId)
|
262
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
|
263
|
+
delayedTimestamp)
|
264
|
+
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
265
|
+
else
|
266
|
+
if priority == 0 then
|
267
|
+
local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
|
268
|
+
parentWaitKey, parentPausedKey)
|
269
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
260
270
|
else
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
265
|
-
else
|
266
|
-
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
267
|
-
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
268
|
-
parentQueueKey .. ":pc", isPausedOrMaxed)
|
269
|
-
end
|
270
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
271
|
-
"waiting-children")
|
271
|
+
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
272
|
+
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
273
|
+
parentQueueKey .. ":pc", isPausedOrMaxed)
|
272
274
|
end
|
275
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
276
|
+
"waiting-children")
|
273
277
|
end
|
274
278
|
end
|
275
|
-
local function moveParentToWaitIfNeeded(parentQueueKey,
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
+
local function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
|
280
|
+
if rcall("EXISTS", parentKey) == 1 then
|
281
|
+
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
282
|
+
if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
|
283
|
+
rcall("ZREM", parentWaitingChildrenKey, parentId)
|
284
|
+
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
279
285
|
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,
|
289
|
+
parentId, timestamp)
|
290
|
+
local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
291
|
+
if doNotHavePendingDependencies then
|
292
|
+
moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
|
293
|
+
end
|
280
294
|
end
|
281
295
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
282
296
|
parentId, jobIdKey, returnvalue, timestamp )
|
283
297
|
local processedSet = parentKey .. ":processed"
|
284
298
|
rcall("HSET", processedSet, jobIdKey, returnvalue)
|
285
|
-
|
299
|
+
moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
286
300
|
end
|
287
301
|
local function updateExistingJobsParent(parentKey, parent, parentData,
|
288
302
|
parentDependenciesKey, completedKey,
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Yf,CAAC;AACW,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -93,12 +93,19 @@ end
|
|
93
93
|
Validate and move or add dependencies to parent.
|
94
94
|
]]
|
95
95
|
-- Includes
|
96
|
+
--[[
|
97
|
+
Validate and move parent to a wait status (waiting, delayed or prioritized)
|
98
|
+
if no pending dependencies.
|
99
|
+
]]
|
100
|
+
-- Includes
|
96
101
|
--[[
|
97
102
|
Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
|
98
103
|
]]
|
104
|
+
-- Includes
|
99
105
|
--[[
|
100
|
-
|
106
|
+
Move parent to a wait status (wait, prioritized or delayed)
|
101
107
|
]]
|
108
|
+
-- Includes
|
102
109
|
--[[
|
103
110
|
Add delay marker if needed.
|
104
111
|
]]
|
@@ -193,52 +200,59 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
193
200
|
return waitKey, false
|
194
201
|
end
|
195
202
|
local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
196
|
-
local
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
203
|
+
local parentWaitKey = parentQueueKey .. ":wait"
|
204
|
+
local parentPausedKey = parentQueueKey .. ":paused"
|
205
|
+
local parentActiveKey = parentQueueKey .. ":active"
|
206
|
+
local parentMetaKey = parentQueueKey .. ":meta"
|
207
|
+
local parentMarkerKey = parentQueueKey .. ":marker"
|
208
|
+
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
209
|
+
local priority = tonumber(jobAttributes[1]) or 0
|
210
|
+
local delay = tonumber(jobAttributes[2]) or 0
|
211
|
+
-- ignore dependencies if any left
|
212
|
+
rcall("HSET", parentKey, "igdp", 1)
|
213
|
+
if delay > 0 then
|
214
|
+
local delayedTimestamp = tonumber(timestamp) + delay
|
215
|
+
local score = delayedTimestamp * 0x1000
|
216
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
217
|
+
rcall("ZADD", parentDelayedKey, score, parentId)
|
218
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
|
219
|
+
delayedTimestamp)
|
220
|
+
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
221
|
+
else
|
222
|
+
if priority == 0 then
|
223
|
+
local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
|
224
|
+
parentWaitKey, parentPausedKey)
|
225
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
216
226
|
else
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
221
|
-
else
|
222
|
-
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
223
|
-
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
224
|
-
parentQueueKey .. ":pc", isPausedOrMaxed)
|
225
|
-
end
|
226
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
227
|
-
"waiting-children")
|
227
|
+
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
228
|
+
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
229
|
+
parentQueueKey .. ":pc", isPausedOrMaxed)
|
228
230
|
end
|
231
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
232
|
+
"waiting-children")
|
229
233
|
end
|
230
234
|
end
|
231
|
-
local function moveParentToWaitIfNeeded(parentQueueKey,
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
+
local function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
|
236
|
+
if rcall("EXISTS", parentKey) == 1 then
|
237
|
+
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
238
|
+
if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
|
239
|
+
rcall("ZREM", parentWaitingChildrenKey, parentId)
|
240
|
+
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
235
241
|
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,
|
245
|
+
parentId, timestamp)
|
246
|
+
local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
247
|
+
if doNotHavePendingDependencies then
|
248
|
+
moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
|
249
|
+
end
|
236
250
|
end
|
237
251
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
238
252
|
parentId, jobIdKey, returnvalue, timestamp )
|
239
253
|
local processedSet = parentKey .. ":processed"
|
240
254
|
rcall("HSET", processedSet, jobIdKey, returnvalue)
|
241
|
-
|
255
|
+
moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
242
256
|
end
|
243
257
|
local function updateExistingJobsParent(parentKey, parent, parentData,
|
244
258
|
parentDependenciesKey, completedKey,
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkWf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -155,12 +155,19 @@ end
|
|
155
155
|
Validate and move or add dependencies to parent.
|
156
156
|
]]
|
157
157
|
-- Includes
|
158
|
+
--[[
|
159
|
+
Validate and move parent to a wait status (waiting, delayed or prioritized)
|
160
|
+
if no pending dependencies.
|
161
|
+
]]
|
162
|
+
-- Includes
|
158
163
|
--[[
|
159
164
|
Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
|
160
165
|
]]
|
166
|
+
-- Includes
|
161
167
|
--[[
|
162
|
-
|
168
|
+
Move parent to a wait status (wait, prioritized or delayed)
|
163
169
|
]]
|
170
|
+
-- Includes
|
164
171
|
--[[
|
165
172
|
Add delay marker if needed.
|
166
173
|
]]
|
@@ -230,52 +237,59 @@ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
|
230
237
|
return waitKey, false
|
231
238
|
end
|
232
239
|
local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
233
|
-
local
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
240
|
+
local parentWaitKey = parentQueueKey .. ":wait"
|
241
|
+
local parentPausedKey = parentQueueKey .. ":paused"
|
242
|
+
local parentActiveKey = parentQueueKey .. ":active"
|
243
|
+
local parentMetaKey = parentQueueKey .. ":meta"
|
244
|
+
local parentMarkerKey = parentQueueKey .. ":marker"
|
245
|
+
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
246
|
+
local priority = tonumber(jobAttributes[1]) or 0
|
247
|
+
local delay = tonumber(jobAttributes[2]) or 0
|
248
|
+
-- ignore dependencies if any left
|
249
|
+
rcall("HSET", parentKey, "igdp", 1)
|
250
|
+
if delay > 0 then
|
251
|
+
local delayedTimestamp = tonumber(timestamp) + delay
|
252
|
+
local score = delayedTimestamp * 0x1000
|
253
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
254
|
+
rcall("ZADD", parentDelayedKey, score, parentId)
|
255
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
|
256
|
+
delayedTimestamp)
|
257
|
+
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
258
|
+
else
|
259
|
+
if priority == 0 then
|
260
|
+
local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
|
261
|
+
parentWaitKey, parentPausedKey)
|
262
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
253
263
|
else
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
258
|
-
else
|
259
|
-
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
260
|
-
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
261
|
-
parentQueueKey .. ":pc", isPausedOrMaxed)
|
262
|
-
end
|
263
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
264
|
-
"waiting-children")
|
264
|
+
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
265
|
+
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
266
|
+
parentQueueKey .. ":pc", isPausedOrMaxed)
|
265
267
|
end
|
268
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
269
|
+
"waiting-children")
|
266
270
|
end
|
267
271
|
end
|
268
|
-
local function moveParentToWaitIfNeeded(parentQueueKey,
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
+
local function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
|
273
|
+
if rcall("EXISTS", parentKey) == 1 then
|
274
|
+
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
275
|
+
if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
|
276
|
+
rcall("ZREM", parentWaitingChildrenKey, parentId)
|
277
|
+
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
272
278
|
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,
|
282
|
+
parentId, timestamp)
|
283
|
+
local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
284
|
+
if doNotHavePendingDependencies then
|
285
|
+
moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
|
286
|
+
end
|
273
287
|
end
|
274
288
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
275
289
|
parentId, jobIdKey, returnvalue, timestamp )
|
276
290
|
local processedSet = parentKey .. ":processed"
|
277
291
|
rcall("HSET", processedSet, jobIdKey, returnvalue)
|
278
|
-
|
292
|
+
moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
279
293
|
end
|
280
294
|
local function updateExistingJobsParent(parentKey, parent, parentData,
|
281
295
|
parentDependenciesKey, completedKey,
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Wf,CAAC;AACW,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,mBAAmB;IACzB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -139,12 +139,19 @@ end
|
|
139
139
|
Validate and move or add dependencies to parent.
|
140
140
|
]]
|
141
141
|
-- Includes
|
142
|
+
--[[
|
143
|
+
Validate and move parent to a wait status (waiting, delayed or prioritized)
|
144
|
+
if no pending dependencies.
|
145
|
+
]]
|
146
|
+
-- Includes
|
142
147
|
--[[
|
143
148
|
Validate and move parent to a wait status (waiting, delayed or prioritized) if needed.
|
144
149
|
]]
|
150
|
+
-- Includes
|
145
151
|
--[[
|
146
|
-
|
152
|
+
Move parent to a wait status (wait, prioritized or delayed)
|
147
153
|
]]
|
154
|
+
-- Includes
|
148
155
|
--[[
|
149
156
|
Add delay marker if needed.
|
150
157
|
]]
|
@@ -203,52 +210,59 @@ local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
|
|
203
210
|
return false
|
204
211
|
end
|
205
212
|
local function moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
206
|
-
local
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
213
|
+
local parentWaitKey = parentQueueKey .. ":wait"
|
214
|
+
local parentPausedKey = parentQueueKey .. ":paused"
|
215
|
+
local parentActiveKey = parentQueueKey .. ":active"
|
216
|
+
local parentMetaKey = parentQueueKey .. ":meta"
|
217
|
+
local parentMarkerKey = parentQueueKey .. ":marker"
|
218
|
+
local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
|
219
|
+
local priority = tonumber(jobAttributes[1]) or 0
|
220
|
+
local delay = tonumber(jobAttributes[2]) or 0
|
221
|
+
-- ignore dependencies if any left
|
222
|
+
rcall("HSET", parentKey, "igdp", 1)
|
223
|
+
if delay > 0 then
|
224
|
+
local delayedTimestamp = tonumber(timestamp) + delay
|
225
|
+
local score = delayedTimestamp * 0x1000
|
226
|
+
local parentDelayedKey = parentQueueKey .. ":delayed"
|
227
|
+
rcall("ZADD", parentDelayedKey, score, parentId)
|
228
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId, "delay",
|
229
|
+
delayedTimestamp)
|
230
|
+
addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
|
231
|
+
else
|
232
|
+
if priority == 0 then
|
233
|
+
local parentTarget, isParentPausedOrMaxed = getTargetQueueList(parentMetaKey, parentActiveKey,
|
234
|
+
parentWaitKey, parentPausedKey)
|
235
|
+
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
226
236
|
else
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed, parentId)
|
231
|
-
else
|
232
|
-
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
233
|
-
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
234
|
-
parentQueueKey .. ":pc", isPausedOrMaxed)
|
235
|
-
end
|
236
|
-
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
237
|
-
"waiting-children")
|
237
|
+
local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
|
238
|
+
addJobWithPriority(parentMarkerKey, parentQueueKey .. ":prioritized", priority, parentId,
|
239
|
+
parentQueueKey .. ":pc", isPausedOrMaxed)
|
238
240
|
end
|
241
|
+
rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId, "prev",
|
242
|
+
"waiting-children")
|
239
243
|
end
|
240
244
|
end
|
241
|
-
local function moveParentToWaitIfNeeded(parentQueueKey,
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
+
local function moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
|
246
|
+
if rcall("EXISTS", parentKey) == 1 then
|
247
|
+
local parentWaitingChildrenKey = parentQueueKey .. ":waiting-children"
|
248
|
+
if rcall("ZSCORE", parentWaitingChildrenKey, parentId) then
|
249
|
+
rcall("ZREM", parentWaitingChildrenKey, parentId)
|
250
|
+
moveParentToWait(parentQueueKey, parentKey, parentId, timestamp)
|
245
251
|
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
local function moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey,
|
255
|
+
parentId, timestamp)
|
256
|
+
local doNotHavePendingDependencies = rcall("SCARD", parentDependenciesKey) == 0
|
257
|
+
if doNotHavePendingDependencies then
|
258
|
+
moveParentToWaitIfNeeded(parentQueueKey, parentKey, parentId, timestamp)
|
259
|
+
end
|
246
260
|
end
|
247
261
|
local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
|
248
262
|
parentId, jobIdKey, returnvalue, timestamp )
|
249
263
|
local processedSet = parentKey .. ":processed"
|
250
264
|
rcall("HSET", processedSet, jobIdKey, returnvalue)
|
251
|
-
|
265
|
+
moveParentToWaitIfNoPendingDependencies(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
|
252
266
|
end
|
253
267
|
local function updateExistingJobsParent(parentKey, parent, parentData,
|
254
268
|
parentDependenciesKey, completedKey,
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgXf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|