bullmq 3.13.4 → 3.14.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 (92) hide show
  1. package/dist/cjs/classes/job.js +1 -1
  2. package/dist/cjs/classes/worker.js.map +1 -1
  3. package/dist/cjs/commands/addJob-8.lua +2 -2
  4. package/dist/cjs/commands/changeDelay-3.lua +2 -3
  5. package/dist/cjs/commands/getRanges-1.lua +1 -1
  6. package/dist/cjs/commands/includes/addDelayMarkerIfNeeded.lua +3 -3
  7. package/dist/cjs/commands/includes/cleanSet.lua +2 -2
  8. package/dist/cjs/commands/includes/getRateLimitTTL.lua +1 -1
  9. package/dist/cjs/commands/includes/promoteDelayedJobs.lua +4 -9
  10. package/dist/cjs/commands/includes/updateParentDepsIfNeeded.lua +0 -1
  11. package/dist/cjs/commands/isFinished-3.lua +3 -3
  12. package/dist/cjs/commands/moveToActive-9.lua +51 -46
  13. package/dist/cjs/commands/moveToDelayed-8.lua +22 -23
  14. package/dist/cjs/commands/moveToFinished-12.lua +3 -1
  15. package/dist/cjs/commands/pause-4.lua +8 -8
  16. package/dist/cjs/commands/promote-6.lua +7 -3
  17. package/dist/cjs/commands/removeRepeatable-2.lua +3 -0
  18. package/dist/cjs/commands/reprocessJob-6.lua +1 -1
  19. package/dist/cjs/commands/retryJob-8.lua +4 -5
  20. package/dist/cjs/commands/saveStacktrace-1.lua +2 -3
  21. package/dist/cjs/commands/updateData-1.lua +6 -2
  22. package/dist/cjs/commands/updateProgress-2.lua +6 -2
  23. package/dist/cjs/scripts/addJob-8.js +5 -5
  24. package/dist/cjs/scripts/changeDelay-3.js +2 -2
  25. package/dist/cjs/scripts/getRanges-1.js +1 -1
  26. package/dist/cjs/scripts/isFinished-3.js +3 -3
  27. package/dist/cjs/scripts/moveToActive-9.js +76 -76
  28. package/dist/cjs/scripts/moveToDelayed-8.js +29 -32
  29. package/dist/cjs/scripts/moveToDelayed-8.js.map +1 -1
  30. package/dist/cjs/scripts/moveToFinished-12.js +21 -23
  31. package/dist/cjs/scripts/moveToFinished-12.js.map +1 -1
  32. package/dist/cjs/scripts/pause-4.js +8 -8
  33. package/dist/cjs/scripts/promote-6.js +6 -3
  34. package/dist/cjs/scripts/promote-6.js.map +1 -1
  35. package/dist/cjs/scripts/removeRepeatable-2.js +2 -0
  36. package/dist/cjs/scripts/removeRepeatable-2.js.map +1 -1
  37. package/dist/cjs/scripts/reprocessJob-6.js +1 -1
  38. package/dist/cjs/scripts/retryJob-8.js +7 -10
  39. package/dist/cjs/scripts/retryJob-8.js.map +1 -1
  40. package/dist/cjs/scripts/saveStacktrace-1.js +1 -1
  41. package/dist/cjs/scripts/updateData-1.js +4 -1
  42. package/dist/cjs/scripts/updateData-1.js.map +1 -1
  43. package/dist/cjs/scripts/updateProgress-2.js +3 -0
  44. package/dist/cjs/scripts/updateProgress-2.js.map +1 -1
  45. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  46. package/dist/esm/classes/job.js +1 -1
  47. package/dist/esm/classes/worker.d.ts +2 -2
  48. package/dist/esm/classes/worker.js.map +1 -1
  49. package/dist/esm/commands/addJob-8.lua +2 -2
  50. package/dist/esm/commands/changeDelay-3.lua +2 -3
  51. package/dist/esm/commands/getRanges-1.lua +1 -1
  52. package/dist/esm/commands/includes/addDelayMarkerIfNeeded.lua +3 -3
  53. package/dist/esm/commands/includes/cleanSet.lua +2 -2
  54. package/dist/esm/commands/includes/getRateLimitTTL.lua +1 -1
  55. package/dist/esm/commands/includes/promoteDelayedJobs.lua +4 -9
  56. package/dist/esm/commands/includes/updateParentDepsIfNeeded.lua +0 -1
  57. package/dist/esm/commands/isFinished-3.lua +3 -3
  58. package/dist/esm/commands/moveToActive-9.lua +51 -46
  59. package/dist/esm/commands/moveToDelayed-8.lua +22 -23
  60. package/dist/esm/commands/moveToFinished-12.lua +3 -1
  61. package/dist/esm/commands/pause-4.lua +8 -8
  62. package/dist/esm/commands/promote-6.lua +7 -3
  63. package/dist/esm/commands/removeRepeatable-2.lua +3 -0
  64. package/dist/esm/commands/reprocessJob-6.lua +1 -1
  65. package/dist/esm/commands/retryJob-8.lua +4 -5
  66. package/dist/esm/commands/saveStacktrace-1.lua +2 -3
  67. package/dist/esm/commands/updateData-1.lua +6 -2
  68. package/dist/esm/commands/updateProgress-2.lua +6 -2
  69. package/dist/esm/scripts/addJob-8.js +5 -5
  70. package/dist/esm/scripts/changeDelay-3.js +2 -2
  71. package/dist/esm/scripts/getRanges-1.js +1 -1
  72. package/dist/esm/scripts/isFinished-3.js +3 -3
  73. package/dist/esm/scripts/moveToActive-9.js +76 -76
  74. package/dist/esm/scripts/moveToDelayed-8.js +29 -32
  75. package/dist/esm/scripts/moveToDelayed-8.js.map +1 -1
  76. package/dist/esm/scripts/moveToFinished-12.js +21 -23
  77. package/dist/esm/scripts/moveToFinished-12.js.map +1 -1
  78. package/dist/esm/scripts/pause-4.js +8 -8
  79. package/dist/esm/scripts/promote-6.js +6 -3
  80. package/dist/esm/scripts/promote-6.js.map +1 -1
  81. package/dist/esm/scripts/removeRepeatable-2.js +2 -0
  82. package/dist/esm/scripts/removeRepeatable-2.js.map +1 -1
  83. package/dist/esm/scripts/reprocessJob-6.js +1 -1
  84. package/dist/esm/scripts/retryJob-8.js +7 -10
  85. package/dist/esm/scripts/retryJob-8.js.map +1 -1
  86. package/dist/esm/scripts/saveStacktrace-1.js +1 -1
  87. package/dist/esm/scripts/updateData-1.js +4 -1
  88. package/dist/esm/scripts/updateData-1.js.map +1 -1
  89. package/dist/esm/scripts/updateProgress-2.js +3 -0
  90. package/dist/esm/scripts/updateProgress-2.js.map +1 -1
  91. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  92. package/package.json +1 -1
