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