bullmq 5.10.4 → 5.11.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/job.js +6 -0
- package/dist/cjs/classes/job.js.map +1 -1
- package/dist/cjs/classes/queue-events.js.map +1 -1
- package/dist/cjs/classes/queue-keys.js +2 -1
- package/dist/cjs/classes/queue-keys.js.map +1 -1
- package/dist/cjs/classes/queue.js +9 -0
- package/dist/cjs/classes/queue.js.map +1 -1
- package/dist/cjs/classes/scripts.js +1 -0
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/commands/addDelayedJob-6.lua +11 -1
- package/dist/cjs/commands/addParentJob-4.lua +10 -1
- package/dist/cjs/commands/addPrioritizedJob-8.lua +11 -2
- package/dist/cjs/commands/addStandardJob-8.lua +11 -2
- package/dist/cjs/commands/includes/cleanList.lua +1 -1
- package/dist/cjs/commands/includes/cleanSet.lua +2 -2
- package/dist/cjs/commands/includes/debounceJob.lua +23 -0
- package/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +6 -3
- package/dist/cjs/commands/includes/removeDebounceKey.lua +12 -0
- package/dist/cjs/commands/includes/removeDebounceKeyIfNeeded.lua +14 -0
- package/dist/cjs/commands/includes/removeJob.lua +5 -1
- package/dist/cjs/commands/includes/removeJobs.lua +1 -1
- package/dist/cjs/commands/includes/removeJobsByMaxAge.lua +3 -2
- package/dist/cjs/commands/includes/removeJobsByMaxCount.lua +1 -1
- package/dist/cjs/commands/includes/removeParentDependencyKey.lua +11 -4
- package/dist/cjs/commands/includes/storeJob.lua +7 -1
- package/dist/cjs/commands/moveStalledJobsToWait-9.lua +6 -2
- package/dist/cjs/commands/moveToFinished-14.lua +14 -11
- package/dist/cjs/commands/removeChildDependency-1.lua +1 -1
- package/dist/cjs/commands/removeJob-2.lua +3 -1
- package/dist/cjs/interfaces/debounce-options.js +3 -0
- package/dist/cjs/interfaces/debounce-options.js.map +1 -0
- package/dist/cjs/interfaces/index.js +1 -0
- package/dist/cjs/interfaces/index.js.map +1 -1
- package/dist/cjs/scripts/addDelayedJob-6.js +34 -1
- package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/cjs/scripts/addParentJob-4.js +34 -1
- package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
- package/dist/cjs/scripts/addPrioritizedJob-8.js +34 -1
- package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -1
- package/dist/cjs/scripts/addStandardJob-8.js +34 -1
- package/dist/cjs/scripts/addStandardJob-8.js.map +1 -1
- package/dist/cjs/scripts/cleanJobsInSet-2.js +28 -8
- package/dist/cjs/scripts/cleanJobsInSet-2.js.map +1 -1
- package/dist/cjs/scripts/drain-4.js +26 -6
- package/dist/cjs/scripts/drain-4.js.map +1 -1
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +49 -13
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +56 -21
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/obliterate-2.js +26 -6
- package/dist/cjs/scripts/obliterate-2.js.map +1 -1
- package/dist/cjs/scripts/removeChildDependency-1.js +12 -5
- package/dist/cjs/scripts/removeChildDependency-1.js.map +1 -1
- package/dist/cjs/scripts/removeJob-2.js +23 -5
- package/dist/cjs/scripts/removeJob-2.js.map +1 -1
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/esm/classes/job.d.ts +4 -0
- package/dist/esm/classes/job.js +6 -0
- package/dist/esm/classes/job.js.map +1 -1
- package/dist/esm/classes/queue-events.d.ts +8 -0
- package/dist/esm/classes/queue-events.js.map +1 -1
- package/dist/esm/classes/queue-keys.js +2 -1
- package/dist/esm/classes/queue-keys.js.map +1 -1
- package/dist/esm/classes/queue.d.ts +6 -0
- package/dist/esm/classes/queue.js +9 -0
- package/dist/esm/classes/queue.js.map +1 -1
- package/dist/esm/classes/scripts.js +1 -0
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/commands/addDelayedJob-6.lua +11 -1
- package/dist/esm/commands/addParentJob-4.lua +10 -1
- package/dist/esm/commands/addPrioritizedJob-8.lua +11 -2
- package/dist/esm/commands/addStandardJob-8.lua +11 -2
- package/dist/esm/commands/includes/cleanList.lua +1 -1
- package/dist/esm/commands/includes/cleanSet.lua +2 -2
- package/dist/esm/commands/includes/debounceJob.lua +23 -0
- package/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +6 -3
- package/dist/esm/commands/includes/removeDebounceKey.lua +12 -0
- package/dist/esm/commands/includes/removeDebounceKeyIfNeeded.lua +14 -0
- package/dist/esm/commands/includes/removeJob.lua +5 -1
- package/dist/esm/commands/includes/removeJobs.lua +1 -1
- package/dist/esm/commands/includes/removeJobsByMaxAge.lua +3 -2
- package/dist/esm/commands/includes/removeJobsByMaxCount.lua +1 -1
- package/dist/esm/commands/includes/removeParentDependencyKey.lua +11 -4
- package/dist/esm/commands/includes/storeJob.lua +7 -1
- package/dist/esm/commands/moveStalledJobsToWait-9.lua +6 -2
- package/dist/esm/commands/moveToFinished-14.lua +14 -11
- package/dist/esm/commands/removeChildDependency-1.lua +1 -1
- package/dist/esm/commands/removeJob-2.lua +3 -1
- package/dist/esm/interfaces/debounce-options.d.ts +13 -0
- package/dist/esm/interfaces/debounce-options.js +2 -0
- package/dist/esm/interfaces/debounce-options.js.map +1 -0
- package/dist/esm/interfaces/index.d.ts +1 -0
- package/dist/esm/interfaces/index.js +1 -0
- package/dist/esm/interfaces/index.js.map +1 -1
- package/dist/esm/interfaces/job-json.d.ts +2 -0
- package/dist/esm/scripts/addDelayedJob-6.js +34 -1
- package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/esm/scripts/addParentJob-4.js +34 -1
- package/dist/esm/scripts/addParentJob-4.js.map +1 -1
- package/dist/esm/scripts/addPrioritizedJob-8.js +34 -1
- package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -1
- package/dist/esm/scripts/addStandardJob-8.js +34 -1
- package/dist/esm/scripts/addStandardJob-8.js.map +1 -1
- package/dist/esm/scripts/cleanJobsInSet-2.js +28 -8
- package/dist/esm/scripts/cleanJobsInSet-2.js.map +1 -1
- package/dist/esm/scripts/drain-4.js +26 -6
- package/dist/esm/scripts/drain-4.js.map +1 -1
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +49 -13
- package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +56 -21
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/obliterate-2.js +26 -6
- package/dist/esm/scripts/obliterate-2.js.map +1 -1
- package/dist/esm/scripts/removeChildDependency-1.js +12 -5
- package/dist/esm/scripts/removeChildDependency-1.js.map +1 -1
- package/dist/esm/scripts/removeJob-2.js +23 -5
- package/dist/esm/scripts/removeJob-2.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/types/job-options.d.ts +9 -1
- package/package.json +1 -1
@@ -31,6 +31,7 @@ const content = `--[[
|
|
31
31
|
[7] parent dependencies key.
|
32
32
|
[8] parent? {id, queueKey}
|
33
33
|
[9] repeat job key
|
34
|
+
[10] debounce key
|
34
35
|
ARGV[2] Json stringified job data
|
35
36
|
ARGV[3] msgpacked options
|
36
37
|
Output:
|
@@ -45,8 +46,9 @@ local args = cmsgpack.unpack(ARGV[1])
|
|
45
46
|
local data = ARGV[2]
|
46
47
|
local opts = cmsgpack.unpack(ARGV[3])
|
47
48
|
local parentKey = args[5]
|
48
|
-
local repeatJobKey = args[9]
|
49
49
|
local parent = args[8]
|
50
|
+
local repeatJobKey = args[9]
|
51
|
+
local debounceKey = args[10]
|
50
52
|
local parentData
|
51
53
|
-- Includes
|
52
54
|
--[[
|
@@ -65,6 +67,27 @@ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed
|
|
65
67
|
rcall(pushCmd, targetKey, jobId)
|
66
68
|
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
67
69
|
end
|
70
|
+
--[[
|
71
|
+
Function to debounce a job.
|
72
|
+
]]
|
73
|
+
local function debounceJob(prefixKey, debounceOpts, jobId, debounceKey, eventsKey, maxEvents)
|
74
|
+
local debounceId = debounceOpts and debounceOpts['id']
|
75
|
+
if debounceId then
|
76
|
+
local ttl = debounceOpts['ttl']
|
77
|
+
local debounceKeyExists
|
78
|
+
if ttl then
|
79
|
+
debounceKeyExists = not rcall('SET', debounceKey, jobId, 'PX', ttl, 'NX')
|
80
|
+
else
|
81
|
+
debounceKeyExists = not rcall('SET', debounceKey, jobId, 'NX')
|
82
|
+
end
|
83
|
+
if debounceKeyExists then
|
84
|
+
local currentDebounceJobId = rcall('GET', debounceKey)
|
85
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
86
|
+
"debounced", "jobId", currentDebounceJobId)
|
87
|
+
return currentDebounceJobId
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
68
91
|
--[[
|
69
92
|
Function to get max events value or set by default 10000.
|
70
93
|
]]
|
@@ -254,6 +277,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
254
277
|
local jsonOpts = cjson.encode(opts)
|
255
278
|
local delay = opts['delay'] or 0
|
256
279
|
local priority = opts['priority'] or 0
|
280
|
+
local debounceId = opts['de'] and opts['de']['id']
|
257
281
|
local optionalValues = {}
|
258
282
|
if parentKey ~= nil then
|
259
283
|
table.insert(optionalValues, "parentKey")
|
@@ -265,6 +289,10 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
265
289
|
table.insert(optionalValues, "rjk")
|
266
290
|
table.insert(optionalValues, repeatJobKey)
|
267
291
|
end
|
292
|
+
if debounceId then
|
293
|
+
table.insert(optionalValues, "deid")
|
294
|
+
table.insert(optionalValues, debounceId)
|
295
|
+
end
|
268
296
|
rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,
|
269
297
|
"timestamp", timestamp, "delay", delay, "priority", priority,
|
270
298
|
unpack(optionalValues))
|
@@ -292,6 +320,11 @@ else
|
|
292
320
|
maxEvents, timestamp)
|
293
321
|
end
|
294
322
|
end
|
323
|
+
local debouncedJobId = debounceJob(args[1], opts['de'],
|
324
|
+
jobId, debounceKey, eventsKey, maxEvents)
|
325
|
+
if debouncedJobId then
|
326
|
+
return debouncedJobId
|
327
|
+
end
|
295
328
|
-- Store the job.
|
296
329
|
storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2], opts, timestamp,
|
297
330
|
parentKey, parentData, repeatJobKey)
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsVf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -47,6 +47,16 @@ end
|
|
47
47
|
Function to remove job.
|
48
48
|
]]
|
49
49
|
-- Includes
|
50
|
+
--[[
|
51
|
+
Function to remove debounce key.
|
52
|
+
]]
|
53
|
+
local function removeDebounceKey(prefixKey, jobKey)
|
54
|
+
local debounceId = rcall("HGET", jobKey, "deid")
|
55
|
+
if debounceId then
|
56
|
+
local debounceKey = prefixKey .. "de:" .. debounceId
|
57
|
+
rcall("DEL", debounceKey)
|
58
|
+
end
|
59
|
+
end
|
50
60
|
--[[
|
51
61
|
Function to remove job keys.
|
52
62
|
]]
|
@@ -115,7 +125,7 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
115
125
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
116
126
|
end
|
117
127
|
end
|
118
|
-
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
128
|
+
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
|
119
129
|
if parentKey then
|
120
130
|
local parentDependenciesKey = parentKey .. ":dependencies"
|
121
131
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
@@ -128,8 +138,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
128
138
|
if numRemovedElements == 1 then
|
129
139
|
if hard then -- remove parent in same queue
|
130
140
|
if parentPrefix == baseKey then
|
131
|
-
removeParentDependencyKey(parentKey, hard, nil, baseKey)
|
141
|
+
removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
|
132
142
|
removeJobKeys(parentKey)
|
143
|
+
if debounceId then
|
144
|
+
rcall("DEL", parentPrefix .. "de:" .. debounceId)
|
145
|
+
end
|
133
146
|
else
|
134
147
|
moveParentToWait(parentPrefix, parentId)
|
135
148
|
end
|
@@ -141,7 +154,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
141
154
|
return true
|
142
155
|
end
|
143
156
|
else
|
144
|
-
local
|
157
|
+
local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
|
158
|
+
local missedParentKey = parentAttributes[1]
|
145
159
|
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
146
160
|
and (rcall("EXISTS", missedParentKey) == 1)) then
|
147
161
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
@@ -155,8 +169,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
155
169
|
if numRemovedElements == 1 then
|
156
170
|
if hard then
|
157
171
|
if parentPrefix == baseKey then
|
158
|
-
removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
|
172
|
+
removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
|
159
173
|
removeJobKeys(missedParentKey)
|
174
|
+
if parentAttributes[2] then
|
175
|
+
rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
|
176
|
+
end
|
160
177
|
else
|
161
178
|
moveParentToWait(parentPrefix, parentId)
|
162
179
|
end
|
@@ -171,9 +188,12 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
171
188
|
end
|
172
189
|
return false
|
173
190
|
end
|
174
|
-
local function removeJob(jobId, hard, baseKey)
|
191
|
+
local function removeJob(jobId, hard, baseKey, shouldRemoveDebounceKey)
|
175
192
|
local jobKey = baseKey .. jobId
|
176
193
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
194
|
+
if shouldRemoveDebounceKey then
|
195
|
+
removeDebounceKey(baseKey, jobKey)
|
196
|
+
end
|
177
197
|
removeJobKeys(jobKey)
|
178
198
|
end
|
179
199
|
local function cleanList(listKey, jobKeyPrefix, rangeStart, rangeEnd,
|
@@ -202,7 +222,7 @@ local function cleanList(listKey, jobKeyPrefix, rangeStart, rangeEnd,
|
|
202
222
|
-- replace the entry with a deletion marker; the actual deletion will
|
203
223
|
-- occur at the end of the script
|
204
224
|
rcall("LSET", listKey, rangeEnd - jobIdsLen + i, deletionMarker)
|
205
|
-
removeJob(job, true, jobKeyPrefix)
|
225
|
+
removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]])
|
206
226
|
deletedCount = deletedCount + 1
|
207
227
|
table.insert(deleted, job)
|
208
228
|
end
|
@@ -256,14 +276,14 @@ local function cleanSet(setKey, jobKeyPrefix, rangeEnd, timestamp, limit, attrib
|
|
256
276
|
end
|
257
277
|
local jobKey = jobKeyPrefix .. job
|
258
278
|
if isFinished then
|
259
|
-
removeJob(job, true, jobKeyPrefix)
|
279
|
+
removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]])
|
260
280
|
deletedCount = deletedCount + 1
|
261
281
|
table.insert(deleted, job)
|
262
282
|
else
|
263
283
|
-- * finishedOn says when the job was completed, but it isn't set unless the job has actually completed
|
264
284
|
jobTS = getTimestamp(jobKey, attributes)
|
265
285
|
if (not jobTS or jobTS <= timestamp) then
|
266
|
-
removeJob(job, true, jobKeyPrefix)
|
286
|
+
removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]])
|
267
287
|
deletedCount = deletedCount + 1
|
268
288
|
table.insert(deleted, job)
|
269
289
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cleanJobsInSet-2.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"cleanJobsInSet-2.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Tf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -22,6 +22,16 @@ local queueBaseKey = ARGV[1]
|
|
22
22
|
Function to remove job.
|
23
23
|
]]
|
24
24
|
-- Includes
|
25
|
+
--[[
|
26
|
+
Function to remove debounce key.
|
27
|
+
]]
|
28
|
+
local function removeDebounceKey(prefixKey, jobKey)
|
29
|
+
local debounceId = rcall("HGET", jobKey, "deid")
|
30
|
+
if debounceId then
|
31
|
+
local debounceKey = prefixKey .. "de:" .. debounceId
|
32
|
+
rcall("DEL", debounceKey)
|
33
|
+
end
|
34
|
+
end
|
25
35
|
--[[
|
26
36
|
Function to remove job keys.
|
27
37
|
]]
|
@@ -90,7 +100,7 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
90
100
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
91
101
|
end
|
92
102
|
end
|
93
|
-
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
103
|
+
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
|
94
104
|
if parentKey then
|
95
105
|
local parentDependenciesKey = parentKey .. ":dependencies"
|
96
106
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
@@ -103,8 +113,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
103
113
|
if numRemovedElements == 1 then
|
104
114
|
if hard then -- remove parent in same queue
|
105
115
|
if parentPrefix == baseKey then
|
106
|
-
removeParentDependencyKey(parentKey, hard, nil, baseKey)
|
116
|
+
removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
|
107
117
|
removeJobKeys(parentKey)
|
118
|
+
if debounceId then
|
119
|
+
rcall("DEL", parentPrefix .. "de:" .. debounceId)
|
120
|
+
end
|
108
121
|
else
|
109
122
|
moveParentToWait(parentPrefix, parentId)
|
110
123
|
end
|
@@ -116,7 +129,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
116
129
|
return true
|
117
130
|
end
|
118
131
|
else
|
119
|
-
local
|
132
|
+
local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
|
133
|
+
local missedParentKey = parentAttributes[1]
|
120
134
|
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
121
135
|
and (rcall("EXISTS", missedParentKey) == 1)) then
|
122
136
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
@@ -130,8 +144,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
130
144
|
if numRemovedElements == 1 then
|
131
145
|
if hard then
|
132
146
|
if parentPrefix == baseKey then
|
133
|
-
removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
|
147
|
+
removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
|
134
148
|
removeJobKeys(missedParentKey)
|
149
|
+
if parentAttributes[2] then
|
150
|
+
rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
|
151
|
+
end
|
135
152
|
else
|
136
153
|
moveParentToWait(parentPrefix, parentId)
|
137
154
|
end
|
@@ -146,14 +163,17 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
146
163
|
end
|
147
164
|
return false
|
148
165
|
end
|
149
|
-
local function removeJob(jobId, hard, baseKey)
|
166
|
+
local function removeJob(jobId, hard, baseKey, shouldRemoveDebounceKey)
|
150
167
|
local jobKey = baseKey .. jobId
|
151
168
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
169
|
+
if shouldRemoveDebounceKey then
|
170
|
+
removeDebounceKey(baseKey, jobKey)
|
171
|
+
end
|
152
172
|
removeJobKeys(jobKey)
|
153
173
|
end
|
154
174
|
local function removeJobs(keys, hard, baseKey, max)
|
155
175
|
for i, key in ipairs(keys) do
|
156
|
-
removeJob(key, hard, baseKey)
|
176
|
+
removeJob(key, hard, baseKey, true --[[remove debounce key]])
|
157
177
|
end
|
158
178
|
return max - #keys
|
159
179
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"drain-4.js","sourceRoot":"","sources":["../../../src/scripts/drain-4.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"drain-4.js","sourceRoot":"","sources":["../../../src/scripts/drain-4.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmOf,CAAC;AACF,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -170,6 +170,18 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
173
|
+
--[[
|
174
|
+
Function to remove debounce key if needed.
|
175
|
+
]]
|
176
|
+
local function removeDebounceKeyIfNeeded(prefixKey, debounceId)
|
177
|
+
if debounceId then
|
178
|
+
local debounceKey = prefixKey .. "de:" .. debounceId
|
179
|
+
local pttl = rcall("PTTL", debounceKey)
|
180
|
+
if pttl == 0 or pttl == -1 then
|
181
|
+
rcall("DEL", debounceKey)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
173
185
|
local function moveParentFromWaitingChildrenToFailed( parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
174
186
|
if rcall("ZREM", parentQueueKey .. ":waiting-children", parentId) == 1 then
|
175
187
|
rcall("ZADD", parentQueueKey .. ":failed", timestamp, parentId)
|
@@ -177,9 +189,10 @@ local function moveParentFromWaitingChildrenToFailed( parentQueueKey, parentKey,
|
|
177
189
|
rcall("HMSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
|
178
190
|
rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
|
179
191
|
failedReason, "prev", "waiting-children")
|
180
|
-
local
|
181
|
-
|
182
|
-
|
192
|
+
local jobAttributes = rcall("HMGET", parentKey, "parent", "deid")
|
193
|
+
removeDebounceKeyIfNeeded(parentQueueKey, jobAttributes[2])
|
194
|
+
if jobAttributes[1] then
|
195
|
+
local parentData = cjson.decode(jobAttributes[1])
|
183
196
|
if parentData['fpof'] then
|
184
197
|
moveParentFromWaitingChildrenToFailed(
|
185
198
|
parentData['queueKey'],
|
@@ -203,6 +216,16 @@ end
|
|
203
216
|
Function to remove job.
|
204
217
|
]]
|
205
218
|
-- Includes
|
219
|
+
--[[
|
220
|
+
Function to remove debounce key.
|
221
|
+
]]
|
222
|
+
local function removeDebounceKey(prefixKey, jobKey)
|
223
|
+
local debounceId = rcall("HGET", jobKey, "deid")
|
224
|
+
if debounceId then
|
225
|
+
local debounceKey = prefixKey .. "de:" .. debounceId
|
226
|
+
rcall("DEL", debounceKey)
|
227
|
+
end
|
228
|
+
end
|
206
229
|
--[[
|
207
230
|
Function to remove job keys.
|
208
231
|
]]
|
@@ -235,7 +258,7 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
235
258
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
236
259
|
end
|
237
260
|
end
|
238
|
-
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
261
|
+
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
|
239
262
|
if parentKey then
|
240
263
|
local parentDependenciesKey = parentKey .. ":dependencies"
|
241
264
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
@@ -248,8 +271,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
248
271
|
if numRemovedElements == 1 then
|
249
272
|
if hard then -- remove parent in same queue
|
250
273
|
if parentPrefix == baseKey then
|
251
|
-
removeParentDependencyKey(parentKey, hard, nil, baseKey)
|
274
|
+
removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
|
252
275
|
removeJobKeys(parentKey)
|
276
|
+
if debounceId then
|
277
|
+
rcall("DEL", parentPrefix .. "de:" .. debounceId)
|
278
|
+
end
|
253
279
|
else
|
254
280
|
moveParentToWait(parentPrefix, parentId)
|
255
281
|
end
|
@@ -261,7 +287,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
261
287
|
return true
|
262
288
|
end
|
263
289
|
else
|
264
|
-
local
|
290
|
+
local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
|
291
|
+
local missedParentKey = parentAttributes[1]
|
265
292
|
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
266
293
|
and (rcall("EXISTS", missedParentKey) == 1)) then
|
267
294
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
@@ -275,8 +302,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
275
302
|
if numRemovedElements == 1 then
|
276
303
|
if hard then
|
277
304
|
if parentPrefix == baseKey then
|
278
|
-
removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
|
305
|
+
removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
|
279
306
|
removeJobKeys(missedParentKey)
|
307
|
+
if parentAttributes[2] then
|
308
|
+
rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
|
309
|
+
end
|
280
310
|
else
|
281
311
|
moveParentToWait(parentPrefix, parentId)
|
282
312
|
end
|
@@ -291,20 +321,24 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
291
321
|
end
|
292
322
|
return false
|
293
323
|
end
|
294
|
-
local function removeJob(jobId, hard, baseKey)
|
324
|
+
local function removeJob(jobId, hard, baseKey, shouldRemoveDebounceKey)
|
295
325
|
local jobKey = baseKey .. jobId
|
296
326
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
327
|
+
if shouldRemoveDebounceKey then
|
328
|
+
removeDebounceKey(baseKey, jobKey)
|
329
|
+
end
|
297
330
|
removeJobKeys(jobKey)
|
298
331
|
end
|
299
332
|
--[[
|
300
333
|
Functions to remove jobs by max age.
|
301
334
|
]]
|
302
335
|
-- Includes
|
303
|
-
local function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix
|
336
|
+
local function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix,
|
337
|
+
shouldRemoveDebounceKey)
|
304
338
|
local start = timestamp - maxAge * 1000
|
305
339
|
local jobIds = rcall("ZREVRANGEBYSCORE", targetSet, start, "-inf")
|
306
340
|
for i, jobId in ipairs(jobIds) do
|
307
|
-
removeJob(jobId, false, prefix)
|
341
|
+
removeJob(jobId, false, prefix, false --[[remove debounce key]])
|
308
342
|
end
|
309
343
|
rcall("ZREMRANGEBYSCORE", targetSet, "-inf", start)
|
310
344
|
end
|
@@ -316,7 +350,7 @@ local function removeJobsByMaxCount(maxCount, targetSet, prefix)
|
|
316
350
|
local start = maxCount
|
317
351
|
local jobIds = rcall("ZREVRANGE", targetSet, start, -1)
|
318
352
|
for i, jobId in ipairs(jobIds) do
|
319
|
-
removeJob(jobId, false, prefix)
|
353
|
+
removeJob(jobId, false, prefix, false --[[remove debounce key]])
|
320
354
|
end
|
321
355
|
rcall("ZREMRANGEBYRANK", targetSet, 0, -(maxCount + 1))
|
322
356
|
end
|
@@ -384,12 +418,13 @@ if (#stalling > 0) then
|
|
384
418
|
local stalledCount =
|
385
419
|
rcall("HINCRBY", jobKey, "stalledCounter", 1)
|
386
420
|
if (stalledCount > MAX_STALLED_JOB_COUNT) then
|
387
|
-
local jobAttributes = rcall("HMGET", jobKey, "opts", "parent")
|
421
|
+
local jobAttributes = rcall("HMGET", jobKey, "opts", "parent", "deid")
|
388
422
|
local rawOpts = jobAttributes[1]
|
389
423
|
local rawParentData = jobAttributes[2]
|
390
424
|
local opts = cjson.decode(rawOpts)
|
391
425
|
local removeOnFailType = type(opts["removeOnFail"])
|
392
426
|
rcall("ZADD", failedKey, timestamp, jobId)
|
427
|
+
removeDebounceKeyIfNeeded(queueKeyPrefix, jobAttributes[3])
|
393
428
|
local failedReason =
|
394
429
|
"job stalled more than allowable limit"
|
395
430
|
rcall("HMSET", jobKey, "failedReason", failedReason,
|
@@ -422,7 +457,8 @@ if (#stalling > 0) then
|
|
422
457
|
failedKey, queueKeyPrefix)
|
423
458
|
elseif removeOnFailType == "boolean" then
|
424
459
|
if opts["removeOnFail"] then
|
425
|
-
removeJob(jobId, false, queueKeyPrefix
|
460
|
+
removeJob(jobId, false, queueKeyPrefix,
|
461
|
+
false --[[remove debounce key]])
|
426
462
|
rcall("ZREM", failedKey, jobId)
|
427
463
|
end
|
428
464
|
elseif removeOnFailType ~= "nil" then
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAofS,CAAC;AAC1B,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -263,6 +263,18 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
|
|
263
263
|
end
|
264
264
|
end
|
265
265
|
end
|
266
|
+
--[[
|
267
|
+
Function to remove debounce key if needed.
|
268
|
+
]]
|
269
|
+
local function removeDebounceKeyIfNeeded(prefixKey, debounceId)
|
270
|
+
if debounceId then
|
271
|
+
local debounceKey = prefixKey .. "de:" .. debounceId
|
272
|
+
local pttl = rcall("PTTL", debounceKey)
|
273
|
+
if pttl == 0 or pttl == -1 then
|
274
|
+
rcall("DEL", debounceKey)
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
266
278
|
local function moveParentFromWaitingChildrenToFailed( parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
|
267
279
|
if rcall("ZREM", parentQueueKey .. ":waiting-children", parentId) == 1 then
|
268
280
|
rcall("ZADD", parentQueueKey .. ":failed", timestamp, parentId)
|
@@ -270,9 +282,10 @@ local function moveParentFromWaitingChildrenToFailed( parentQueueKey, parentKey,
|
|
270
282
|
rcall("HMSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
|
271
283
|
rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
|
272
284
|
failedReason, "prev", "waiting-children")
|
273
|
-
local
|
274
|
-
|
275
|
-
|
285
|
+
local jobAttributes = rcall("HMGET", parentKey, "parent", "deid")
|
286
|
+
removeDebounceKeyIfNeeded(parentQueueKey, jobAttributes[2])
|
287
|
+
if jobAttributes[1] then
|
288
|
+
local parentData = cjson.decode(jobAttributes[1])
|
276
289
|
if parentData['fpof'] then
|
277
290
|
moveParentFromWaitingChildrenToFailed(
|
278
291
|
parentData['queueKey'],
|
@@ -373,6 +386,16 @@ end
|
|
373
386
|
Function to remove job.
|
374
387
|
]]
|
375
388
|
-- Includes
|
389
|
+
--[[
|
390
|
+
Function to remove debounce key.
|
391
|
+
]]
|
392
|
+
local function removeDebounceKey(prefixKey, jobKey)
|
393
|
+
local debounceId = rcall("HGET", jobKey, "deid")
|
394
|
+
if debounceId then
|
395
|
+
local debounceKey = prefixKey .. "de:" .. debounceId
|
396
|
+
rcall("DEL", debounceKey)
|
397
|
+
end
|
398
|
+
end
|
376
399
|
--[[
|
377
400
|
Check if this job has a parent. If so we will just remove it from
|
378
401
|
the parent child list, but if it is the last child we should move the parent to "wait/paused"
|
@@ -398,7 +421,7 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
398
421
|
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
399
422
|
end
|
400
423
|
end
|
401
|
-
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
424
|
+
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
|
402
425
|
if parentKey then
|
403
426
|
local parentDependenciesKey = parentKey .. ":dependencies"
|
404
427
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
@@ -411,8 +434,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
411
434
|
if numRemovedElements == 1 then
|
412
435
|
if hard then -- remove parent in same queue
|
413
436
|
if parentPrefix == baseKey then
|
414
|
-
removeParentDependencyKey(parentKey, hard, nil, baseKey)
|
437
|
+
removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
|
415
438
|
removeJobKeys(parentKey)
|
439
|
+
if debounceId then
|
440
|
+
rcall("DEL", parentPrefix .. "de:" .. debounceId)
|
441
|
+
end
|
416
442
|
else
|
417
443
|
moveParentToWait(parentPrefix, parentId)
|
418
444
|
end
|
@@ -424,7 +450,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
424
450
|
return true
|
425
451
|
end
|
426
452
|
else
|
427
|
-
local
|
453
|
+
local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
|
454
|
+
local missedParentKey = parentAttributes[1]
|
428
455
|
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
429
456
|
and (rcall("EXISTS", missedParentKey) == 1)) then
|
430
457
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
@@ -438,8 +465,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
438
465
|
if numRemovedElements == 1 then
|
439
466
|
if hard then
|
440
467
|
if parentPrefix == baseKey then
|
441
|
-
removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
|
468
|
+
removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
|
442
469
|
removeJobKeys(missedParentKey)
|
470
|
+
if parentAttributes[2] then
|
471
|
+
rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
|
472
|
+
end
|
443
473
|
else
|
444
474
|
moveParentToWait(parentPrefix, parentId)
|
445
475
|
end
|
@@ -454,16 +484,20 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
454
484
|
end
|
455
485
|
return false
|
456
486
|
end
|
457
|
-
local function removeJob(jobId, hard, baseKey)
|
487
|
+
local function removeJob(jobId, hard, baseKey, shouldRemoveDebounceKey)
|
458
488
|
local jobKey = baseKey .. jobId
|
459
489
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
490
|
+
if shouldRemoveDebounceKey then
|
491
|
+
removeDebounceKey(baseKey, jobKey)
|
492
|
+
end
|
460
493
|
removeJobKeys(jobKey)
|
461
494
|
end
|
462
|
-
local function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix
|
495
|
+
local function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix,
|
496
|
+
shouldRemoveDebounceKey)
|
463
497
|
local start = timestamp - maxAge * 1000
|
464
498
|
local jobIds = rcall("ZREVRANGEBYSCORE", targetSet, start, "-inf")
|
465
499
|
for i, jobId in ipairs(jobIds) do
|
466
|
-
removeJob(jobId, false, prefix)
|
500
|
+
removeJob(jobId, false, prefix, false --[[remove debounce key]])
|
467
501
|
end
|
468
502
|
rcall("ZREMRANGEBYSCORE", targetSet, "-inf", start)
|
469
503
|
end
|
@@ -475,7 +509,7 @@ local function removeJobsByMaxCount(maxCount, targetSet, prefix)
|
|
475
509
|
local start = maxCount
|
476
510
|
local jobIds = rcall("ZREVRANGE", targetSet, start, -1)
|
477
511
|
for i, jobId in ipairs(jobIds) do
|
478
|
-
removeJob(jobId, false, prefix)
|
512
|
+
removeJob(jobId, false, prefix, false --[[remove debounce key]])
|
479
513
|
end
|
480
514
|
rcall("ZREMRANGEBYRANK", targetSet, 0, -(maxCount + 1))
|
481
515
|
end
|
@@ -546,12 +580,12 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
546
580
|
if rcall("SCARD", jobIdKey .. ":dependencies") ~= 0 then -- // Make sure it does not have pending dependencies
|
547
581
|
return -4
|
548
582
|
end
|
549
|
-
local
|
550
|
-
local parentKey =
|
583
|
+
local jobAttributes = rcall("HMGET", jobIdKey, "parentKey", "parent", "deid")
|
584
|
+
local parentKey = jobAttributes[1] or ""
|
551
585
|
local parentId = ""
|
552
586
|
local parentQueueKey = ""
|
553
|
-
if
|
554
|
-
local jsonDecodedParent = cjson.decode(
|
587
|
+
if jobAttributes[2] ~= false then
|
588
|
+
local jsonDecodedParent = cjson.decode(jobAttributes[2])
|
555
589
|
parentId = jsonDecodedParent['id']
|
556
590
|
parentQueueKey = jsonDecodedParent['queueKey']
|
557
591
|
end
|
@@ -564,6 +598,8 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
564
598
|
local metaKey = KEYS[9]
|
565
599
|
-- Trim events before emiting them to avoid trimming events emitted in this script
|
566
600
|
trimEvents(metaKey, eventStreamKey)
|
601
|
+
local prefix = ARGV[7]
|
602
|
+
removeDebounceKeyIfNeeded(prefix, jobAttributes[3])
|
567
603
|
-- If job has a parent we need to
|
568
604
|
-- 1) remove this job id from parents dependencies
|
569
605
|
-- 2) move the job Id to parent "processed" set
|
@@ -608,7 +644,6 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
608
644
|
rcall("HMSET", jobIdKey, ARGV[3], ARGV[4], "finishedOn", timestamp)
|
609
645
|
-- "returnvalue" / "failedReason" and "finishedOn"
|
610
646
|
-- Remove old jobs?
|
611
|
-
local prefix = ARGV[7]
|
612
647
|
if maxAge ~= nil then
|
613
648
|
removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix)
|
614
649
|
end
|
@@ -621,7 +656,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
621
656
|
-- TODO: when a child is removed when finished, result or failure in parent
|
622
657
|
-- must not be deleted, those value references should be deleted when the parent
|
623
658
|
-- is deleted
|
624
|
-
removeParentDependencyKey(jobIdKey, false, parentKey)
|
659
|
+
removeParentDependencyKey(jobIdKey, false, parentKey, jobAttributes[3])
|
625
660
|
end
|
626
661
|
end
|
627
662
|
rcall("XADD", eventStreamKey, "*", "event", ARGV[5], "jobId", jobId, ARGV[3],
|
@@ -641,7 +676,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
641
676
|
if (ARGV[6] == "1") then
|
642
677
|
local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[2], KEYS[1], KEYS[8])
|
643
678
|
-- Check if there are delayed jobs that can be promoted
|
644
|
-
promoteDelayedJobs(KEYS[7], KEYS[14], target, KEYS[3], eventStreamKey,
|
679
|
+
promoteDelayedJobs(KEYS[7], KEYS[14], target, KEYS[3], eventStreamKey, prefix,
|
645
680
|
timestamp, KEYS[10], isPausedOrMaxed)
|
646
681
|
local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
|
647
682
|
-- Check if we are rate limited first.
|
@@ -659,19 +694,19 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
659
694
|
if jobId == "0:0" then
|
660
695
|
jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2],
|
661
696
|
KEYS[10])
|
662
|
-
return prepareJobForProcessing(
|
697
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId,
|
663
698
|
timestamp, maxJobs,
|
664
699
|
opts)
|
665
700
|
end
|
666
701
|
else
|
667
|
-
return prepareJobForProcessing(
|
702
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId,
|
668
703
|
timestamp, maxJobs,
|
669
704
|
opts)
|
670
705
|
end
|
671
706
|
else
|
672
707
|
jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2], KEYS[10])
|
673
708
|
if jobId then
|
674
|
-
return prepareJobForProcessing(
|
709
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId,
|
675
710
|
timestamp, maxJobs,
|
676
711
|
opts)
|
677
712
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+tBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|