@@ -40,11 +40,11 @@ local function getNextDelayedTimestamp(delayedKey)
40
40
  return nextTimestamp
41
41
  end
42
42
  end
43
- local function addDelayMarkerIfNeeded(target, delayedKey)
44
- if rcall("LLEN", target) == 0 then
43
+ local function addDelayMarkerIfNeeded(targetKey, delayedKey)
44
+ if rcall("LLEN", targetKey) == 0 then
45
45
  local nextTimestamp = getNextDelayedTimestamp(delayedKey)
46
46
  if nextTimestamp ~= nil then
47
- rcall("LPUSH", target, "0:" .. nextTimestamp)
47
+ rcall("LPUSH", targetKey, "0:" .. nextTimestamp)
48
48
  end
49
49
  end
50
50
  end
@@ -65,7 +65,6 @@ end
65
65
  Events:
66
66
  'waiting'
67
67
  ]]
68
- local rcall = redis.call
69
68
  -- Includes
70
69
  --[[
71
70
  Function to add job considering priority.
@@ -82,21 +81,19 @@ local function addJobWithPriority(priorityKey, priority, targetKey, jobId)
82
81
  end
83
82
  end
84
83
  -- Try to get as much as 1000 jobs at once
85
- local function promoteDelayedJobs(delayedKey, waitKey, priorityKey, pausedKey,
86
- metaKey, eventStreamKey, prefix, timestamp)
84
+ local function promoteDelayedJobs(delayedKey, targetKey, priorityKey,
85
+ eventStreamKey, prefix, timestamp)
87
86
  local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000, "LIMIT", 0, 1000)
88
87
  if (#jobs > 0) then
89
88
  rcall("ZREM", delayedKey, unpack(jobs))
90
- -- check if we need to use push in paused instead of waiting
91
- local target = getTargetQueueList(metaKey, waitKey, pausedKey)
92
89
  for _, jobId in ipairs(jobs) do
93
90
  local priority =
94
91
  tonumber(rcall("HGET", prefix .. jobId, "priority")) or 0
95
92
  if priority == 0 then
96
93
  -- LIFO or FIFO
97
- rcall("LPUSH", target, jobId)
94
+ rcall("LPUSH", targetKey, jobId)
98
95
  else
99
- addJobWithPriority(priorityKey, priority, target, jobId)
96
+ addJobWithPriority(priorityKey, priority, targetKey, jobId)
100
97
  end
101
98
  -- Emit waiting event
102
99
  rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",
@@ -107,30 +104,30 @@ local function promoteDelayedJobs(delayedKey, waitKey, priorityKey, pausedKey,
107
104
  end
108
105
  local jobKey = KEYS[5]
109
106
  if rcall("EXISTS", jobKey) == 1 then
110
- local delayedKey = KEYS[4]
111
- if ARGV[5] ~= "0" then
112
- local lockKey = jobKey .. ':lock'
113
- if rcall("GET", lockKey) == ARGV[5] then
114
- rcall("DEL", lockKey)
115
- else
116
- return -2
117
- end
118
- end
119
- local jobId = ARGV[4]
120
- local score = tonumber(ARGV[3])
121
- local delayedTimestamp = (score / 0x1000)
122
- local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)
123
- if (numRemovedElements < 1) then
124
- return -3
107
+ local delayedKey = KEYS[4]
108
+ if ARGV[5] ~= "0" then
109
+ local lockKey = jobKey .. ':lock'
110
+ if rcall("GET", lockKey) == ARGV[5] then
111
+ rcall("DEL", lockKey)
112
+ else
113
+ return -2
125
114
  end
126
- rcall("ZADD", delayedKey, score, jobId)
127
- rcall("XADD", KEYS[6], "*", "event", "delayed", "jobId", jobId, "delay", delayedTimestamp)
128
- -- Check if we need to push a marker job to wake up sleeping workers.
129
- local target = getTargetQueueList(KEYS[8], KEYS[1], KEYS[7])
130
- addDelayMarkerIfNeeded(target, delayedKey)
131
- return 0
115
+ end
116
+ local jobId = ARGV[4]
117
+ local score = tonumber(ARGV[3])
118
+ local delayedTimestamp = (score / 0x1000)
119
+ local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)
120
+ if numRemovedElements < 1 then
121
+ return -3
122
+ end
123
+ rcall("ZADD", delayedKey, score, jobId)
124
+ rcall("XADD", KEYS[6], "*", "event", "delayed", "jobId", jobId, "delay", delayedTimestamp)
125
+ -- Check if we need to push a marker job to wake up sleeping workers.
126
+ local target = getTargetQueueList(KEYS[8], KEYS[1], KEYS[7])
127
+ addDelayMarkerIfNeeded(target, delayedKey)
128
+ return 0
132
129
  else
133
- return -1
130
+ return -1
134
131
  end
135
132
  `;
136
133
  export const moveToDelayed = {
@@ -1 +1 @@
1
- {"version":3,"file":"moveToDelayed-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToDelayed-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsIf,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"moveToDelayed-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToDelayed-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmIf,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -195,7 +195,6 @@ end
195
195
  Events:
196
196
  'waiting'
197
197
  ]]
198
- local rcall = redis.call
199
198
  -- Includes
200
199
  --[[
201
200
  Function to add job considering priority.
@@ -211,33 +210,20 @@ local function addJobWithPriority(priorityKey, priority, targetKey, jobId)
211
210
  rcall("RPUSH", targetKey, jobId)
212
211
  end
213
212
  end
214
- --[[
215
- Function to check for the meta.paused key to decide if we are paused or not
216
- (since an empty list and !EXISTS are not really the same).
217
- ]]
218
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
219
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
220
- return waitKey
221
- else
222
- return pausedKey
223
- end
224
- end
225
213
  -- Try to get as much as 1000 jobs at once
226
- local function promoteDelayedJobs(delayedKey, waitKey, priorityKey, pausedKey,
227
- metaKey, eventStreamKey, prefix, timestamp)
214
+ local function promoteDelayedJobs(delayedKey, targetKey, priorityKey,
215
+ eventStreamKey, prefix, timestamp)
228
216
  local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000, "LIMIT", 0, 1000)
229
217
  if (#jobs > 0) then
230
218
  rcall("ZREM", delayedKey, unpack(jobs))
231
- -- check if we need to use push in paused instead of waiting
232
- local target = getTargetQueueList(metaKey, waitKey, pausedKey)
233
219
  for _, jobId in ipairs(jobs) do
234
220
  local priority =
235
221
  tonumber(rcall("HGET", prefix .. jobId, "priority")) or 0
236
222
  if priority == 0 then
237
223
  -- LIFO or FIFO
238
- rcall("LPUSH", target, jobId)
224
+ rcall("LPUSH", targetKey, jobId)
239
225
  else
240
- addJobWithPriority(priorityKey, priority, target, jobId)
226
+ addJobWithPriority(priorityKey, priority, targetKey, jobId)
241
227
  end
242
228
  -- Emit waiting event
243
229
  rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",
@@ -269,6 +255,17 @@ end
269
255
  local getJobKeyPrefix = function (jobKey, jobId)
270
256
  return string.sub(jobKey, 0, #jobKey - #jobId)
271
257
  end
258
+ --[[
259
+ Function to check for the meta.paused key to decide if we are paused or not
260
+ (since an empty list and !EXISTS are not really the same).
261
+ ]]
262
+ local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
263
+ if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
264
+ return waitKey
265
+ else
266
+ return pausedKey
267
+ end
268
+ end
272
269
  local function moveParentToWait(parentPrefix, parentId, emitEvent)
273
270
  local parentTarget = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait", parentPrefix .. "paused")
274
271
  rcall("RPUSH", parentTarget, parentId)
@@ -376,11 +373,11 @@ end
376
373
  Add delay marker if needed.
377
374
  ]]
378
375
  -- Includes
379
- local function addDelayMarkerIfNeeded(target, delayedKey)
380
- if rcall("LLEN", target) == 0 then
376
+ local function addDelayMarkerIfNeeded(targetKey, delayedKey)
377
+ if rcall("LLEN", targetKey) == 0 then
381
378
  local nextTimestamp = getNextDelayedTimestamp(delayedKey)
382
379
  if nextTimestamp ~= nil then
383
- rcall("LPUSH", target, "0:" .. nextTimestamp)
380
+ rcall("LPUSH", targetKey, "0:" .. nextTimestamp)
384
381
  end
385
382
  end
386
383
  end
@@ -418,7 +415,7 @@ local function getRateLimitTTL(opts, limiterKey)
418
415
  if jobCounter ~= nil and jobCounter >= maxJobs then
419
416
  local pttl = rcall("PTTL", limiterKey)
420
417
  if pttl > 0 then
421
- return pttl
418
+ return pttl
422
419
  end
423
420
  end
424
421
  end
@@ -526,8 +523,9 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
526
523
  -- Try to get next job to avoid an extra roundtrip if the queue is not closing,
527
524
  -- and not rate limited.
528
525
  if (ARGV[7] == "1") then
526
+ local target = getTargetQueueList(KEYS[11], KEYS[1], KEYS[8])
529
527
  -- Check if there are delayed jobs that can be promoted
530
- promoteDelayedJobs(KEYS[7], KEYS[1], KEYS[3], KEYS[8], KEYS[11],
528
+ promoteDelayedJobs(KEYS[7], target, KEYS[3],
531
529
  KEYS[4], ARGV[8], timestamp)
532
530
  -- Check if we are rate limited first.
533
531
  local pttl = getRateLimitTTL(opts, KEYS[6])
@@ -1 +1 @@
1
- {"version":3,"file":"moveToFinished-12.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-12.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAojBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
1
+ {"version":3,"file":"moveToFinished-12.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-12.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkjBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
@@ -1,13 +1,13 @@
1
1
  const content = `--[[
2
2
  Pauses or resumes a queue globably.
3
- Input:
4
- KEYS[1] 'wait' or 'paused''
5
- KEYS[2] 'paused' or 'wait'
6
- KEYS[3] 'meta'
7
- KEYS[4] events stream key
8
- ARGV[1] 'paused' or 'resumed'
9
- Event:
10
- publish paused or resumed event.
3
+ Input:
4
+ KEYS[1] 'wait' or 'paused''
5
+ KEYS[2] 'paused' or 'wait'
6
+ KEYS[3] 'meta'
7
+ KEYS[4] events stream key
8
+ ARGV[1] 'paused' or 'resumed'
9
+ Event:
10
+ publish paused or resumed event.
11
11
  ]]
12
12
  local rcall = redis.call
13
13
  if rcall("EXISTS", KEYS[1]) == 1 then
@@ -1,6 +1,6 @@
1
1
  const content = `--[[
2
2
  Promotes a job that is currently "delayed" to the "waiting" state
3
- Input:
3
+ Input:
4
4
  KEYS[1] 'delayed'
5
5
  KEYS[2] 'wait'
6
6
  KEYS[3] 'paused'
@@ -9,10 +9,13 @@ const content = `--[[
9
9
  KEYS[6] 'event stream'
10
10
  ARGV[1] queue.toKey('')
11
11
  ARGV[2] jobId
12
- Events:
12
+ Output:
13
+ 0 - OK
14
+ -3 - Job not in delayed zset.
15
+ Events:
13
16
  'waiting'
14
17
  ]]
15
- local rcall = redis.call;
18
+ local rcall = redis.call
16
19
  local jobId = ARGV[2]
17
20
  -- Includes
18
21
  --[[
@@ -1 +1 @@
1
- {"version":3,"file":"promote-6.js","sourceRoot":"","sources":["../../../src/scripts/promote-6.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgEZ,CAAC;AACL,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,SAAS;IACf,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"promote-6.js","sourceRoot":"","sources":["../../../src/scripts/promote-6.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAmEZ,CAAC;AACL,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,SAAS;IACf,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -9,6 +9,8 @@ const content = `--[[
9
9
  Output:
10
10
  0 - OK
11
11
  1 - Missing repeat job
12
+ Events:
13
+ 'removed'
12
14
  ]]
13
15
  local rcall = redis.call
14
16
  local millis = rcall("ZSCORE", KEYS[1], ARGV[2])
@@ -1 +1 @@
1
- {"version":3,"file":"removeRepeatable-2.js","sourceRoot":"","sources":["../../../src/scripts/removeRepeatable-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Bf,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,kBAAkB;IACxB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"removeRepeatable-2.js","sourceRoot":"","sources":["../../../src/scripts/removeRepeatable-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Bf,CAAC;AACF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,kBAAkB;IACxB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -12,7 +12,7 @@ const content = `--[[
12
12
  ARGV[3] propVal - failedReason/returnvalue
13
13
  ARGV[4] prev state - failed/completed
14
14
  Output:
15
- 1 means the operation was a success
15
+ 1 means the operation was a success
16
16
  -1 means the job does not exist
17
17
  -3 means the job was not found in the expected set.
18
18
  ]]
@@ -40,7 +40,6 @@ end
40
40
  Events:
41
41
  'waiting'
42
42
  ]]
43
- local rcall = redis.call
44
43
  -- Includes
45
44
  --[[
46
45
  Function to add job considering priority.
@@ -57,21 +56,19 @@ local function addJobWithPriority(priorityKey, priority, targetKey, jobId)
57
56
  end
58
57
  end
59
58
  -- Try to get as much as 1000 jobs at once
60
- local function promoteDelayedJobs(delayedKey, waitKey, priorityKey, pausedKey,
61
- metaKey, eventStreamKey, prefix, timestamp)
59
+ local function promoteDelayedJobs(delayedKey, targetKey, priorityKey,
60
+ eventStreamKey, prefix, timestamp)
62
61
  local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000, "LIMIT", 0, 1000)
63
62
  if (#jobs > 0) then
64
63
  rcall("ZREM", delayedKey, unpack(jobs))
65
- -- check if we need to use push in paused instead of waiting
66
- local target = getTargetQueueList(metaKey, waitKey, pausedKey)
67
64
  for _, jobId in ipairs(jobs) do
68
65
  local priority =
69
66
  tonumber(rcall("HGET", prefix .. jobId, "priority")) or 0
70
67
  if priority == 0 then
71
68
  -- LIFO or FIFO
72
- rcall("LPUSH", target, jobId)
69
+ rcall("LPUSH", targetKey, jobId)
73
70
  else
74
- addJobWithPriority(priorityKey, priority, target, jobId)
71
+ addJobWithPriority(priorityKey, priority, targetKey, jobId)
75
72
  end
76
73
  -- Emit waiting event
77
74
  rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",
@@ -80,7 +77,8 @@ local function promoteDelayedJobs(delayedKey, waitKey, priorityKey, pausedKey,
80
77
  end
81
78
  end
82
79
  end
83
- promoteDelayedJobs(KEYS[7], KEYS[2], KEYS[8], KEYS[3], KEYS[5], KEYS[6], ARGV[1], ARGV[2])
80
+ local target = getTargetQueueList(KEYS[5], KEYS[2], KEYS[3])
81
+ promoteDelayedJobs(KEYS[7], target, KEYS[8], KEYS[6], ARGV[1], ARGV[2])
84
82
  if rcall("EXISTS", KEYS[4]) == 1 then
85
83
  if ARGV[5] ~= "0" then
86
84
  local lockKey = KEYS[4] .. ':lock'
@@ -90,11 +88,10 @@ if rcall("EXISTS", KEYS[4]) == 1 then
90
88
  return -2
91
89
  end
92
90
  end
93
- local target = getTargetQueueList(KEYS[5], KEYS[2], KEYS[3])
94
91
  rcall("LREM", KEYS[1], 0, ARGV[4])
95
92
  rcall(ARGV[3], target, ARGV[4])
96
93
  -- Emit waiting event
97
- rcall("XADD", KEYS[6], "*", "event", "waiting", "jobId", ARGV[4], "prev", "failed");
94
+ rcall("XADD", KEYS[6], "*", "event", "waiting", "jobId", ARGV[4], "prev", "failed")
98
95
  return 0
99
96
  else
100
97
  return -1
@@ -1 +1 @@
1
- {"version":3,"file":"retryJob-8.js","sourceRoot":"","sources":["../../../src/scripts/retryJob-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqGf,CAAC;AACF,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,UAAU;IAChB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"retryJob-8.js","sourceRoot":"","sources":["../../../src/scripts/retryJob-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkGf,CAAC;AACF,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,UAAU;IAChB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -5,7 +5,7 @@ const content = `--[[
5
5
  ARGV[1] stacktrace
6
6
  ARGV[2] failedReason
7
7
  Output:
8
- 0 - OK
8
+ 0 - OK
9
9
  -1 - Missing key
10
10
  ]]
11
11
  local rcall = redis.call
@@ -2,7 +2,10 @@ const content = `--[[
2
2
  Update job data
3
3
  Input:
4
4
  KEYS[1] Job id key
5
- ARGV[1] data
5
+ ARGV[1] data
6
+ Output:
7
+ 0 - OK
8
+ -1 - Missing job.
6
9
  ]]
7
10
  local rcall = redis.call
8
11
  if rcall("EXISTS",KEYS[1]) == 1 then -- // Make sure job exists
@@ -1 +1 @@
1
- {"version":3,"file":"updateData-1.js","sourceRoot":"","sources":["../../../src/scripts/updateData-1.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;CAaf,CAAC;AACF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"updateData-1.js","sourceRoot":"","sources":["../../../src/scripts/updateData-1.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;CAgBf,CAAC;AACF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -5,6 +5,9 @@ const content = `--[[
5
5
  KEYS[2] event stream key
6
6
  ARGV[1] id
7
7
  ARGV[2] progress
8
+ Output:
9
+ 0 - OK
10
+ -1 - Missing job.
8
11
  Event:
9
12
  progress(jobId, progress)
10
13
  ]]
@@ -1 +1 @@
1
- {"version":3,"file":"updateProgress-2.js","sourceRoot":"","sources":["../../../src/scripts/updateProgress-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;CAkBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"updateProgress-2.js","sourceRoot":"","sources":["../../../src/scripts/updateProgress-2.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;CAqBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}