bullmq 5.14.0 → 5.16.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/child-pool.js +9 -2
- package/dist/cjs/classes/child-pool.js.map +1 -1
- package/dist/cjs/classes/child.js +5 -6
- package/dist/cjs/classes/child.js.map +1 -1
- package/dist/cjs/classes/job-scheduler.js +140 -0
- package/dist/cjs/classes/job-scheduler.js.map +1 -0
- package/dist/cjs/classes/job.js +1 -1
- package/dist/cjs/classes/job.js.map +1 -1
- package/dist/cjs/classes/queue.js +64 -0
- package/dist/cjs/classes/queue.js.map +1 -1
- package/dist/cjs/classes/repeat.js +9 -10
- package/dist/cjs/classes/repeat.js.map +1 -1
- package/dist/cjs/classes/scripts.js +45 -39
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/classes/worker.js +25 -4
- package/dist/cjs/classes/worker.js.map +1 -1
- package/dist/cjs/commands/addJobScheduler-2.lua +75 -0
- package/dist/cjs/commands/{cleanJobsInSet-2.lua → cleanJobsInSet-3.lua} +6 -5
- package/dist/cjs/commands/drain-5.lua +41 -0
- package/dist/cjs/commands/includes/cleanSet.lua +50 -29
- package/dist/cjs/commands/includes/removeZSetJobs.lua +13 -1
- package/dist/cjs/commands/moveStalledJobsToWait-9.lua +2 -4
- package/dist/cjs/commands/removeJob-2.lua +17 -9
- package/dist/cjs/commands/removeJobScheduler-3.lua +43 -0
- package/dist/cjs/enums/error-code.js +1 -0
- package/dist/cjs/enums/error-code.js.map +1 -1
- package/dist/cjs/interfaces/index.js +1 -0
- package/dist/cjs/interfaces/index.js.map +1 -1
- package/dist/cjs/interfaces/sandboxed-options.js +3 -0
- package/dist/cjs/interfaces/sandboxed-options.js.map +1 -0
- package/dist/cjs/scripts/addJobScheduler-2.js +223 -0
- package/dist/cjs/scripts/addJobScheduler-2.js.map +1 -0
- package/dist/cjs/scripts/{cleanJobsInSet-2.js → cleanJobsInSet-3.js} +57 -35
- package/dist/cjs/scripts/{cleanJobsInSet-2.js.map → cleanJobsInSet-3.js.map} +1 -1
- package/dist/cjs/scripts/{drain-4.js → drain-5.js} +28 -7
- package/dist/cjs/scripts/drain-5.js.map +1 -0
- package/dist/cjs/scripts/index.js +4 -2
- package/dist/cjs/scripts/index.js.map +1 -1
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +2 -3
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/cjs/scripts/obliterate-2.js +11 -1
- package/dist/cjs/scripts/obliterate-2.js.map +1 -1
- package/dist/cjs/scripts/removeJob-2.js +16 -9
- package/dist/cjs/scripts/removeJob-2.js.map +1 -1
- package/dist/cjs/scripts/removeJobScheduler-3.js +49 -0
- package/dist/cjs/scripts/removeJobScheduler-3.js.map +1 -0
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/utils.js +25 -1
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/classes/child-pool.d.ts +3 -3
- package/dist/esm/classes/child-pool.js +9 -2
- package/dist/esm/classes/child-pool.js.map +1 -1
- package/dist/esm/classes/child.d.ts +3 -5
- package/dist/esm/classes/child.js +5 -6
- package/dist/esm/classes/child.js.map +1 -1
- package/dist/esm/classes/job-scheduler.d.ts +30 -0
- package/dist/esm/classes/job-scheduler.js +135 -0
- package/dist/esm/classes/job-scheduler.js.map +1 -0
- package/dist/esm/classes/job.d.ts +1 -1
- package/dist/esm/classes/job.js +2 -2
- package/dist/esm/classes/job.js.map +1 -1
- package/dist/esm/classes/queue.d.ts +47 -0
- package/dist/esm/classes/queue.js +64 -0
- package/dist/esm/classes/queue.js.map +1 -1
- package/dist/esm/classes/repeat.js +9 -10
- package/dist/esm/classes/repeat.js.map +1 -1
- package/dist/esm/classes/scripts.d.ts +3 -7
- package/dist/esm/classes/scripts.js +46 -40
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/classes/worker.d.ts +3 -0
- package/dist/esm/classes/worker.js +25 -4
- package/dist/esm/classes/worker.js.map +1 -1
- package/dist/esm/commands/addJobScheduler-2.lua +75 -0
- package/dist/esm/commands/{cleanJobsInSet-2.lua → cleanJobsInSet-3.lua} +6 -5
- package/dist/esm/commands/drain-5.lua +41 -0
- package/dist/esm/commands/includes/cleanSet.lua +50 -29
- package/dist/esm/commands/includes/removeZSetJobs.lua +13 -1
- package/dist/esm/commands/moveStalledJobsToWait-9.lua +2 -4
- package/dist/esm/commands/removeJob-2.lua +17 -9
- package/dist/esm/commands/removeJobScheduler-3.lua +43 -0
- package/dist/esm/enums/error-code.d.ts +2 -1
- package/dist/esm/enums/error-code.js +1 -0
- package/dist/esm/enums/error-code.js.map +1 -1
- 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/sandboxed-options.d.ts +28 -0
- package/dist/esm/interfaces/sandboxed-options.js +2 -0
- package/dist/esm/interfaces/sandboxed-options.js.map +1 -0
- package/dist/esm/interfaces/worker-options.d.ts +2 -18
- package/dist/esm/scripts/addJobScheduler-2.d.ts +5 -0
- package/dist/esm/scripts/addJobScheduler-2.js +220 -0
- package/dist/esm/scripts/addJobScheduler-2.js.map +1 -0
- package/dist/esm/scripts/{cleanJobsInSet-2.js → cleanJobsInSet-3.js} +57 -35
- package/dist/esm/scripts/{cleanJobsInSet-2.js.map → cleanJobsInSet-3.js.map} +1 -1
- package/dist/esm/scripts/{drain-4.js → drain-5.js} +28 -7
- package/dist/esm/scripts/drain-5.js.map +1 -0
- package/dist/esm/scripts/index.d.ts +4 -2
- package/dist/esm/scripts/index.js +4 -2
- package/dist/esm/scripts/index.js.map +1 -1
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +2 -3
- package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/esm/scripts/obliterate-2.js +11 -1
- package/dist/esm/scripts/obliterate-2.js.map +1 -1
- package/dist/esm/scripts/removeJob-2.js +16 -9
- package/dist/esm/scripts/removeJob-2.js.map +1 -1
- package/dist/esm/scripts/removeJobScheduler-3.d.ts +5 -0
- package/dist/esm/scripts/removeJobScheduler-3.js +46 -0
- package/dist/esm/scripts/removeJobScheduler-3.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/utils.d.ts +7 -0
- package/dist/esm/utils.js +23 -0
- package/dist/esm/utils.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/commands/drain-4.lua +0 -26
- package/dist/cjs/scripts/drain-4.js.map +0 -1
- package/dist/esm/commands/drain-4.lua +0 -26
- package/dist/esm/scripts/drain-4.js.map +0 -1
- /package/dist/esm/scripts/{cleanJobsInSet-2.d.ts → cleanJobsInSet-3.d.ts} +0 -0
- /package/dist/esm/scripts/{drain-4.d.ts → drain-5.d.ts} +0 -0
@@ -0,0 +1,220 @@
|
|
1
|
+
const content = `--[[
|
2
|
+
Adds a job scheduler, i.e. a job factory that creates jobs based on a given schedule (repeat options).
|
3
|
+
Input:
|
4
|
+
KEYS[1] 'repeat' key
|
5
|
+
KEYS[2] 'delayed' key
|
6
|
+
ARGV[1] next milliseconds
|
7
|
+
ARGV[2] msgpacked options
|
8
|
+
[1] name
|
9
|
+
[2] tz?
|
10
|
+
[3] patten?
|
11
|
+
[4] endDate?
|
12
|
+
[5] every?
|
13
|
+
ARGV[3] jobs scheduler id
|
14
|
+
ARGV[4] prefix key
|
15
|
+
Output:
|
16
|
+
repeatableKey - OK
|
17
|
+
]]
|
18
|
+
local rcall = redis.call
|
19
|
+
local repeatKey = KEYS[1]
|
20
|
+
local delayedKey = KEYS[2]
|
21
|
+
local nextMillis = ARGV[1]
|
22
|
+
local jobSchedulerId = ARGV[3]
|
23
|
+
local prefixKey = ARGV[4]
|
24
|
+
-- Includes
|
25
|
+
--[[
|
26
|
+
Function to remove job.
|
27
|
+
]]
|
28
|
+
-- Includes
|
29
|
+
--[[
|
30
|
+
Function to remove debounce key.
|
31
|
+
]]
|
32
|
+
local function removeDebounceKey(prefixKey, jobKey)
|
33
|
+
local debounceId = rcall("HGET", jobKey, "deid")
|
34
|
+
if debounceId then
|
35
|
+
local debounceKey = prefixKey .. "de:" .. debounceId
|
36
|
+
rcall("DEL", debounceKey)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
--[[
|
40
|
+
Function to remove job keys.
|
41
|
+
]]
|
42
|
+
local function removeJobKeys(jobKey)
|
43
|
+
return rcall("DEL", jobKey, jobKey .. ':logs',
|
44
|
+
jobKey .. ':dependencies', jobKey .. ':processed', jobKey .. ':failed')
|
45
|
+
end
|
46
|
+
--[[
|
47
|
+
Check if this job has a parent. If so we will just remove it from
|
48
|
+
the parent child list, but if it is the last child we should move the parent to "wait/paused"
|
49
|
+
which requires code from "moveToFinished"
|
50
|
+
]]
|
51
|
+
-- Includes
|
52
|
+
--[[
|
53
|
+
Function to add job in target list and add marker if needed.
|
54
|
+
]]
|
55
|
+
-- Includes
|
56
|
+
--[[
|
57
|
+
Add marker if needed when a job is available.
|
58
|
+
]]
|
59
|
+
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
60
|
+
if not isPausedOrMaxed then
|
61
|
+
rcall("ZADD", markerKey, 0, "0")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
|
65
|
+
rcall(pushCmd, targetKey, jobId)
|
66
|
+
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
67
|
+
end
|
68
|
+
--[[
|
69
|
+
Functions to destructure job key.
|
70
|
+
Just a bit of warning, these functions may be a bit slow and affect performance significantly.
|
71
|
+
]]
|
72
|
+
local getJobIdFromKey = function (jobKey)
|
73
|
+
return string.match(jobKey, ".*:(.*)")
|
74
|
+
end
|
75
|
+
local getJobKeyPrefix = function (jobKey, jobId)
|
76
|
+
return string.sub(jobKey, 0, #jobKey - #jobId)
|
77
|
+
end
|
78
|
+
--[[
|
79
|
+
Function to check for the meta.paused key to decide if we are paused or not
|
80
|
+
(since an empty list and !EXISTS are not really the same).
|
81
|
+
]]
|
82
|
+
local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
|
83
|
+
local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
|
84
|
+
if queueAttributes[1] then
|
85
|
+
return pausedKey, true
|
86
|
+
else
|
87
|
+
if queueAttributes[2] then
|
88
|
+
local activeCount = rcall("LLEN", activeKey)
|
89
|
+
if activeCount >= tonumber(queueAttributes[2]) then
|
90
|
+
return waitKey, true
|
91
|
+
else
|
92
|
+
return waitKey, false
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
return waitKey, false
|
97
|
+
end
|
98
|
+
local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
99
|
+
local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
|
100
|
+
parentPrefix .. "wait", parentPrefix .. "paused")
|
101
|
+
addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
|
102
|
+
if emitEvent then
|
103
|
+
local parentEventStream = parentPrefix .. "events"
|
104
|
+
rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
|
108
|
+
if parentKey then
|
109
|
+
local parentDependenciesKey = parentKey .. ":dependencies"
|
110
|
+
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
111
|
+
if result > 0 then
|
112
|
+
local pendingDependencies = rcall("SCARD", parentDependenciesKey)
|
113
|
+
if pendingDependencies == 0 then
|
114
|
+
local parentId = getJobIdFromKey(parentKey)
|
115
|
+
local parentPrefix = getJobKeyPrefix(parentKey, parentId)
|
116
|
+
local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)
|
117
|
+
if numRemovedElements == 1 then
|
118
|
+
if hard then -- remove parent in same queue
|
119
|
+
if parentPrefix == baseKey then
|
120
|
+
removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
|
121
|
+
removeJobKeys(parentKey)
|
122
|
+
if debounceId then
|
123
|
+
rcall("DEL", parentPrefix .. "de:" .. debounceId)
|
124
|
+
end
|
125
|
+
else
|
126
|
+
moveParentToWait(parentPrefix, parentId)
|
127
|
+
end
|
128
|
+
else
|
129
|
+
moveParentToWait(parentPrefix, parentId, true)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
return true
|
134
|
+
end
|
135
|
+
else
|
136
|
+
local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
|
137
|
+
local missedParentKey = parentAttributes[1]
|
138
|
+
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
139
|
+
and (rcall("EXISTS", missedParentKey) == 1)) then
|
140
|
+
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
141
|
+
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
142
|
+
if result > 0 then
|
143
|
+
local pendingDependencies = rcall("SCARD", parentDependenciesKey)
|
144
|
+
if pendingDependencies == 0 then
|
145
|
+
local parentId = getJobIdFromKey(missedParentKey)
|
146
|
+
local parentPrefix = getJobKeyPrefix(missedParentKey, parentId)
|
147
|
+
local numRemovedElements = rcall("ZREM", parentPrefix .. "waiting-children", parentId)
|
148
|
+
if numRemovedElements == 1 then
|
149
|
+
if hard then
|
150
|
+
if parentPrefix == baseKey then
|
151
|
+
removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
|
152
|
+
removeJobKeys(missedParentKey)
|
153
|
+
if parentAttributes[2] then
|
154
|
+
rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
|
155
|
+
end
|
156
|
+
else
|
157
|
+
moveParentToWait(parentPrefix, parentId)
|
158
|
+
end
|
159
|
+
else
|
160
|
+
moveParentToWait(parentPrefix, parentId, true)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
return true
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
return false
|
169
|
+
end
|
170
|
+
local function removeJob(jobId, hard, baseKey, shouldRemoveDebounceKey)
|
171
|
+
local jobKey = baseKey .. jobId
|
172
|
+
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
173
|
+
if shouldRemoveDebounceKey then
|
174
|
+
removeDebounceKey(baseKey, jobKey)
|
175
|
+
end
|
176
|
+
removeJobKeys(jobKey)
|
177
|
+
end
|
178
|
+
local function storeRepeatableJob(repeatKey, nextMillis, rawOpts)
|
179
|
+
rcall("ZADD", repeatKey, nextMillis, jobSchedulerId)
|
180
|
+
local opts = cmsgpack.unpack(rawOpts)
|
181
|
+
local optionalValues = {}
|
182
|
+
if opts['tz'] then
|
183
|
+
table.insert(optionalValues, "tz")
|
184
|
+
table.insert(optionalValues, opts['tz'])
|
185
|
+
end
|
186
|
+
if opts['pattern'] then
|
187
|
+
table.insert(optionalValues, "pattern")
|
188
|
+
table.insert(optionalValues, opts['pattern'])
|
189
|
+
end
|
190
|
+
if opts['endDate'] then
|
191
|
+
table.insert(optionalValues, "endDate")
|
192
|
+
table.insert(optionalValues, opts['endDate'])
|
193
|
+
end
|
194
|
+
if opts['every'] then
|
195
|
+
table.insert(optionalValues, "every")
|
196
|
+
table.insert(optionalValues, opts['every'])
|
197
|
+
end
|
198
|
+
rcall("HMSET", repeatKey .. ":" .. jobSchedulerId, "name", opts['name'],
|
199
|
+
unpack(optionalValues))
|
200
|
+
end
|
201
|
+
-- If we are overriding a repeatable job we must delete the delayed job for
|
202
|
+
-- the next iteration.
|
203
|
+
local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
|
204
|
+
if prevMillis ~= false then
|
205
|
+
local delayedJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
|
206
|
+
local nextDelayedJobId = repeatKey .. ":" .. jobSchedulerId .. ":" .. nextMillis
|
207
|
+
if rcall("ZSCORE", delayedKey, delayedJobId) ~= false
|
208
|
+
and rcall("EXISTS", nextDelayedJobId) ~= 1 then
|
209
|
+
removeJob(delayedJobId, true, prefixKey, true --[[remove debounce key]])
|
210
|
+
rcall("ZREM", delayedKey, delayedJobId)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
return storeRepeatableJob(repeatKey, nextMillis, ARGV[2])
|
214
|
+
`;
|
215
|
+
export const addJobScheduler = {
|
216
|
+
name: 'addJobScheduler',
|
217
|
+
content,
|
218
|
+
keys: 2,
|
219
|
+
};
|
220
|
+
//# sourceMappingURL=addJobScheduler-2.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"addJobScheduler-2.js","sourceRoot":"","sources":["../../../src/scripts/addJobScheduler-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqNf,CAAC;AACF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -3,6 +3,7 @@ const content = `--[[
|
|
3
3
|
Input:
|
4
4
|
KEYS[1] set key,
|
5
5
|
KEYS[2] events stream key
|
6
|
+
KEYS[3] job schedulers key
|
6
7
|
ARGV[1] jobKey prefix
|
7
8
|
ARGV[2] timestamp
|
8
9
|
ARGV[3] limit the number of jobs to be removed. 0 is unlimited
|
@@ -234,7 +235,7 @@ end
|
|
234
235
|
--[[
|
235
236
|
Function to clean job set.
|
236
237
|
Returns jobIds and deleted count number.
|
237
|
-
]]
|
238
|
+
]]
|
238
239
|
-- Includes
|
239
240
|
--[[
|
240
241
|
Function to loop in batches.
|
@@ -265,54 +266,75 @@ local function getJobsInZset(zsetKey, rangeEnd, limit)
|
|
265
266
|
return rcall("ZRANGEBYSCORE", zsetKey, 0, rangeEnd)
|
266
267
|
end
|
267
268
|
end
|
268
|
-
local function
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
if limit > 0 and deletedCount >= limit then
|
275
|
-
break
|
269
|
+
local function isJobSchedulerJob(jobId, jobSchedulersKey)
|
270
|
+
if jobSchedulersKey then
|
271
|
+
local jobSchedulerId = jobId:match("repeat:(.*):%d+")
|
272
|
+
if jobSchedulerId then
|
273
|
+
return rcall("ZSCORE", jobSchedulersKey, jobSchedulerId)
|
274
|
+
end
|
276
275
|
end
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
276
|
+
return false
|
277
|
+
end
|
278
|
+
local function cleanSet(
|
279
|
+
setKey,
|
280
|
+
jobKeyPrefix,
|
281
|
+
rangeEnd,
|
282
|
+
timestamp,
|
283
|
+
limit,
|
284
|
+
attributes,
|
285
|
+
isFinished,
|
286
|
+
jobSchedulersKey)
|
287
|
+
local jobs = getJobsInZset(setKey, rangeEnd, limit)
|
288
|
+
local deleted = {}
|
289
|
+
local deletedCount = 0
|
290
|
+
local jobTS
|
291
|
+
for i, job in ipairs(jobs) do
|
292
|
+
if limit > 0 and deletedCount >= limit then
|
293
|
+
break
|
294
|
+
end
|
295
|
+
-- Extract a Job Scheduler Id from jobId ("repeat:job-scheduler-id:millis")
|
296
|
+
-- and check if it is in the scheduled jobs
|
297
|
+
if not isJobSchedulerJob(job, jobSchedulersKey) then
|
298
|
+
local jobKey = jobKeyPrefix .. job
|
299
|
+
if isFinished then
|
300
|
+
removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]] )
|
301
|
+
deletedCount = deletedCount + 1
|
302
|
+
table.insert(deleted, job)
|
303
|
+
else
|
304
|
+
-- * finishedOn says when the job was completed, but it isn't set unless the job has actually completed
|
305
|
+
jobTS = getTimestamp(jobKey, attributes)
|
306
|
+
if (not jobTS or jobTS <= timestamp) then
|
307
|
+
removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]] )
|
308
|
+
deletedCount = deletedCount + 1
|
309
|
+
table.insert(deleted, job)
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
290
313
|
end
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
314
|
+
if (#deleted > 0) then
|
315
|
+
for from, to in batches(#deleted, 7000) do
|
316
|
+
rcall("ZREM", setKey, unpack(deleted, from, to))
|
317
|
+
end
|
295
318
|
end
|
296
|
-
|
297
|
-
return {deleted, deletedCount}
|
319
|
+
return {deleted, deletedCount}
|
298
320
|
end
|
299
321
|
local result
|
300
322
|
if ARGV[4] == "active" then
|
301
|
-
result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], false)
|
323
|
+
result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], false --[[ hasFinished ]])
|
302
324
|
elseif ARGV[4] == "delayed" then
|
303
325
|
rangeEnd = "+inf"
|
304
326
|
result = cleanSet(KEYS[1], ARGV[1], rangeEnd, ARGV[2], limit,
|
305
|
-
{"processedOn", "timestamp"}, false)
|
327
|
+
{"processedOn", "timestamp"}, false --[[ hasFinished ]], KEYS[3])
|
306
328
|
elseif ARGV[4] == "prioritized" then
|
307
329
|
rangeEnd = "+inf"
|
308
330
|
result = cleanSet(KEYS[1], ARGV[1], rangeEnd, ARGV[2], limit,
|
309
|
-
{"timestamp"}, false)
|
331
|
+
{"timestamp"}, false --[[ hasFinished ]])
|
310
332
|
elseif ARGV[4] == "wait" or ARGV[4] == "paused" then
|
311
|
-
result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], true)
|
333
|
+
result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], true --[[ hasFinished ]])
|
312
334
|
else
|
313
335
|
rangeEnd = ARGV[2]
|
314
336
|
result = cleanSet(KEYS[1], ARGV[1], rangeEnd, ARGV[2], limit,
|
315
|
-
{"finishedOn"}, true)
|
337
|
+
{"finishedOn"}, true --[[ hasFinished ]])
|
316
338
|
end
|
317
339
|
rcall("XADD", KEYS[2], "*", "event", "cleaned", "count", result[2])
|
318
340
|
return result[1]
|
@@ -320,6 +342,6 @@ return result[1]
|
|
320
342
|
export const cleanJobsInSet = {
|
321
343
|
name: 'cleanJobsInSet',
|
322
344
|
content,
|
323
|
-
keys:
|
345
|
+
keys: 3,
|
324
346
|
};
|
325
|
-
//# sourceMappingURL=cleanJobsInSet-
|
347
|
+
//# sourceMappingURL=cleanJobsInSet-3.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cleanJobsInSet-
|
1
|
+
{"version":3,"file":"cleanJobsInSet-3.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-3.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoVf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -6,6 +6,7 @@ const content = `--[[
|
|
6
6
|
KEYS[2] 'paused'
|
7
7
|
KEYS[3] 'delayed'
|
8
8
|
KEYS[4] 'prioritized'
|
9
|
+
KEYS[5] 'jobschedulers' (repeat)
|
9
10
|
ARGV[1] queue key prefix
|
10
11
|
]]
|
11
12
|
local rcall = redis.call
|
@@ -209,8 +210,18 @@ end
|
|
209
210
|
local function getZSetItems(keyName, max)
|
210
211
|
return rcall('ZRANGE', keyName, 0, max - 1)
|
211
212
|
end
|
212
|
-
local function removeZSetJobs(keyName, hard, baseKey, max)
|
213
|
+
local function removeZSetJobs(keyName, hard, baseKey, max, jobsToIgnore)
|
213
214
|
local jobs = getZSetItems(keyName, max)
|
215
|
+
-- filter out jobs to ignore
|
216
|
+
if jobsToIgnore then
|
217
|
+
local filteredJobs = {}
|
218
|
+
for i = 1, #jobs do
|
219
|
+
if not jobsToIgnore[jobs[i]] then
|
220
|
+
table.insert(filteredJobs, jobs[i])
|
221
|
+
end
|
222
|
+
end
|
223
|
+
jobs = filteredJobs
|
224
|
+
end
|
214
225
|
local count = removeJobs(jobs, hard, baseKey, max)
|
215
226
|
if(#jobs > 0) then
|
216
227
|
for from, to in batches(#jobs, 7000) do
|
@@ -219,16 +230,26 @@ local function removeZSetJobs(keyName, hard, baseKey, max)
|
|
219
230
|
end
|
220
231
|
return count
|
221
232
|
end
|
222
|
-
removeListJobs(KEYS[1], true, queueBaseKey, 0) --wait
|
223
|
-
removeListJobs(KEYS[2], true, queueBaseKey, 0) --paused
|
233
|
+
removeListJobs(KEYS[1], true, queueBaseKey, 0) -- wait
|
234
|
+
removeListJobs(KEYS[2], true, queueBaseKey, 0) -- paused
|
224
235
|
if KEYS[3] ~= "" then
|
225
|
-
|
236
|
+
-- We must not remove delayed jobs if they are associated to a job scheduler.
|
237
|
+
local scheduledJobs = {}
|
238
|
+
local jobSchedulers = rcall("ZRANGE", KEYS[5], 0, -1, "WITHSCORES")
|
239
|
+
-- For every job scheduler, get the current delayed job id.
|
240
|
+
for i = 1, #jobSchedulers, 2 do
|
241
|
+
local jobSchedulerId = jobSchedulers[i]
|
242
|
+
local jobSchedulerMillis = jobSchedulers[i + 1]
|
243
|
+
local delayedJobId = "repeat:" .. jobSchedulerId .. ":" .. jobSchedulerMillis
|
244
|
+
scheduledJobs[delayedJobId] = true
|
245
|
+
end
|
246
|
+
removeZSetJobs(KEYS[3], true, queueBaseKey, 0, scheduledJobs) -- delayed
|
226
247
|
end
|
227
|
-
removeZSetJobs(KEYS[4], true, queueBaseKey, 0) --prioritized
|
248
|
+
removeZSetJobs(KEYS[4], true, queueBaseKey, 0) -- prioritized
|
228
249
|
`;
|
229
250
|
export const drain = {
|
230
251
|
name: 'drain',
|
231
252
|
content,
|
232
|
-
keys:
|
253
|
+
keys: 5,
|
233
254
|
};
|
234
|
-
//# sourceMappingURL=drain-
|
255
|
+
//# sourceMappingURL=drain-5.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"drain-5.js","sourceRoot":"","sources":["../../../src/scripts/drain-5.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwPf,CAAC;AACF,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export * from './addDelayedJob-6';
|
2
|
+
export * from './addJobScheduler-2';
|
2
3
|
export * from './addLog-2';
|
3
4
|
export * from './addParentJob-4';
|
4
5
|
export * from './addPrioritizedJob-8';
|
@@ -6,8 +7,8 @@ export * from './addRepeatableJob-2';
|
|
6
7
|
export * from './addStandardJob-8';
|
7
8
|
export * from './changeDelay-4';
|
8
9
|
export * from './changePriority-7';
|
9
|
-
export * from './cleanJobsInSet-
|
10
|
-
export * from './drain-
|
10
|
+
export * from './cleanJobsInSet-3';
|
11
|
+
export * from './drain-5';
|
11
12
|
export * from './extendLock-2';
|
12
13
|
export * from './getCounts-1';
|
13
14
|
export * from './getCountsPerPriority-4';
|
@@ -32,6 +33,7 @@ export * from './promote-9';
|
|
32
33
|
export * from './releaseLock-1';
|
33
34
|
export * from './removeChildDependency-1';
|
34
35
|
export * from './removeJob-2';
|
36
|
+
export * from './removeJobScheduler-3';
|
35
37
|
export * from './removeRepeatable-3';
|
36
38
|
export * from './reprocessJob-8';
|
37
39
|
export * from './retryJob-11';
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export * from './addDelayedJob-6';
|
2
|
+
export * from './addJobScheduler-2';
|
2
3
|
export * from './addLog-2';
|
3
4
|
export * from './addParentJob-4';
|
4
5
|
export * from './addPrioritizedJob-8';
|
@@ -6,8 +7,8 @@ export * from './addRepeatableJob-2';
|
|
6
7
|
export * from './addStandardJob-8';
|
7
8
|
export * from './changeDelay-4';
|
8
9
|
export * from './changePriority-7';
|
9
|
-
export * from './cleanJobsInSet-
|
10
|
-
export * from './drain-
|
10
|
+
export * from './cleanJobsInSet-3';
|
11
|
+
export * from './drain-5';
|
11
12
|
export * from './extendLock-2';
|
12
13
|
export * from './getCounts-1';
|
13
14
|
export * from './getCountsPerPriority-4';
|
@@ -32,6 +33,7 @@ export * from './promote-9';
|
|
32
33
|
export * from './releaseLock-1';
|
33
34
|
export * from './removeChildDependency-1';
|
34
35
|
export * from './removeJob-2';
|
36
|
+
export * from './removeJobScheduler-3';
|
35
37
|
export * from './removeRepeatable-3';
|
36
38
|
export * from './reprocessJob-8';
|
37
39
|
export * from './retryJob-11';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC"}
|
@@ -390,7 +390,7 @@ local metaKey = KEYS[6]
|
|
390
390
|
local pausedKey = KEYS[7]
|
391
391
|
local markerKey = KEYS[8]
|
392
392
|
local eventStreamKey = KEYS[9]
|
393
|
-
local maxStalledJobCount = ARGV[1]
|
393
|
+
local maxStalledJobCount = tonumber(ARGV[1])
|
394
394
|
local queueKeyPrefix = ARGV[2]
|
395
395
|
local timestamp = ARGV[3]
|
396
396
|
local maxCheckTime = ARGV[4]
|
@@ -404,7 +404,6 @@ local stalled = {}
|
|
404
404
|
local failed = {}
|
405
405
|
if (#stalling > 0) then
|
406
406
|
rcall('DEL', stalledKey)
|
407
|
-
local MAX_STALLED_JOB_COUNT = tonumber(maxStalledJobCount)
|
408
407
|
-- Remove from active list
|
409
408
|
for i, jobId in ipairs(stalling) do
|
410
409
|
-- Markers in waitlist DEPRECATED in v5: Remove in v6.
|
@@ -421,7 +420,7 @@ if (#stalling > 0) then
|
|
421
420
|
-- If this job has been stalled too many times, such as if it crashes the worker, then fail it.
|
422
421
|
local stalledCount =
|
423
422
|
rcall("HINCRBY", jobKey, "stalledCounter", 1)
|
424
|
-
if (stalledCount >
|
423
|
+
if (stalledCount > maxStalledJobCount) then
|
425
424
|
local jobAttributes = rcall("HMGET", jobKey, "opts", "parent", "deid")
|
426
425
|
local rawOpts = jobAttributes[1]
|
427
426
|
local rawParentData = jobAttributes[2]
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBA2fS,CAAC;AAC1B,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -215,8 +215,18 @@ end
|
|
215
215
|
local function getZSetItems(keyName, max)
|
216
216
|
return rcall('ZRANGE', keyName, 0, max - 1)
|
217
217
|
end
|
218
|
-
local function removeZSetJobs(keyName, hard, baseKey, max)
|
218
|
+
local function removeZSetJobs(keyName, hard, baseKey, max, jobsToIgnore)
|
219
219
|
local jobs = getZSetItems(keyName, max)
|
220
|
+
-- filter out jobs to ignore
|
221
|
+
if jobsToIgnore then
|
222
|
+
local filteredJobs = {}
|
223
|
+
for i = 1, #jobs do
|
224
|
+
if not jobsToIgnore[jobs[i]] then
|
225
|
+
table.insert(filteredJobs, jobs[i])
|
226
|
+
end
|
227
|
+
end
|
228
|
+
jobs = filteredJobs
|
229
|
+
end
|
220
230
|
local count = removeJobs(jobs, hard, baseKey, max)
|
221
231
|
if(#jobs > 0) then
|
222
232
|
for from, to in batches(#jobs, 7000) do
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"obliterate-2.js","sourceRoot":"","sources":["../../../src/scripts/obliterate-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"obliterate-2.js","sourceRoot":"","sources":["../../../src/scripts/obliterate-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Tf,CAAC;AACF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -225,20 +225,20 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debou
|
|
225
225
|
end
|
226
226
|
return false
|
227
227
|
end
|
228
|
-
local function removeJob(
|
228
|
+
local function removeJob(prefix, jobId, parentKey, removeChildren)
|
229
229
|
local jobKey = prefix .. jobId;
|
230
230
|
removeParentDependencyKey(jobKey, false, parentKey, nil)
|
231
231
|
if removeChildren == "1" then
|
232
232
|
-- Check if this job has children
|
233
233
|
-- If so, we are going to try to remove the children recursively in deep first way because
|
234
234
|
-- if some job is locked we must exit with and error.
|
235
|
-
--local countProcessed = rcall("HLEN", jobKey .. ":processed")
|
235
|
+
-- local countProcessed = rcall("HLEN", jobKey .. ":processed")
|
236
236
|
local processed = rcall("HGETALL", jobKey .. ":processed")
|
237
237
|
if (#processed > 0) then
|
238
238
|
for i = 1, #processed, 2 do
|
239
239
|
local childJobId = getJobIdFromKey(processed[i])
|
240
240
|
local childJobPrefix = getJobKeyPrefix(processed[i], childJobId)
|
241
|
-
removeJob(
|
241
|
+
removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
|
242
242
|
end
|
243
243
|
end
|
244
244
|
local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")
|
@@ -247,7 +247,7 @@ local function removeJob( prefix, jobId, parentKey, removeChildren)
|
|
247
247
|
-- We need to get the jobId for this job.
|
248
248
|
local childJobId = getJobIdFromKey(childJobKey)
|
249
249
|
local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)
|
250
|
-
removeJob(
|
250
|
+
removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
|
251
251
|
end
|
252
252
|
end
|
253
253
|
local failed = rcall("HGETALL", jobKey .. ":failed")
|
@@ -255,7 +255,7 @@ local function removeJob( prefix, jobId, parentKey, removeChildren)
|
|
255
255
|
for i = 1, #failed, 2 do
|
256
256
|
local childJobId = getJobIdFromKey(failed[i])
|
257
257
|
local childJobPrefix = getJobKeyPrefix(failed[i], childJobId)
|
258
|
-
removeJob(
|
258
|
+
removeJob(childJobPrefix, childJobId, jobKey, removeChildren)
|
259
259
|
end
|
260
260
|
end
|
261
261
|
end
|
@@ -263,13 +263,20 @@ local function removeJob( prefix, jobId, parentKey, removeChildren)
|
|
263
263
|
removeDebounceKey(prefix, jobKey)
|
264
264
|
if removeJobKeys(jobKey) > 0 then
|
265
265
|
local maxEvents = getOrSetMaxEvents(KEYS[2])
|
266
|
-
rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",
|
267
|
-
|
266
|
+
rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed", "jobId", jobId, "prev",
|
267
|
+
prev)
|
268
268
|
end
|
269
269
|
end
|
270
270
|
local prefix = KEYS[1]
|
271
|
-
|
272
|
-
|
271
|
+
local jobId = ARGV[1]
|
272
|
+
local shouldRemoveChildren = ARGV[2]
|
273
|
+
local jobKey = prefix .. jobId
|
274
|
+
-- Check if the job belongs to a job scheduler and it is in delayed state.
|
275
|
+
if rcall("ZSCORE", prefix .. "delayed", jobId) and rcall("HGET", jobKey, "rjk") then
|
276
|
+
return -8 -- Return error code as the job is part of a job scheduler and is in delayed state.
|
277
|
+
end
|
278
|
+
if not isLocked(prefix, jobId, shouldRemoveChildren) then
|
279
|
+
removeJob(prefix, jobId, nil, shouldRemoveChildren)
|
273
280
|
return 1
|
274
281
|
end
|
275
282
|
return 0
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"removeJob-2.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"removeJob-2.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Rf,CAAC;AACF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|