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