bullmq 6.3.12 → 6.3.14
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/queue-getters.js +3 -1
- package/dist/cjs/classes/queue.js +2 -1
- package/dist/cjs/classes/redis-connection.js +1 -1
- package/dist/cjs/classes/redis-queue-backend.js +1 -1
- package/dist/cjs/commands/includes/moveChildBackToParentDependencies.lua +20 -0
- package/dist/cjs/commands/moveJobsToWait-8.lua +3 -0
- package/dist/cjs/commands/reprocessJob-7.lua +2 -14
- package/dist/cjs/scripts/moveJobsToWait-8.js +21 -0
- package/dist/cjs/scripts/reprocessJob-7.js +20 -13
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/queue-getters.d.ts +3 -1
- package/dist/esm/classes/queue-getters.js +3 -1
- package/dist/esm/classes/queue.d.ts +2 -1
- package/dist/esm/classes/queue.js +2 -1
- package/dist/esm/classes/redis-connection.d.ts +1 -1
- package/dist/esm/classes/redis-connection.js +1 -1
- package/dist/esm/classes/redis-queue-backend.d.ts +1 -1
- package/dist/esm/classes/redis-queue-backend.js +1 -1
- package/dist/esm/commands/includes/moveChildBackToParentDependencies.lua +20 -0
- package/dist/esm/commands/moveJobsToWait-8.lua +3 -0
- package/dist/esm/commands/reprocessJob-7.lua +2 -14
- package/dist/esm/scripts/moveJobsToWait-8.js +21 -0
- package/dist/esm/scripts/reprocessJob-7.js +20 -13
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +2 -2
|
@@ -329,7 +329,9 @@ class QueueGetters extends queue_base_1.QueueBase {
|
|
|
329
329
|
*
|
|
330
330
|
* @param parentId - The id of the parent job
|
|
331
331
|
* @param type - "processed" | "pending"
|
|
332
|
-
* @param
|
|
332
|
+
* @param start - Zero-based index from where to start returning children.
|
|
333
|
+
* @param end - Zero-based index where to stop returning children (inclusive),
|
|
334
|
+
* or -1 to return all of them.
|
|
333
335
|
*
|
|
334
336
|
* @returns an object with the following shape:
|
|
335
337
|
* `{ items: { id: string, v?: any, err?: string } [], jobs: JobJson[], total: number}`
|
|
@@ -233,7 +233,8 @@ class Queue extends queue_getters_1.QueueGetters {
|
|
|
233
233
|
* Upserting a scheduler will create a new job scheduler or update an existing one.
|
|
234
234
|
* It will also create the first job based on the repeat options and delayed accordingly.
|
|
235
235
|
*
|
|
236
|
-
* @param
|
|
236
|
+
* @param jobSchedulerId - Unique id of the job scheduler. Upserting with an
|
|
237
|
+
* existing id updates that scheduler.
|
|
237
238
|
* @param repeatOpts - Repeat options
|
|
238
239
|
* @param jobTemplate - Job template. If provided it will be used for all the jobs
|
|
239
240
|
* created by the scheduler.
|
|
@@ -175,7 +175,7 @@ class RedisConnection extends events_1.EventEmitter {
|
|
|
175
175
|
}
|
|
176
176
|
/**
|
|
177
177
|
* Waits for a redis client to be ready.
|
|
178
|
-
* @param
|
|
178
|
+
* @param client - Redis client to wait for.
|
|
179
179
|
*/
|
|
180
180
|
static async waitUntilReady(client) {
|
|
181
181
|
if (client.status === 'ready') {
|
|
@@ -1438,8 +1438,8 @@ class RedisQueueBackend extends events_1.EventEmitter {
|
|
|
1438
1438
|
* This script is used when a job has been manually rate limited and needs
|
|
1439
1439
|
* to be moved back to wait from active status.
|
|
1440
1440
|
*
|
|
1441
|
-
* @param client - Redis client
|
|
1442
1441
|
* @param jobId - Job id
|
|
1442
|
+
* @param token - Lock token of the job. Defaults to '0'.
|
|
1443
1443
|
* @returns
|
|
1444
1444
|
*/
|
|
1445
1445
|
async moveJobFromActiveToWait(jobId, token = '0') {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
--[[
|
|
2
|
+
Function to move a retried child back to its parent's dependencies.
|
|
3
|
+
This does not move a parent that has already left waiting-children back to that state.
|
|
4
|
+
]]
|
|
5
|
+
local function moveChildBackToParentDependencies(jobKey, prevState)
|
|
6
|
+
local parentKey = rcall("HGET", jobKey, "parentKey")
|
|
7
|
+
|
|
8
|
+
if parentKey and rcall("EXISTS", parentKey) == 1 then
|
|
9
|
+
if prevState == "failed" then
|
|
10
|
+
if rcall("ZREM", parentKey .. ":unsuccessful", jobKey) == 1 or
|
|
11
|
+
rcall("HDEL", parentKey .. ":failed", jobKey) == 1 then
|
|
12
|
+
rcall("SADD", parentKey .. ":dependencies", jobKey)
|
|
13
|
+
end
|
|
14
|
+
else
|
|
15
|
+
if rcall("HDEL", parentKey .. ":processed", jobKey) == 1 then
|
|
16
|
+
rcall("SADD", parentKey .. ":dependencies", jobKey)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -31,6 +31,7 @@ local rcall = redis.call;
|
|
|
31
31
|
--- @include "includes/batches"
|
|
32
32
|
--- @include "includes/getOrSetMaxEvents"
|
|
33
33
|
--- @include "includes/isQueuePausedOrMaxed"
|
|
34
|
+
--- @include "includes/moveChildBackToParentDependencies"
|
|
34
35
|
|
|
35
36
|
local metaKey = KEYS[6]
|
|
36
37
|
local isPausedOrMaxed = isQueuePausedOrMaxed(metaKey, KEYS[7])
|
|
@@ -42,11 +43,13 @@ if (#jobs > 0) then
|
|
|
42
43
|
for i, key in ipairs(jobs) do
|
|
43
44
|
local jobKey = KEYS[1] .. key
|
|
44
45
|
rcall("HDEL", jobKey, "finishedOn", "processedOn", "failedReason")
|
|
46
|
+
moveChildBackToParentDependencies(jobKey, ARGV[3])
|
|
45
47
|
end
|
|
46
48
|
elseif ARGV[3] == "completed" then
|
|
47
49
|
for i, key in ipairs(jobs) do
|
|
48
50
|
local jobKey = KEYS[1] .. key
|
|
49
51
|
rcall("HDEL", jobKey, "finishedOn", "processedOn", "returnvalue")
|
|
52
|
+
moveChildBackToParentDependencies(jobKey, ARGV[3])
|
|
50
53
|
end
|
|
51
54
|
end
|
|
52
55
|
|
|
@@ -28,6 +28,7 @@ local rcall = redis.call;
|
|
|
28
28
|
--- @include "includes/addJobInTargetList"
|
|
29
29
|
--- @include "includes/getOrSetMaxEvents"
|
|
30
30
|
--- @include "includes/isQueuePausedOrMaxed"
|
|
31
|
+
--- @include "includes/moveChildBackToParentDependencies"
|
|
31
32
|
|
|
32
33
|
local jobKey = KEYS[1]
|
|
33
34
|
if rcall("EXISTS", jobKey) == 1 then
|
|
@@ -48,20 +49,7 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
|
48
49
|
local isPausedOrMaxed = isQueuePausedOrMaxed(KEYS[5], KEYS[6])
|
|
49
50
|
addJobInTargetList(KEYS[4], KEYS[7], ARGV[2], isPausedOrMaxed, jobId)
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if parentKey and rcall("EXISTS", parentKey) == 1 then
|
|
54
|
-
if ARGV[4] == "failed" then
|
|
55
|
-
if rcall("ZREM", parentKey .. ":unsuccessful", jobKey) == 1 or
|
|
56
|
-
rcall("HDEL", parentKey .. ":failed", jobKey) == 1 then
|
|
57
|
-
rcall("SADD", parentKey .. ":dependencies", jobKey)
|
|
58
|
-
end
|
|
59
|
-
else
|
|
60
|
-
if rcall("HDEL", parentKey .. ":processed", jobKey) == 1 then
|
|
61
|
-
rcall("SADD", parentKey .. ":dependencies", jobKey)
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
52
|
+
moveChildBackToParentDependencies(jobKey, ARGV[4])
|
|
65
53
|
|
|
66
54
|
local maxEvents = getOrSetMaxEvents(KEYS[5])
|
|
67
55
|
-- Emit waiting event
|
|
@@ -75,6 +75,25 @@ local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
|
|
|
75
75
|
end
|
|
76
76
|
return false
|
|
77
77
|
end
|
|
78
|
+
--[[
|
|
79
|
+
Function to move a retried child back to its parent's dependencies.
|
|
80
|
+
This does not move a parent that has already left waiting-children back to that state.
|
|
81
|
+
]]
|
|
82
|
+
local function moveChildBackToParentDependencies(jobKey, prevState)
|
|
83
|
+
local parentKey = rcall("HGET", jobKey, "parentKey")
|
|
84
|
+
if parentKey and rcall("EXISTS", parentKey) == 1 then
|
|
85
|
+
if prevState == "failed" then
|
|
86
|
+
if rcall("ZREM", parentKey .. ":unsuccessful", jobKey) == 1 or
|
|
87
|
+
rcall("HDEL", parentKey .. ":failed", jobKey) == 1 then
|
|
88
|
+
rcall("SADD", parentKey .. ":dependencies", jobKey)
|
|
89
|
+
end
|
|
90
|
+
else
|
|
91
|
+
if rcall("HDEL", parentKey .. ":processed", jobKey) == 1 then
|
|
92
|
+
rcall("SADD", parentKey .. ":dependencies", jobKey)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
78
97
|
local metaKey = KEYS[6]
|
|
79
98
|
local isPausedOrMaxed = isQueuePausedOrMaxed(metaKey, KEYS[7])
|
|
80
99
|
local jobs = rcall('ZRANGEBYSCORE', KEYS[3], 0, timestamp, 'LIMIT', 0, maxCount)
|
|
@@ -83,11 +102,13 @@ if (#jobs > 0) then
|
|
|
83
102
|
for i, key in ipairs(jobs) do
|
|
84
103
|
local jobKey = KEYS[1] .. key
|
|
85
104
|
rcall("HDEL", jobKey, "finishedOn", "processedOn", "failedReason")
|
|
105
|
+
moveChildBackToParentDependencies(jobKey, ARGV[3])
|
|
86
106
|
end
|
|
87
107
|
elseif ARGV[3] == "completed" then
|
|
88
108
|
for i, key in ipairs(jobs) do
|
|
89
109
|
local jobKey = KEYS[1] .. key
|
|
90
110
|
rcall("HDEL", jobKey, "finishedOn", "processedOn", "returnvalue")
|
|
111
|
+
moveChildBackToParentDependencies(jobKey, ARGV[3])
|
|
91
112
|
end
|
|
92
113
|
end
|
|
93
114
|
local maxEvents = getOrSetMaxEvents(metaKey)
|
|
@@ -67,6 +67,25 @@ local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
|
|
|
67
67
|
end
|
|
68
68
|
return false
|
|
69
69
|
end
|
|
70
|
+
--[[
|
|
71
|
+
Function to move a retried child back to its parent's dependencies.
|
|
72
|
+
This does not move a parent that has already left waiting-children back to that state.
|
|
73
|
+
]]
|
|
74
|
+
local function moveChildBackToParentDependencies(jobKey, prevState)
|
|
75
|
+
local parentKey = rcall("HGET", jobKey, "parentKey")
|
|
76
|
+
if parentKey and rcall("EXISTS", parentKey) == 1 then
|
|
77
|
+
if prevState == "failed" then
|
|
78
|
+
if rcall("ZREM", parentKey .. ":unsuccessful", jobKey) == 1 or
|
|
79
|
+
rcall("HDEL", parentKey .. ":failed", jobKey) == 1 then
|
|
80
|
+
rcall("SADD", parentKey .. ":dependencies", jobKey)
|
|
81
|
+
end
|
|
82
|
+
else
|
|
83
|
+
if rcall("HDEL", parentKey .. ":processed", jobKey) == 1 then
|
|
84
|
+
rcall("SADD", parentKey .. ":dependencies", jobKey)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
70
89
|
local jobKey = KEYS[1]
|
|
71
90
|
if rcall("EXISTS", jobKey) == 1 then
|
|
72
91
|
local jobId = ARGV[1]
|
|
@@ -81,19 +100,7 @@ if rcall("EXISTS", jobKey) == 1 then
|
|
|
81
100
|
rcall("HDEL", jobKey, "finishedOn", "processedOn", ARGV[3], unpack(attributesToRemove))
|
|
82
101
|
local isPausedOrMaxed = isQueuePausedOrMaxed(KEYS[5], KEYS[6])
|
|
83
102
|
addJobInTargetList(KEYS[4], KEYS[7], ARGV[2], isPausedOrMaxed, jobId)
|
|
84
|
-
|
|
85
|
-
if parentKey and rcall("EXISTS", parentKey) == 1 then
|
|
86
|
-
if ARGV[4] == "failed" then
|
|
87
|
-
if rcall("ZREM", parentKey .. ":unsuccessful", jobKey) == 1 or
|
|
88
|
-
rcall("HDEL", parentKey .. ":failed", jobKey) == 1 then
|
|
89
|
-
rcall("SADD", parentKey .. ":dependencies", jobKey)
|
|
90
|
-
end
|
|
91
|
-
else
|
|
92
|
-
if rcall("HDEL", parentKey .. ":processed", jobKey) == 1 then
|
|
93
|
-
rcall("SADD", parentKey .. ":dependencies", jobKey)
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
103
|
+
moveChildBackToParentDependencies(jobKey, ARGV[4])
|
|
97
104
|
local maxEvents = getOrSetMaxEvents(KEYS[5])
|
|
98
105
|
-- Emit waiting event
|
|
99
106
|
rcall("XADD", KEYS[2], "MAXLEN", "~", maxEvents, "*", "event", "waiting",
|