bullmq 5.40.4 → 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.
Files changed (64) hide show
  1. package/dist/cjs/classes/job.js +9 -0
  2. package/dist/cjs/classes/job.js.map +1 -1
  3. package/dist/cjs/classes/queue.js +7 -0
  4. package/dist/cjs/classes/queue.js.map +1 -1
  5. package/dist/cjs/classes/scripts.js +4 -4
  6. package/dist/cjs/classes/scripts.js.map +1 -1
  7. package/dist/cjs/classes/worker.js +1 -1
  8. package/dist/cjs/classes/worker.js.map +1 -1
  9. package/dist/cjs/commands/cleanJobsInSet-3.lua +4 -2
  10. package/dist/cjs/commands/drain-5.lua +16 -16
  11. package/dist/cjs/commands/includes/cleanList.lua +4 -2
  12. package/dist/cjs/commands/includes/cleanSet.lua +3 -11
  13. package/dist/cjs/commands/includes/filterOutJobsToIgnore.lua +14 -0
  14. package/dist/cjs/commands/includes/isJobSchedulerJob.lua +15 -0
  15. package/dist/cjs/commands/includes/removeListJobs.lua +7 -1
  16. package/dist/cjs/commands/includes/removeZSetJobs.lua +2 -8
  17. package/dist/cjs/commands/{removeJob-2.lua → removeJob-3.lua} +5 -3
  18. package/dist/cjs/scripts/cleanJobsInSet-3.js +24 -15
  19. package/dist/cjs/scripts/cleanJobsInSet-3.js.map +1 -1
  20. package/dist/cjs/scripts/drain-5.js +33 -24
  21. package/dist/cjs/scripts/drain-5.js.map +1 -1
  22. package/dist/cjs/scripts/index.js +1 -1
  23. package/dist/cjs/scripts/obliterate-2.js +17 -9
  24. package/dist/cjs/scripts/obliterate-2.js.map +1 -1
  25. package/dist/cjs/scripts/{removeJob-2.js → removeJob-3.js} +21 -5
  26. package/dist/cjs/scripts/removeJob-3.js.map +1 -0
  27. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  28. package/dist/cjs/version.js +1 -1
  29. package/dist/esm/classes/job.d.ts +8 -1
  30. package/dist/esm/classes/job.js +9 -0
  31. package/dist/esm/classes/job.js.map +1 -1
  32. package/dist/esm/classes/queue.d.ts +4 -0
  33. package/dist/esm/classes/queue.js +7 -0
  34. package/dist/esm/classes/queue.js.map +1 -1
  35. package/dist/esm/classes/scripts.js +4 -4
  36. package/dist/esm/classes/scripts.js.map +1 -1
  37. package/dist/esm/classes/worker.js +1 -1
  38. package/dist/esm/classes/worker.js.map +1 -1
  39. package/dist/esm/commands/cleanJobsInSet-3.lua +4 -2
  40. package/dist/esm/commands/drain-5.lua +16 -16
  41. package/dist/esm/commands/includes/cleanList.lua +4 -2
  42. package/dist/esm/commands/includes/cleanSet.lua +3 -11
  43. package/dist/esm/commands/includes/filterOutJobsToIgnore.lua +14 -0
  44. package/dist/esm/commands/includes/isJobSchedulerJob.lua +15 -0
  45. package/dist/esm/commands/includes/removeListJobs.lua +7 -1
  46. package/dist/esm/commands/includes/removeZSetJobs.lua +2 -8
  47. package/dist/esm/commands/{removeJob-2.lua → removeJob-3.lua} +5 -3
  48. package/dist/esm/scripts/cleanJobsInSet-3.js +24 -15
  49. package/dist/esm/scripts/cleanJobsInSet-3.js.map +1 -1
  50. package/dist/esm/scripts/drain-5.js +33 -24
  51. package/dist/esm/scripts/drain-5.js.map +1 -1
  52. package/dist/esm/scripts/index.d.ts +1 -1
  53. package/dist/esm/scripts/index.js +1 -1
  54. package/dist/esm/scripts/obliterate-2.js +17 -9
  55. package/dist/esm/scripts/obliterate-2.js.map +1 -1
  56. package/dist/esm/scripts/{removeJob-2.js → removeJob-3.js} +21 -5
  57. package/dist/esm/scripts/removeJob-3.js.map +1 -0
  58. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  59. package/dist/esm/version.d.ts +1 -1
  60. package/dist/esm/version.js +1 -1
  61. package/package.json +1 -1
  62. package/dist/cjs/scripts/removeJob-2.js.map +0 -1
  63. package/dist/esm/scripts/removeJob-2.js.map +0 -1
  64. /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
