bullmq 5.40.5 → 5.41.1

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 (77) 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 +3 -2
  6. package/dist/cjs/classes/scripts.js.map +1 -1
  7. package/dist/cjs/classes/worker.js +2 -2
  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 +15 -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/moveToActive-11.lua +1 -0
  18. package/dist/cjs/commands/moveToFinished-14.lua +1 -0
  19. package/dist/cjs/commands/{removeJob-2.lua → removeJob-3.lua} +5 -3
  20. package/dist/cjs/scripts/cleanJobsInSet-3.js +24 -15
  21. package/dist/cjs/scripts/cleanJobsInSet-3.js.map +1 -1
  22. package/dist/cjs/scripts/drain-5.js +31 -23
  23. package/dist/cjs/scripts/drain-5.js.map +1 -1
  24. package/dist/cjs/scripts/index.js +1 -1
  25. package/dist/cjs/scripts/moveToActive-11.js +1 -0
  26. package/dist/cjs/scripts/moveToActive-11.js.map +1 -1
  27. package/dist/cjs/scripts/moveToFinished-14.js +1 -0
  28. package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
  29. package/dist/cjs/scripts/obliterate-2.js +17 -9
  30. package/dist/cjs/scripts/obliterate-2.js.map +1 -1
  31. package/dist/cjs/scripts/{removeJob-2.js → removeJob-3.js} +21 -5
  32. package/dist/cjs/scripts/removeJob-3.js.map +1 -0
  33. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  34. package/dist/cjs/version.js +1 -1
  35. package/dist/esm/classes/job.d.ts +8 -1
  36. package/dist/esm/classes/job.js +9 -0
  37. package/dist/esm/classes/job.js.map +1 -1
  38. package/dist/esm/classes/queue.d.ts +4 -0
  39. package/dist/esm/classes/queue.js +7 -0
  40. package/dist/esm/classes/queue.js.map +1 -1
  41. package/dist/esm/classes/scripts.js +3 -2
  42. package/dist/esm/classes/scripts.js.map +1 -1
  43. package/dist/esm/classes/worker.d.ts +0 -1
  44. package/dist/esm/classes/worker.js +2 -2
  45. package/dist/esm/classes/worker.js.map +1 -1
  46. package/dist/esm/commands/cleanJobsInSet-3.lua +4 -2
  47. package/dist/esm/commands/drain-5.lua +15 -16
  48. package/dist/esm/commands/includes/cleanList.lua +4 -2
  49. package/dist/esm/commands/includes/cleanSet.lua +3 -11
  50. package/dist/esm/commands/includes/filterOutJobsToIgnore.lua +14 -0
  51. package/dist/esm/commands/includes/isJobSchedulerJob.lua +15 -0
  52. package/dist/esm/commands/includes/removeListJobs.lua +7 -1
  53. package/dist/esm/commands/includes/removeZSetJobs.lua +2 -8
  54. package/dist/esm/commands/moveToActive-11.lua +1 -0
  55. package/dist/esm/commands/moveToFinished-14.lua +1 -0
  56. package/dist/esm/commands/{removeJob-2.lua → removeJob-3.lua} +5 -3
  57. package/dist/esm/scripts/cleanJobsInSet-3.js +24 -15
  58. package/dist/esm/scripts/cleanJobsInSet-3.js.map +1 -1
  59. package/dist/esm/scripts/drain-5.js +31 -23
  60. package/dist/esm/scripts/drain-5.js.map +1 -1
  61. package/dist/esm/scripts/index.d.ts +1 -1
  62. package/dist/esm/scripts/index.js +1 -1
  63. package/dist/esm/scripts/moveToActive-11.js +1 -0
  64. package/dist/esm/scripts/moveToActive-11.js.map +1 -1
  65. package/dist/esm/scripts/moveToFinished-14.js +1 -0
  66. package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
  67. package/dist/esm/scripts/obliterate-2.js +17 -9
  68. package/dist/esm/scripts/obliterate-2.js.map +1 -1
  69. package/dist/esm/scripts/{removeJob-2.js → removeJob-3.js} +21 -5
  70. package/dist/esm/scripts/removeJob-3.js.map +1 -0
  71. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  72. package/dist/esm/version.d.ts +1 -1
  73. package/dist/esm/version.js +1 -1
  74. package/package.json +1 -1
  75. package/dist/cjs/scripts/removeJob-2.js.map +0 -1
  76. package/dist/esm/scripts/removeJob-2.js.map +0 -1
  77. /package/dist/esm/scripts/{removeJob-2.d.ts → removeJob-3.d.ts} +0 -0
@@ -33,6 +33,7 @@
33
33
  opts - token - lock token
34
34
  opts - lockDuration
35
35
  opts - limiter
36
+ opts - name - worker name
36
37
  ]]
37
38
  local rcall = redis.call
38
39
  local waitKey = KEYS[1]
@@ -42,6 +42,7 @@
42
42
  opts - fpof - fail parent on fail
43
43
  opts - idof - ignore dependency on fail
44
44
  opts - rdof - remove dependency on fail
45
+ opts - name - worker name
45
46
 
46
47
  Output:
47
48
  0 OK
@@ -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"}
@@ -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
- local filteredJobs = {}
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
- removeListJobs(KEYS[1], true, queueBaseKey, 0) -- wait
235
- removeListJobs(KEYS[2], true, queueBaseKey, 0) -- paused
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
- -- We must not remove delayed jobs if they are associated to a job scheduler.
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyPf,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';
@@ -26,6 +26,7 @@ const content = `--[[
26
26
  opts - token - lock token
27
27
  opts - lockDuration
28
28
  opts - limiter
29
+ opts - name - worker name
29
30
  ]]
30
31
  local rcall = redis.call
31
32
  local waitKey = KEYS[1]
@@ -1 +1 @@
1
- {"version":3,"file":"moveToActive-11.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-11.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Nf,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
1
+ {"version":3,"file":"moveToActive-11.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-11.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgOf,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
@@ -36,6 +36,7 @@ const content = `--[[
36
36
  opts - fpof - fail parent on fail
37
37
  opts - idof - ignore dependency on fail
38
38
  opts - rdof - remove dependency on fail
39
+ opts - name - worker name
39
40
  Output:
40
41
  0 OK
41
42
  -1 Missing key.
@@ -1 +1 @@
1
- {"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoxBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
1
+ {"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqxBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
@@ -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"}