bullmq 5.40.5 → 5.41.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 +9 -0
- package/dist/cjs/classes/job.js.map +1 -1
- package/dist/cjs/classes/queue.js +7 -0
- package/dist/cjs/classes/queue.js.map +1 -1
- package/dist/cjs/classes/scripts.js +2 -2
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/classes/worker.js +1 -1
- package/dist/cjs/classes/worker.js.map +1 -1
- package/dist/cjs/commands/cleanJobsInSet-3.lua +4 -2
- package/dist/cjs/commands/drain-5.lua +15 -16
- package/dist/cjs/commands/includes/cleanList.lua +4 -2
- package/dist/cjs/commands/includes/cleanSet.lua +3 -11
- package/dist/cjs/commands/includes/filterOutJobsToIgnore.lua +14 -0
- package/dist/cjs/commands/includes/isJobSchedulerJob.lua +15 -0
- package/dist/cjs/commands/includes/removeListJobs.lua +7 -1
- package/dist/cjs/commands/includes/removeZSetJobs.lua +2 -8
- package/dist/cjs/commands/{removeJob-2.lua → removeJob-3.lua} +5 -3
- package/dist/cjs/scripts/cleanJobsInSet-3.js +24 -15
- package/dist/cjs/scripts/cleanJobsInSet-3.js.map +1 -1
- package/dist/cjs/scripts/drain-5.js +31 -23
- package/dist/cjs/scripts/drain-5.js.map +1 -1
- package/dist/cjs/scripts/index.js +1 -1
- package/dist/cjs/scripts/obliterate-2.js +17 -9
- package/dist/cjs/scripts/obliterate-2.js.map +1 -1
- package/dist/cjs/scripts/{removeJob-2.js → removeJob-3.js} +21 -5
- package/dist/cjs/scripts/removeJob-3.js.map +1 -0
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/job.d.ts +8 -1
- package/dist/esm/classes/job.js +9 -0
- package/dist/esm/classes/job.js.map +1 -1
- package/dist/esm/classes/queue.d.ts +4 -0
- package/dist/esm/classes/queue.js +7 -0
- package/dist/esm/classes/queue.js.map +1 -1
- package/dist/esm/classes/scripts.js +2 -2
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/classes/worker.js +1 -1
- package/dist/esm/classes/worker.js.map +1 -1
- package/dist/esm/commands/cleanJobsInSet-3.lua +4 -2
- package/dist/esm/commands/drain-5.lua +15 -16
- package/dist/esm/commands/includes/cleanList.lua +4 -2
- package/dist/esm/commands/includes/cleanSet.lua +3 -11
- package/dist/esm/commands/includes/filterOutJobsToIgnore.lua +14 -0
- package/dist/esm/commands/includes/isJobSchedulerJob.lua +15 -0
- package/dist/esm/commands/includes/removeListJobs.lua +7 -1
- package/dist/esm/commands/includes/removeZSetJobs.lua +2 -8
- package/dist/esm/commands/{removeJob-2.lua → removeJob-3.lua} +5 -3
- package/dist/esm/scripts/cleanJobsInSet-3.js +24 -15
- package/dist/esm/scripts/cleanJobsInSet-3.js.map +1 -1
- package/dist/esm/scripts/drain-5.js +31 -23
- package/dist/esm/scripts/drain-5.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/obliterate-2.js +17 -9
- package/dist/esm/scripts/obliterate-2.js.map +1 -1
- package/dist/esm/scripts/{removeJob-2.js → removeJob-3.js} +21 -5
- package/dist/esm/scripts/removeJob-3.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/scripts/removeJob-2.js.map +0 -1
- package/dist/esm/scripts/removeJob-2.js.map +0 -1
- /package/dist/esm/scripts/{removeJob-2.d.ts → removeJob-3.d.ts} +0 -0
@@ -5,10 +5,11 @@
|
|
5
5
|
|
6
6
|
-- Includes
|
7
7
|
--- @include "getTimestamp"
|
8
|
+
--- @include "isJobSchedulerJob"
|
8
9
|
--- @include "removeJob"
|
9
10
|
|
10
11
|
local function cleanList(listKey, jobKeyPrefix, rangeStart, rangeEnd,
|
11
|
-
timestamp, isWaiting)
|
12
|
+
timestamp, isWaiting, jobSchedulersKey)
|
12
13
|
local jobs = rcall("LRANGE", listKey, rangeStart, rangeEnd)
|
13
14
|
local deleted = {}
|
14
15
|
local deletedCount = 0
|
@@ -21,7 +22,8 @@ local function cleanList(listKey, jobKeyPrefix, rangeStart, rangeEnd,
|
|
21
22
|
end
|
22
23
|
|
23
24
|
local jobKey = jobKeyPrefix .. job
|
24
|
-
if (isWaiting or rcall("EXISTS", jobKey .. ":lock") == 0)
|
25
|
+
if (isWaiting or rcall("EXISTS", jobKey .. ":lock") == 0) and
|
26
|
+
not isJobSchedulerJob(job, jobKey, jobSchedulersKey) then
|
25
27
|
-- Find the right timestamp of the job to compare to maxTimestamp:
|
26
28
|
-- * finishedOn says when the job was completed, but it isn't set unless the job has actually completed
|
27
29
|
-- * processedOn represents when the job was last attempted, but it doesn't get populated until
|
@@ -7,16 +7,8 @@
|
|
7
7
|
--- @include "batches"
|
8
8
|
--- @include "getJobsInZset"
|
9
9
|
--- @include "getTimestamp"
|
10
|
+
--- @include "isJobSchedulerJob"
|
10
11
|
--- @include "removeJob"
|
11
|
-
local function isJobSchedulerJob(jobId, jobSchedulersKey)
|
12
|
-
if jobSchedulersKey then
|
13
|
-
local jobSchedulerId = jobId:match("repeat:(.*):%d+")
|
14
|
-
if jobSchedulerId then
|
15
|
-
return rcall("ZSCORE", jobSchedulersKey, jobSchedulerId)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
return false
|
19
|
-
end
|
20
12
|
|
21
13
|
local function cleanSet(
|
22
14
|
setKey,
|
@@ -36,10 +28,10 @@ local function cleanSet(
|
|
36
28
|
break
|
37
29
|
end
|
38
30
|
|
31
|
+
local jobKey = jobKeyPrefix .. job
|
39
32
|
-- Extract a Job Scheduler Id from jobId ("repeat:job-scheduler-id:millis")
|
40
33
|
-- and check if it is in the scheduled jobs
|
41
|
-
if not isJobSchedulerJob(job, jobSchedulersKey) then
|
42
|
-
local jobKey = jobKeyPrefix .. job
|
34
|
+
if not isJobSchedulerJob(job, jobKey, jobSchedulersKey) then
|
43
35
|
if isFinished then
|
44
36
|
removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]] )
|
45
37
|
deletedCount = deletedCount + 1
|
@@ -0,0 +1,14 @@
|
|
1
|
+
--[[
|
2
|
+
Function to filter out jobs to ignore from a table.
|
3
|
+
]]
|
4
|
+
|
5
|
+
local function filterOutJobsToIgnore(jobs, jobsToIgnore)
|
6
|
+
local filteredJobs = {}
|
7
|
+
for i = 1, #jobs do
|
8
|
+
if not jobsToIgnore[jobs[i]] then
|
9
|
+
table.insert(filteredJobs, jobs[i])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
return filteredJobs
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
--[[
|
2
|
+
Function to check if the job belongs to a job scheduler and
|
3
|
+
current delayed job matches with jobId
|
4
|
+
]]
|
5
|
+
local function isJobSchedulerJob(jobId, jobKey, jobSchedulersKey)
|
6
|
+
local repeatJobKey = rcall("HGET", jobKey, "rjk")
|
7
|
+
if repeatJobKey then
|
8
|
+
local prevMillis = rcall("ZSCORE", jobSchedulersKey, repeatJobKey)
|
9
|
+
if prevMillis ~= false then
|
10
|
+
local currentDelayedJobId = "repeat:" .. repeatJobKey .. ":" .. prevMillis
|
11
|
+
return jobId == currentDelayedJobId
|
12
|
+
end
|
13
|
+
end
|
14
|
+
return false
|
15
|
+
end
|
@@ -3,14 +3,20 @@
|
|
3
3
|
]]
|
4
4
|
|
5
5
|
-- Includes
|
6
|
+
--- @include "filterOutJobsToIgnore"
|
6
7
|
--- @include "removeJobs"
|
7
8
|
|
8
9
|
local function getListItems(keyName, max)
|
9
10
|
return rcall('LRANGE', keyName, 0, max - 1)
|
10
11
|
end
|
11
12
|
|
12
|
-
local function removeListJobs(keyName, hard, baseKey, max)
|
13
|
+
local function removeListJobs(keyName, hard, baseKey, max, jobsToIgnore)
|
13
14
|
local jobs = getListItems(keyName, max)
|
15
|
+
|
16
|
+
if jobsToIgnore then
|
17
|
+
jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)
|
18
|
+
end
|
19
|
+
|
14
20
|
local count = removeJobs(jobs, hard, baseKey, max)
|
15
21
|
rcall("LTRIM", keyName, #jobs, -1)
|
16
22
|
return count
|
@@ -1,20 +1,14 @@
|
|
1
1
|
-- Includes
|
2
2
|
--- @include "batches"
|
3
|
+
--- @include "filterOutJobsToIgnore"
|
3
4
|
--- @include "getZSetItems"
|
4
5
|
--- @include "removeJobs"
|
5
6
|
|
6
7
|
local function removeZSetJobs(keyName, hard, baseKey, max, jobsToIgnore)
|
7
8
|
local jobs = getZSetItems(keyName, max)
|
8
9
|
|
9
|
-
-- filter out jobs to ignore
|
10
10
|
if jobsToIgnore then
|
11
|
-
|
12
|
-
for i = 1, #jobs do
|
13
|
-
if not jobsToIgnore[jobs[i]] then
|
14
|
-
table.insert(filteredJobs, jobs[i])
|
15
|
-
end
|
16
|
-
end
|
17
|
-
jobs = filteredJobs
|
11
|
+
jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)
|
18
12
|
end
|
19
13
|
|
20
14
|
local count = removeJobs(jobs, hard, baseKey, max)
|
@@ -5,6 +5,7 @@
|
|
5
5
|
Input:
|
6
6
|
KEYS[1] queue prefix
|
7
7
|
KEYS[2] meta key
|
8
|
+
KEYS[3] repeat key
|
8
9
|
|
9
10
|
ARGV[1] jobId
|
10
11
|
ARGV[2] remove children
|
@@ -18,6 +19,7 @@ local rcall = redis.call
|
|
18
19
|
-- Includes
|
19
20
|
--- @include "includes/destructureJobKey"
|
20
21
|
--- @include "includes/getOrSetMaxEvents"
|
22
|
+
--- @include "includes/isJobSchedulerJob"
|
21
23
|
--- @include "includes/isLocked"
|
22
24
|
--- @include "includes/removeDeduplicationKey"
|
23
25
|
--- @include "includes/removeJobFromAnyState"
|
@@ -79,10 +81,10 @@ local prefix = KEYS[1]
|
|
79
81
|
local jobId = ARGV[1]
|
80
82
|
local shouldRemoveChildren = ARGV[2]
|
81
83
|
local jobKey = prefix .. jobId
|
84
|
+
local repeatKey = KEYS[3]
|
82
85
|
|
83
|
-
|
84
|
-
|
85
|
-
return -8 -- Return error code as the job is part of a job scheduler and is in delayed state.
|
86
|
+
if isJobSchedulerJob(jobId, jobKey, repeatKey) then
|
87
|
+
return -8
|
86
88
|
end
|
87
89
|
|
88
90
|
if not isLocked(prefix, jobId, shouldRemoveChildren) then
|
@@ -47,6 +47,21 @@ local function getTimestamp(jobKey, attributes)
|
|
47
47
|
end
|
48
48
|
return jobTs
|
49
49
|
end
|
50
|
+
--[[
|
51
|
+
Function to check if the job belongs to a job scheduler and
|
52
|
+
current delayed job matches with jobId
|
53
|
+
]]
|
54
|
+
local function isJobSchedulerJob(jobId, jobKey, jobSchedulersKey)
|
55
|
+
local repeatJobKey = rcall("HGET", jobKey, "rjk")
|
56
|
+
if repeatJobKey then
|
57
|
+
local prevMillis = rcall("ZSCORE", jobSchedulersKey, repeatJobKey)
|
58
|
+
if prevMillis ~= false then
|
59
|
+
local currentDelayedJobId = "repeat:" .. repeatJobKey .. ":" .. prevMillis
|
60
|
+
return jobId == currentDelayedJobId
|
61
|
+
end
|
62
|
+
end
|
63
|
+
return false
|
64
|
+
end
|
50
65
|
--[[
|
51
66
|
Function to remove job.
|
52
67
|
]]
|
@@ -201,7 +216,7 @@ local function removeJob(jobId, hard, baseKey, shouldRemoveDeduplicationKey)
|
|
201
216
|
removeJobKeys(jobKey)
|
202
217
|
end
|
203
218
|
local function cleanList(listKey, jobKeyPrefix, rangeStart, rangeEnd,
|
204
|
-
timestamp, isWaiting)
|
219
|
+
timestamp, isWaiting, jobSchedulersKey)
|
205
220
|
local jobs = rcall("LRANGE", listKey, rangeStart, rangeEnd)
|
206
221
|
local deleted = {}
|
207
222
|
local deletedCount = 0
|
@@ -213,7 +228,8 @@ local function cleanList(listKey, jobKeyPrefix, rangeStart, rangeEnd,
|
|
213
228
|
break
|
214
229
|
end
|
215
230
|
local jobKey = jobKeyPrefix .. job
|
216
|
-
if (isWaiting or rcall("EXISTS", jobKey .. ":lock") == 0)
|
231
|
+
if (isWaiting or rcall("EXISTS", jobKey .. ":lock") == 0) and
|
232
|
+
not isJobSchedulerJob(job, jobKey, jobSchedulersKey) then
|
217
233
|
-- Find the right timestamp of the job to compare to maxTimestamp:
|
218
234
|
-- * finishedOn says when the job was completed, but it isn't set unless the job has actually completed
|
219
235
|
-- * processedOn represents when the job was last attempted, but it doesn't get populated until
|
@@ -269,15 +285,6 @@ local function getJobsInZset(zsetKey, rangeEnd, limit)
|
|
269
285
|
return rcall("ZRANGEBYSCORE", zsetKey, 0, rangeEnd)
|
270
286
|
end
|
271
287
|
end
|
272
|
-
local function isJobSchedulerJob(jobId, jobSchedulersKey)
|
273
|
-
if jobSchedulersKey then
|
274
|
-
local jobSchedulerId = jobId:match("repeat:(.*):%d+")
|
275
|
-
if jobSchedulerId then
|
276
|
-
return rcall("ZSCORE", jobSchedulersKey, jobSchedulerId)
|
277
|
-
end
|
278
|
-
end
|
279
|
-
return false
|
280
|
-
end
|
281
288
|
local function cleanSet(
|
282
289
|
setKey,
|
283
290
|
jobKeyPrefix,
|
@@ -295,10 +302,10 @@ local function cleanSet(
|
|
295
302
|
if limit > 0 and deletedCount >= limit then
|
296
303
|
break
|
297
304
|
end
|
305
|
+
local jobKey = jobKeyPrefix .. job
|
298
306
|
-- Extract a Job Scheduler Id from jobId ("repeat:job-scheduler-id:millis")
|
299
307
|
-- and check if it is in the scheduled jobs
|
300
|
-
if not isJobSchedulerJob(job, jobSchedulersKey) then
|
301
|
-
local jobKey = jobKeyPrefix .. job
|
308
|
+
if not isJobSchedulerJob(job, jobKey, jobSchedulersKey) then
|
302
309
|
if isFinished then
|
303
310
|
removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]] )
|
304
311
|
deletedCount = deletedCount + 1
|
@@ -323,7 +330,8 @@ local function cleanSet(
|
|
323
330
|
end
|
324
331
|
local result
|
325
332
|
if ARGV[4] == "active" then
|
326
|
-
result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], false --[[ hasFinished ]]
|
333
|
+
result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], false --[[ hasFinished ]],
|
334
|
+
KEYS[3])
|
327
335
|
elseif ARGV[4] == "delayed" then
|
328
336
|
rangeEnd = "+inf"
|
329
337
|
result = cleanSet(KEYS[1], ARGV[1], rangeEnd, ARGV[2], limit,
|
@@ -333,7 +341,8 @@ elseif ARGV[4] == "prioritized" then
|
|
333
341
|
result = cleanSet(KEYS[1], ARGV[1], rangeEnd, ARGV[2], limit,
|
334
342
|
{"timestamp"}, false --[[ hasFinished ]])
|
335
343
|
elseif ARGV[4] == "wait" or ARGV[4] == "paused" then
|
336
|
-
result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], true --[[ hasFinished ]]
|
344
|
+
result = cleanList(KEYS[1], ARGV[1], rangeStart, rangeEnd, ARGV[2], true --[[ hasFinished ]],
|
345
|
+
KEYS[3])
|
337
346
|
else
|
338
347
|
rangeEnd = ARGV[2]
|
339
348
|
result = cleanSet(KEYS[1], ARGV[1], rangeEnd, ARGV[2], limit,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cleanJobsInSet-3.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-3.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"cleanJobsInSet-3.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-3.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Vf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -19,6 +19,18 @@ local queueBaseKey = ARGV[1]
|
|
19
19
|
Functions to remove jobs.
|
20
20
|
]]
|
21
21
|
-- Includes
|
22
|
+
--[[
|
23
|
+
Function to filter out jobs to ignore from a table.
|
24
|
+
]]
|
25
|
+
local function filterOutJobsToIgnore(jobs, jobsToIgnore)
|
26
|
+
local filteredJobs = {}
|
27
|
+
for i = 1, #jobs do
|
28
|
+
if not jobsToIgnore[jobs[i]] then
|
29
|
+
table.insert(filteredJobs, jobs[i])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
return filteredJobs
|
33
|
+
end
|
22
34
|
--[[
|
23
35
|
Functions to remove jobs.
|
24
36
|
]]
|
@@ -185,8 +197,11 @@ end
|
|
185
197
|
local function getListItems(keyName, max)
|
186
198
|
return rcall('LRANGE', keyName, 0, max - 1)
|
187
199
|
end
|
188
|
-
local function removeListJobs(keyName, hard, baseKey, max)
|
200
|
+
local function removeListJobs(keyName, hard, baseKey, max, jobsToIgnore)
|
189
201
|
local jobs = getListItems(keyName, max)
|
202
|
+
if jobsToIgnore then
|
203
|
+
jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)
|
204
|
+
end
|
190
205
|
local count = removeJobs(jobs, hard, baseKey, max)
|
191
206
|
rcall("LTRIM", keyName, #jobs, -1)
|
192
207
|
return count
|
@@ -216,15 +231,8 @@ local function getZSetItems(keyName, max)
|
|
216
231
|
end
|
217
232
|
local function removeZSetJobs(keyName, hard, baseKey, max, jobsToIgnore)
|
218
233
|
local jobs = getZSetItems(keyName, max)
|
219
|
-
-- filter out jobs to ignore
|
220
234
|
if jobsToIgnore then
|
221
|
-
|
222
|
-
for i = 1, #jobs do
|
223
|
-
if not jobsToIgnore[jobs[i]] then
|
224
|
-
table.insert(filteredJobs, jobs[i])
|
225
|
-
end
|
226
|
-
end
|
227
|
-
jobs = filteredJobs
|
235
|
+
jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)
|
228
236
|
end
|
229
237
|
local count = removeJobs(jobs, hard, baseKey, max)
|
230
238
|
if(#jobs > 0) then
|
@@ -234,22 +242,22 @@ local function removeZSetJobs(keyName, hard, baseKey, max, jobsToIgnore)
|
|
234
242
|
end
|
235
243
|
return count
|
236
244
|
end
|
237
|
-
|
238
|
-
|
245
|
+
-- We must not remove delayed jobs if they are associated to a job scheduler.
|
246
|
+
local scheduledJobs = {}
|
247
|
+
local jobSchedulers = rcall("ZRANGE", KEYS[5], 0, -1, "WITHSCORES")
|
248
|
+
-- For every job scheduler, get the current delayed job id.
|
249
|
+
for i = 1, #jobSchedulers, 2 do
|
250
|
+
local jobSchedulerId = jobSchedulers[i]
|
251
|
+
local jobSchedulerMillis = jobSchedulers[i + 1]
|
252
|
+
local delayedJobId = "repeat:" .. jobSchedulerId .. ":" .. jobSchedulerMillis
|
253
|
+
scheduledJobs[delayedJobId] = true
|
254
|
+
end
|
255
|
+
removeListJobs(KEYS[1], true, queueBaseKey, 0, scheduledJobs) -- wait
|
256
|
+
removeListJobs(KEYS[2], true, queueBaseKey, 0, scheduledJobs) -- paused
|
239
257
|
if ARGV[2] == "1" then
|
240
|
-
|
241
|
-
local scheduledJobs = {}
|
242
|
-
local jobSchedulers = rcall("ZRANGE", KEYS[5], 0, -1, "WITHSCORES")
|
243
|
-
-- For every job scheduler, get the current delayed job id.
|
244
|
-
for i = 1, #jobSchedulers, 2 do
|
245
|
-
local jobSchedulerId = jobSchedulers[i]
|
246
|
-
local jobSchedulerMillis = jobSchedulers[i + 1]
|
247
|
-
local delayedJobId = "repeat:" .. jobSchedulerId .. ":" .. jobSchedulerMillis
|
248
|
-
scheduledJobs[delayedJobId] = true
|
249
|
-
end
|
250
|
-
removeZSetJobs(KEYS[3], true, queueBaseKey, 0, scheduledJobs) -- delayed
|
258
|
+
removeZSetJobs(KEYS[3], true, queueBaseKey, 0, scheduledJobs) -- delayed
|
251
259
|
end
|
252
|
-
removeZSetJobs(KEYS[4], true, queueBaseKey, 0) -- prioritized
|
260
|
+
removeZSetJobs(KEYS[4], true, queueBaseKey, 0, scheduledJobs) -- prioritized
|
253
261
|
`;
|
254
262
|
exports.drain = {
|
255
263
|
name: 'drain',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"drain-5.js","sourceRoot":"","sources":["../../../src/scripts/drain-5.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"drain-5.js","sourceRoot":"","sources":["../../../src/scripts/drain-5.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiQf,CAAC;AACW,QAAA,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -37,7 +37,7 @@ tslib_1.__exportStar(require("./pause-7"), exports);
|
|
37
37
|
tslib_1.__exportStar(require("./promote-9"), exports);
|
38
38
|
tslib_1.__exportStar(require("./releaseLock-1"), exports);
|
39
39
|
tslib_1.__exportStar(require("./removeChildDependency-1"), exports);
|
40
|
-
tslib_1.__exportStar(require("./removeJob-
|
40
|
+
tslib_1.__exportStar(require("./removeJob-3"), exports);
|
41
41
|
tslib_1.__exportStar(require("./removeJobScheduler-3"), exports);
|
42
42
|
tslib_1.__exportStar(require("./removeRepeatable-3"), exports);
|
43
43
|
tslib_1.__exportStar(require("./reprocessJob-8"), exports);
|
@@ -186,11 +186,26 @@ end
|
|
186
186
|
Functions to remove jobs.
|
187
187
|
]]
|
188
188
|
-- Includes
|
189
|
+
--[[
|
190
|
+
Function to filter out jobs to ignore from a table.
|
191
|
+
]]
|
192
|
+
local function filterOutJobsToIgnore(jobs, jobsToIgnore)
|
193
|
+
local filteredJobs = {}
|
194
|
+
for i = 1, #jobs do
|
195
|
+
if not jobsToIgnore[jobs[i]] then
|
196
|
+
table.insert(filteredJobs, jobs[i])
|
197
|
+
end
|
198
|
+
end
|
199
|
+
return filteredJobs
|
200
|
+
end
|
189
201
|
local function getListItems(keyName, max)
|
190
202
|
return rcall('LRANGE', keyName, 0, max - 1)
|
191
203
|
end
|
192
|
-
local function removeListJobs(keyName, hard, baseKey, max)
|
204
|
+
local function removeListJobs(keyName, hard, baseKey, max, jobsToIgnore)
|
193
205
|
local jobs = getListItems(keyName, max)
|
206
|
+
if jobsToIgnore then
|
207
|
+
jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)
|
208
|
+
end
|
194
209
|
local count = removeJobs(jobs, hard, baseKey, max)
|
195
210
|
rcall("LTRIM", keyName, #jobs, -1)
|
196
211
|
return count
|
@@ -220,15 +235,8 @@ local function getZSetItems(keyName, max)
|
|
220
235
|
end
|
221
236
|
local function removeZSetJobs(keyName, hard, baseKey, max, jobsToIgnore)
|
222
237
|
local jobs = getZSetItems(keyName, max)
|
223
|
-
-- filter out jobs to ignore
|
224
238
|
if jobsToIgnore then
|
225
|
-
|
226
|
-
for i = 1, #jobs do
|
227
|
-
if not jobsToIgnore[jobs[i]] then
|
228
|
-
table.insert(filteredJobs, jobs[i])
|
229
|
-
end
|
230
|
-
end
|
231
|
-
jobs = filteredJobs
|
239
|
+
jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)
|
232
240
|
end
|
233
241
|
local count = removeJobs(jobs, hard, baseKey, max)
|
234
242
|
if(#jobs > 0) then
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqUf,CAAC;AACW,QAAA,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -7,6 +7,7 @@ const content = `--[[
|
|
7
7
|
Input:
|
8
8
|
KEYS[1] queue prefix
|
9
9
|
KEYS[2] meta key
|
10
|
+
KEYS[3] repeat key
|
10
11
|
ARGV[1] jobId
|
11
12
|
ARGV[2] remove children
|
12
13
|
Events:
|
@@ -35,6 +36,21 @@ local function getOrSetMaxEvents(metaKey)
|
|
35
36
|
end
|
36
37
|
return maxEvents
|
37
38
|
end
|
39
|
+
--[[
|
40
|
+
Function to check if the job belongs to a job scheduler and
|
41
|
+
current delayed job matches with jobId
|
42
|
+
]]
|
43
|
+
local function isJobSchedulerJob(jobId, jobKey, jobSchedulersKey)
|
44
|
+
local repeatJobKey = rcall("HGET", jobKey, "rjk")
|
45
|
+
if repeatJobKey then
|
46
|
+
local prevMillis = rcall("ZSCORE", jobSchedulersKey, repeatJobKey)
|
47
|
+
if prevMillis ~= false then
|
48
|
+
local currentDelayedJobId = "repeat:" .. repeatJobKey .. ":" .. prevMillis
|
49
|
+
return jobId == currentDelayedJobId
|
50
|
+
end
|
51
|
+
end
|
52
|
+
return false
|
53
|
+
end
|
38
54
|
--[[
|
39
55
|
Function to recursively check if there are no locks
|
40
56
|
on the jobs to be removed.
|
@@ -274,9 +290,9 @@ local prefix = KEYS[1]
|
|
274
290
|
local jobId = ARGV[1]
|
275
291
|
local shouldRemoveChildren = ARGV[2]
|
276
292
|
local jobKey = prefix .. jobId
|
277
|
-
|
278
|
-
if
|
279
|
-
return -8
|
293
|
+
local repeatKey = KEYS[3]
|
294
|
+
if isJobSchedulerJob(jobId, jobKey, repeatKey) then
|
295
|
+
return -8
|
280
296
|
end
|
281
297
|
if not isLocked(prefix, jobId, shouldRemoveChildren) then
|
282
298
|
removeJob(prefix, jobId, nil, shouldRemoveChildren)
|
@@ -287,6 +303,6 @@ return 0
|
|
287
303
|
exports.removeJob = {
|
288
304
|
name: 'removeJob',
|
289
305
|
content,
|
290
|
-
keys:
|
306
|
+
keys: 3,
|
291
307
|
};
|
292
|
-
//# sourceMappingURL=removeJob-
|
308
|
+
//# sourceMappingURL=removeJob-3.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"removeJob-3.js","sourceRoot":"","sources":["../../../src/scripts/removeJob-3.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Sf,CAAC;AACW,QAAA,SAAS,GAAG;IACvB,IAAI,EAAE,WAAW;IACjB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|