- -- Check if the job belongs to a job scheduler and it is in delayed state.
84
- if rcall("ZSCORE", prefix .. "delayed", jobId) and rcall("HGET", jobKey, "rjk") then
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) then
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoVf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
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"}
@@ -8,6 +8,7 @@ const content = `--[[
8
8
  KEYS[4] 'prioritized'
9
9
  KEYS[5] 'jobschedulers' (repeat)
10
10
  ARGV[1] queue key prefix
11
+ ARGV[2] should clean delayed jobs
11
12
  ]]
12
13
  local rcall = redis.call
13
14
  local queueBaseKey = ARGV[1]
@@ -15,6 +16,18 @@ local queueBaseKey = ARGV[1]
15
16
  Functions to remove jobs.
16
17
  ]]
17
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
18
31
  --[[
19
32
  Functions to remove jobs.
20
33
  ]]
@@ -181,8 +194,11 @@ end
181
194
  local function getListItems(keyName, max)
182
195
  return rcall('LRANGE', keyName, 0, max - 1)
183
196
  end
184
- local function removeListJobs(keyName, hard, baseKey, max)
197
+ local function removeListJobs(keyName, hard, baseKey, max, jobsToIgnore)
185
198
  local jobs = getListItems(keyName, max)
199
+ if jobsToIgnore then
200
+ jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)
201
+ end
186
202
  local count = removeJobs(jobs, hard, baseKey, max)
187
203
  rcall("LTRIM", keyName, #jobs, -1)
188
204
  return count
@@ -212,15 +228,8 @@ local function getZSetItems(keyName, max)
212
228
  end
213
229
  local function removeZSetJobs(keyName, hard, baseKey, max, jobsToIgnore)
214
230
  local jobs = getZSetItems(keyName, max)
215
- -- filter out jobs to ignore
216
231
  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
232
+ jobs = filterOutJobsToIgnore(jobs, jobsToIgnore)
224
233
  end
225
234
  local count = removeJobs(jobs, hard, baseKey, max)
226
235
  if(#jobs > 0) then
@@ -230,22 +239,22 @@ local function removeZSetJobs(keyName, hard, baseKey, max, jobsToIgnore)
230
239
  end
231
240
  return count
232
241
  end
233
- removeListJobs(KEYS[1], true, queueBaseKey, 0) -- wait
234
- removeListJobs(KEYS[2], true, queueBaseKey, 0) -- paused
235
- if KEYS[3] ~= "" then
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
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
254
+ if ARGV[2] == "1" then
255
+ removeZSetJobs(KEYS[3], true, queueBaseKey, 0, scheduledJobs) -- delayed
247
256
  end
248
- removeZSetJobs(KEYS[4], true, queueBaseKey, 0) -- prioritized
257
+ removeZSetJobs(KEYS[4], true, queueBaseKey, 0, scheduledJobs) -- prioritized
249
258
  `;
250
259
  export const drain = {
251
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwPf,CAAC;AACF,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
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-2';
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-2';
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
- 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
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Tf,CAAC;AACF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
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
- -- 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.
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: 2,
303
+ keys: 3,
288
304
  };
289
- //# sourceMappingURL=removeJob-2.js.map
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"}