bullmq 4.17.0 → 5.1.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 (200) hide show
  1. package/dist/cjs/classes/flow-producer.js +3 -10
  2. package/dist/cjs/classes/flow-producer.js.map +1 -1
  3. package/dist/cjs/classes/job.js +21 -11
  4. package/dist/cjs/classes/job.js.map +1 -1
  5. package/dist/cjs/classes/queue-base.js +2 -9
  6. package/dist/cjs/classes/queue-base.js.map +1 -1
  7. package/dist/cjs/classes/queue-events.js +3 -1
  8. package/dist/cjs/classes/queue-events.js.map +1 -1
  9. package/dist/cjs/classes/queue-keys.js +1 -0
  10. package/dist/cjs/classes/queue-keys.js.map +1 -1
  11. package/dist/cjs/classes/queue.js +1 -1
  12. package/dist/cjs/classes/redis-connection.js +9 -7
  13. package/dist/cjs/classes/redis-connection.js.map +1 -1
  14. package/dist/cjs/classes/repeat.js +22 -5
  15. package/dist/cjs/classes/repeat.js.map +1 -1
  16. package/dist/cjs/classes/scripts.js +34 -34
  17. package/dist/cjs/classes/scripts.js.map +1 -1
  18. package/dist/cjs/classes/worker.js +27 -32
  19. package/dist/cjs/classes/worker.js.map +1 -1
  20. package/dist/cjs/commands/{addDelayedJob-7.lua → addDelayedJob-6.lua} +18 -22
  21. package/dist/cjs/commands/addParentJob-4.lua +0 -2
  22. package/dist/{esm/commands/addPrioritizedJob-8.lua → cjs/commands/addPrioritizedJob-7.lua} +18 -24
  23. package/dist/cjs/commands/{addStandardJob-6.lua → addStandardJob-7.lua} +6 -2
  24. package/dist/cjs/commands/changePriority-6.lua +57 -0
  25. package/dist/cjs/commands/getCounts-1.lua +1 -0
  26. package/dist/cjs/commands/getRanges-1.lua +1 -0
  27. package/dist/cjs/commands/includes/addDelayMarkerIfNeeded.lua +5 -19
  28. package/dist/cjs/commands/includes/addJobWithPriority.lua +3 -7
  29. package/dist/cjs/commands/includes/checkStalledJobs.lua +1 -1
  30. package/dist/cjs/commands/includes/isQueuePaused.lua +7 -0
  31. package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +39 -30
  32. package/dist/cjs/commands/includes/prepareJobForProcessing.lua +1 -1
  33. package/dist/cjs/commands/includes/promoteDelayedJobs.lua +7 -4
  34. package/dist/{esm/commands/moveToActive-10.lua → cjs/commands/moveToActive-11.lua} +18 -29
  35. package/dist/cjs/commands/moveToDelayed-7.lua +77 -0
  36. package/dist/cjs/commands/{moveToFinished-13.lua → moveToFinished-14.lua} +29 -22
  37. package/dist/cjs/commands/moveToWaitingChildren-4.lua +7 -4
  38. package/dist/cjs/commands/pause-7.lua +41 -0
  39. package/dist/cjs/commands/promote-8.lua +60 -0
  40. package/dist/cjs/commands/{retryJob-9.lua → retryJob-10.lua} +16 -11
  41. package/dist/cjs/scripts/{addDelayedJob-7.js → addDelayedJob-6.js} +77 -88
  42. package/dist/cjs/scripts/{moveToActive-10.js.map → addDelayedJob-6.js.map} +1 -1
  43. package/dist/cjs/scripts/addParentJob-4.js +51 -61
  44. package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
  45. package/dist/cjs/scripts/{addPrioritizedJob-8.js → addPrioritizedJob-7.js} +80 -93
  46. package/dist/cjs/scripts/addPrioritizedJob-7.js.map +1 -0
  47. package/dist/cjs/scripts/{addStandardJob-6.js → addStandardJob-7.js} +58 -63
  48. package/dist/cjs/scripts/addStandardJob-7.js.map +1 -0
  49. package/dist/cjs/scripts/changePriority-6.js +85 -0
  50. package/dist/cjs/scripts/changePriority-6.js.map +1 -0
  51. package/dist/cjs/scripts/getCounts-1.js +1 -0
  52. package/dist/cjs/scripts/getCounts-1.js.map +1 -1
  53. package/dist/cjs/scripts/getRanges-1.js +1 -0
  54. package/dist/cjs/scripts/getRanges-1.js.map +1 -1
  55. package/dist/cjs/scripts/index.js +10 -10
  56. package/dist/cjs/scripts/index.js.map +1 -1
  57. package/dist/cjs/scripts/moveStalledJobsToWait-8.js +1 -0
  58. package/dist/cjs/scripts/moveStalledJobsToWait-8.js.map +1 -1
  59. package/dist/cjs/scripts/{moveToActive-10.js → moveToActive-11.js} +30 -48
  60. package/dist/cjs/scripts/moveToActive-11.js.map +1 -0
  61. package/dist/cjs/scripts/moveToDelayed-7.js +103 -0
  62. package/dist/cjs/scripts/moveToDelayed-7.js.map +1 -0
  63. package/dist/cjs/scripts/{moveToFinished-13.js → moveToFinished-14.js} +89 -88
  64. package/dist/cjs/scripts/{moveToFinished-13.js.map → moveToFinished-14.js.map} +1 -1
  65. package/dist/cjs/scripts/moveToWaitingChildren-4.js +6 -3
  66. package/dist/cjs/scripts/moveToWaitingChildren-4.js.map +1 -1
  67. package/dist/cjs/scripts/pause-7.js +67 -0
  68. package/dist/cjs/scripts/pause-7.js.map +1 -0
  69. package/dist/cjs/scripts/promote-8.js +79 -0
  70. package/dist/cjs/scripts/promote-8.js.map +1 -0
  71. package/dist/cjs/scripts/{retryJob-9.js → retryJob-10.js} +26 -32
  72. package/dist/cjs/scripts/retryJob-10.js.map +1 -0
  73. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  74. package/dist/esm/classes/flow-producer.js +3 -10
  75. package/dist/esm/classes/flow-producer.js.map +1 -1
  76. package/dist/esm/classes/job.d.ts +5 -0
  77. package/dist/esm/classes/job.js +21 -11
  78. package/dist/esm/classes/job.js.map +1 -1
  79. package/dist/esm/classes/queue-base.js +2 -9
  80. package/dist/esm/classes/queue-base.js.map +1 -1
  81. package/dist/esm/classes/queue-events.js +3 -1
  82. package/dist/esm/classes/queue-events.js.map +1 -1
  83. package/dist/esm/classes/queue-keys.js +1 -0
  84. package/dist/esm/classes/queue-keys.js.map +1 -1
  85. package/dist/esm/classes/queue.d.ts +1 -1
  86. package/dist/esm/classes/queue.js +1 -1
  87. package/dist/esm/classes/redis-connection.js +9 -7
  88. package/dist/esm/classes/redis-connection.js.map +1 -1
  89. package/dist/esm/classes/repeat.js +22 -5
  90. package/dist/esm/classes/repeat.js.map +1 -1
  91. package/dist/esm/classes/scripts.d.ts +4 -4
  92. package/dist/esm/classes/scripts.js +34 -34
  93. package/dist/esm/classes/scripts.js.map +1 -1
  94. package/dist/esm/classes/worker.d.ts +1 -1
  95. package/dist/esm/classes/worker.js +27 -32
  96. package/dist/esm/classes/worker.js.map +1 -1
  97. package/dist/esm/commands/{addDelayedJob-7.lua → addDelayedJob-6.lua} +18 -22
  98. package/dist/esm/commands/addParentJob-4.lua +0 -2
  99. package/dist/{cjs/commands/addPrioritizedJob-8.lua → esm/commands/addPrioritizedJob-7.lua} +18 -24
  100. package/dist/esm/commands/{addStandardJob-6.lua → addStandardJob-7.lua} +6 -2
  101. package/dist/esm/commands/changePriority-6.lua +57 -0
  102. package/dist/esm/commands/getCounts-1.lua +1 -0
  103. package/dist/esm/commands/getRanges-1.lua +1 -0
  104. package/dist/esm/commands/includes/addDelayMarkerIfNeeded.lua +5 -19
  105. package/dist/esm/commands/includes/addJobWithPriority.lua +3 -7
  106. package/dist/esm/commands/includes/checkStalledJobs.lua +1 -1
  107. package/dist/esm/commands/includes/isQueuePaused.lua +7 -0
  108. package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +39 -30
  109. package/dist/esm/commands/includes/prepareJobForProcessing.lua +1 -1
  110. package/dist/esm/commands/includes/promoteDelayedJobs.lua +7 -4
  111. package/dist/{cjs/commands/moveToActive-10.lua → esm/commands/moveToActive-11.lua} +18 -29
  112. package/dist/esm/commands/moveToDelayed-7.lua +77 -0
  113. package/dist/esm/commands/{moveToFinished-13.lua → moveToFinished-14.lua} +29 -22
  114. package/dist/esm/commands/moveToWaitingChildren-4.lua +7 -4
  115. package/dist/esm/commands/pause-7.lua +41 -0
  116. package/dist/esm/commands/promote-8.lua +60 -0
  117. package/dist/esm/commands/{retryJob-9.lua → retryJob-10.lua} +16 -11
  118. package/dist/esm/interfaces/job-json.d.ts +4 -1
  119. package/dist/esm/interfaces/minimal-job.d.ts +3 -0
  120. package/dist/esm/interfaces/queue-options.d.ts +1 -1
  121. package/dist/esm/interfaces/repeat-options.d.ts +7 -0
  122. package/dist/esm/scripts/{addDelayedJob-7.js → addDelayedJob-6.js} +77 -88
  123. package/dist/esm/scripts/{moveToActive-10.js.map → addDelayedJob-6.js.map} +1 -1
  124. package/dist/esm/scripts/addParentJob-4.js +51 -61
  125. package/dist/esm/scripts/addParentJob-4.js.map +1 -1
  126. package/dist/esm/scripts/{addPrioritizedJob-8.js → addPrioritizedJob-7.js} +80 -93
  127. package/dist/esm/scripts/addPrioritizedJob-7.js.map +1 -0
  128. package/dist/esm/scripts/{addStandardJob-6.js → addStandardJob-7.js} +58 -63
  129. package/dist/esm/scripts/addStandardJob-7.js.map +1 -0
  130. package/dist/esm/scripts/changePriority-6.js +82 -0
  131. package/dist/esm/scripts/changePriority-6.js.map +1 -0
  132. package/dist/esm/scripts/getCounts-1.js +1 -0
  133. package/dist/esm/scripts/getCounts-1.js.map +1 -1
  134. package/dist/esm/scripts/getRanges-1.js +1 -0
  135. package/dist/esm/scripts/getRanges-1.js.map +1 -1
  136. package/dist/esm/scripts/index.d.ts +10 -10
  137. package/dist/esm/scripts/index.js +10 -10
  138. package/dist/esm/scripts/index.js.map +1 -1
  139. package/dist/esm/scripts/moveStalledJobsToWait-8.js +1 -0
  140. package/dist/esm/scripts/moveStalledJobsToWait-8.js.map +1 -1
  141. package/dist/esm/scripts/{moveToActive-10.js → moveToActive-11.js} +30 -48
  142. package/dist/esm/scripts/moveToActive-11.js.map +1 -0
  143. package/dist/esm/scripts/moveToDelayed-7.js +100 -0
  144. package/dist/esm/scripts/moveToDelayed-7.js.map +1 -0
  145. package/dist/esm/scripts/{moveToFinished-13.js → moveToFinished-14.js} +89 -88
  146. package/dist/esm/scripts/{moveToFinished-13.js.map → moveToFinished-14.js.map} +1 -1
  147. package/dist/esm/scripts/moveToWaitingChildren-4.js +6 -3
  148. package/dist/esm/scripts/moveToWaitingChildren-4.js.map +1 -1
  149. package/dist/esm/scripts/pause-7.js +64 -0
  150. package/dist/esm/scripts/pause-7.js.map +1 -0
  151. package/dist/esm/scripts/promote-8.js +76 -0
  152. package/dist/esm/scripts/promote-8.js.map +1 -0
  153. package/dist/esm/scripts/{retryJob-9.js → retryJob-10.js} +26 -32
  154. package/dist/esm/scripts/retryJob-10.js.map +1 -0
  155. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  156. package/package.json +2 -1
  157. package/dist/cjs/commands/changePriority-5.lua +0 -52
  158. package/dist/cjs/commands/includes/addPriorityMarkerIfNeeded.lua +0 -12
  159. package/dist/cjs/commands/moveToDelayed-8.lua +0 -72
  160. package/dist/cjs/commands/pause-5.lua +0 -36
  161. package/dist/cjs/commands/promote-7.lua +0 -57
  162. package/dist/cjs/scripts/addDelayedJob-7.js.map +0 -1
  163. package/dist/cjs/scripts/addPrioritizedJob-8.js.map +0 -1
  164. package/dist/cjs/scripts/addStandardJob-6.js.map +0 -1
  165. package/dist/cjs/scripts/changePriority-5.js +0 -87
  166. package/dist/cjs/scripts/changePriority-5.js.map +0 -1
  167. package/dist/cjs/scripts/moveToDelayed-8.js +0 -168
  168. package/dist/cjs/scripts/moveToDelayed-8.js.map +0 -1
  169. package/dist/cjs/scripts/pause-5.js +0 -48
  170. package/dist/cjs/scripts/pause-5.js.map +0 -1
  171. package/dist/cjs/scripts/promote-7.js +0 -87
  172. package/dist/cjs/scripts/promote-7.js.map +0 -1
  173. package/dist/cjs/scripts/retryJob-9.js.map +0 -1
  174. package/dist/esm/commands/changePriority-5.lua +0 -52
  175. package/dist/esm/commands/includes/addPriorityMarkerIfNeeded.lua +0 -12
  176. package/dist/esm/commands/moveToDelayed-8.lua +0 -72
  177. package/dist/esm/commands/pause-5.lua +0 -36
  178. package/dist/esm/commands/promote-7.lua +0 -57
  179. package/dist/esm/scripts/addDelayedJob-7.js.map +0 -1
  180. package/dist/esm/scripts/addPrioritizedJob-8.js.map +0 -1
  181. package/dist/esm/scripts/addStandardJob-6.js.map +0 -1
  182. package/dist/esm/scripts/changePriority-5.js +0 -84
  183. package/dist/esm/scripts/changePriority-5.js.map +0 -1
  184. package/dist/esm/scripts/moveToDelayed-8.js +0 -165
  185. package/dist/esm/scripts/moveToDelayed-8.js.map +0 -1
  186. package/dist/esm/scripts/pause-5.js +0 -45
  187. package/dist/esm/scripts/pause-5.js.map +0 -1
  188. package/dist/esm/scripts/promote-7.js +0 -84
  189. package/dist/esm/scripts/promote-7.js.map +0 -1
  190. package/dist/esm/scripts/retryJob-9.js.map +0 -1
  191. /package/dist/esm/scripts/{addDelayedJob-7.d.ts → addDelayedJob-6.d.ts} +0 -0
  192. /package/dist/esm/scripts/{addPrioritizedJob-8.d.ts → addPrioritizedJob-7.d.ts} +0 -0
  193. /package/dist/esm/scripts/{addStandardJob-6.d.ts → addStandardJob-7.d.ts} +0 -0
  194. /package/dist/esm/scripts/{changePriority-5.d.ts → changePriority-6.d.ts} +0 -0
  195. /package/dist/esm/scripts/{moveToActive-10.d.ts → moveToActive-11.d.ts} +0 -0
  196. /package/dist/esm/scripts/{moveToDelayed-8.d.ts → moveToDelayed-7.d.ts} +0 -0
  197. /package/dist/esm/scripts/{moveToFinished-13.d.ts → moveToFinished-14.d.ts} +0 -0
  198. /package/dist/esm/scripts/{pause-5.d.ts → pause-7.d.ts} +0 -0
  199. /package/dist/esm/scripts/{promote-7.d.ts → promote-8.d.ts} +0 -0
  200. /package/dist/esm/scripts/{retryJob-9.d.ts → retryJob-10.d.ts} +0 -0
@@ -13,15 +13,16 @@ const content = `--[[
13
13
  -- Rate limiting
14
14
  KEYS[6] rate limiter key
15
15
  KEYS[7] delayed key
16
- -- Promote delayed jobs
16
+ -- Delayed jobs
17
17
  KEYS[8] paused key
18
18
  KEYS[9] meta key
19
19
  KEYS[10] pc priority counter
20
+ -- Marker
21
+ KEYS[11] marker key
20
22
  -- Arguments
21
23
  ARGV[1] key prefix
22
24
  ARGV[2] timestamp
23
- ARGV[3] optional job ID
24
- ARGV[4] opts
25
+ ARGV[3] opts
25
26
  opts - token - lock token
26
27
  opts - lockDuration
27
28
  opts - limiter
@@ -31,7 +32,7 @@ local waitKey = KEYS[1]
31
32
  local activeKey = KEYS[2]
32
33
  local rateLimiterKey = KEYS[6]
33
34
  local delayedKey = KEYS[7]
34
- local opts = cmsgpack.unpack(ARGV[4])
35
+ local opts = cmsgpack.unpack(ARGV[3])
35
36
  -- Includes
36
37
  --[[
37
38
  Function to return the next delayed job timestamp.
@@ -142,7 +143,7 @@ local function prepareJobForProcessing(keys, keyPrefix, targetKey, jobId, proces
142
143
  end
143
144
  rcall("XADD", keys[4], "*", "event", "active", "jobId", jobId, "prev", "waiting")
144
145
  rcall("HSET", jobKey, "processedOn", processedOn)
145
- rcall("HINCRBY", jobKey, "attemptsMade", 1)
146
+ rcall("HINCRBY", jobKey, "ats", 1)
146
147
  return {rcall("HGETALL", jobKey), jobId, 0, 0} -- get job data
147
148
  end
148
149
  --[[
@@ -155,29 +156,17 @@ end
155
156
  --[[
156
157
  Function to add job considering priority.
157
158
  ]]
158
- -- Includes
159
- --[[
160
- Function priority marker to wait if needed
161
- in order to wake up our workers and to respect priority
162
- order as much as possible
163
- ]]
164
- local function addPriorityMarkerIfNeeded(waitKey)
165
- local waitLen = rcall("LLEN", waitKey)
166
- if waitLen == 0 then
167
- rcall("LPUSH", waitKey, "0:0")
168
- end
169
- end
170
- local function addJobWithPriority(waitKey, prioritizedKey, priority, paused, jobId, priorityCounterKey)
159
+ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
171
160
  local prioCounter = rcall("INCR", priorityCounterKey)
172
161
  local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
173
162
  rcall("ZADD", prioritizedKey, score, jobId)
174
- if not paused then
175
- addPriorityMarkerIfNeeded(waitKey)
163
+ if not isPaused then
164
+ rcall("ZADD", markerKey, 0, "0")
176
165
  end
177
166
  end
178
167
  -- Try to get as much as 1000 jobs at once
179
- local function promoteDelayedJobs(delayedKey, waitKey, targetKey, prioritizedKey,
180
- eventStreamKey, prefix, timestamp, paused, priorityCounterKey)
168
+ local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,
169
+ eventStreamKey, prefix, timestamp, priorityCounterKey, isPaused)
181
170
  local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000, "LIMIT", 0, 1000)
182
171
  if (#jobs > 0) then
183
172
  rcall("ZREM", delayedKey, unpack(jobs))
@@ -188,9 +177,12 @@ local function promoteDelayedJobs(delayedKey, waitKey, targetKey, prioritizedKey
188
177
  if priority == 0 then
189
178
  -- LIFO or FIFO
190
179
  rcall("LPUSH", targetKey, jobId)
180
+ if not isPaused then
181
+ rcall("ZADD", markerKey, 0, "0")
182
+ end
191
183
  else
192
- addJobWithPriority(waitKey, prioritizedKey, priority, paused,
193
- jobId, priorityCounterKey)
184
+ addJobWithPriority(markerKey, prioritizedKey, priority,
185
+ jobId, priorityCounterKey, isPaused)
194
186
  end
195
187
  -- Emit waiting event
196
188
  rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",
@@ -201,31 +193,21 @@ local function promoteDelayedJobs(delayedKey, waitKey, targetKey, prioritizedKey
201
193
  end
202
194
  local target, paused = getTargetQueueList(KEYS[9], waitKey, KEYS[8])
203
195
  -- Check if there are delayed jobs that we can move to wait.
204
- promoteDelayedJobs(delayedKey, waitKey, target, KEYS[3], KEYS[4], ARGV[1],
205
- ARGV[2], paused, KEYS[10])
196
+ local markerKey = KEYS[11]
197
+ promoteDelayedJobs(delayedKey, markerKey, target, KEYS[3], KEYS[4], ARGV[1],
198
+ ARGV[2], KEYS[10], paused)
206
199
  local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
207
200
  local expireTime = getRateLimitTTL(maxJobs, rateLimiterKey)
208
- local jobId = nil
209
- if ARGV[3] ~= "" then
210
- jobId = ARGV[3]
211
- -- clean stalled key
212
- rcall("SREM", KEYS[5], jobId)
213
- end
214
- if not jobId or (jobId and string.sub(jobId, 1, 2) == "0:") then
215
- -- If jobId is special ID 0:delay, then there is no job to process
216
- if jobId then rcall("LREM", activeKey, 1, jobId) end
217
- -- Check if we are rate limited first.
218
- if expireTime > 0 then return {0, 0, expireTime, 0} end
219
- -- paused queue
220
- if paused then return {0, 0, 0, 0} end
221
- -- no job ID, try non-blocking move from wait to active
201
+ -- Check if we are rate limited first.
202
+ if expireTime > 0 then return {0, 0, expireTime, 0} end
203
+ -- paused queue
204
+ if paused then return {0, 0, 0, 0} end
205
+ -- no job ID, try non-blocking move from wait to active
206
+ local jobId = rcall("RPOPLPUSH", waitKey, activeKey)
207
+ -- Markers in waitlist DEPRECATED in v5: Will be completely removed in v6.
208
+ if jobId and string.sub(jobId, 1, 2) == "0:" then
209
+ rcall("LREM", activeKey, 1, jobId)
222
210
  jobId = rcall("RPOPLPUSH", waitKey, activeKey)
223
- -- Since it is possible that between a call to BRPOPLPUSH and moveToActive
224
- -- another script puts a new maker in wait, we need to check again.
225
- if jobId and string.sub(jobId, 1, 2) == "0:" then
226
- rcall("LREM", activeKey, 1, jobId)
227
- jobId = rcall("RPOPLPUSH", waitKey, activeKey)
228
- end
229
211
  end
230
212
  if jobId then
231
213
  return prepareJobForProcessing(KEYS, ARGV[1], target, jobId, ARGV[2],
@@ -245,6 +227,6 @@ return {0, 0, 0, 0}
245
227
  export const moveToActive = {
246
228
  name: 'moveToActive',
247
229
  content,
248
- keys: 10,
230
+ keys: 11,
249
231
  };
250
- //# sourceMappingURL=moveToActive-10.js.map
232
+ //# sourceMappingURL=moveToActive-11.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moveToActive-11.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-11.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiOf,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
@@ -0,0 +1,100 @@
1
+ const content = `--[[
2
+ Moves job from active to delayed set.
3
+ Input:
4
+ KEYS[1] marker key
5
+ KEYS[2] active key
6
+ KEYS[3] prioritized key
7
+ KEYS[4] delayed key
8
+ KEYS[5] job key
9
+ KEYS[6] events stream
10
+ KEYS[7] meta key
11
+ ARGV[1] key prefix
12
+ ARGV[2] timestamp
13
+ ARGV[3] delayedTimestamp
14
+ ARGV[4] the id of the job
15
+ ARGV[5] queue token
16
+ ARGV[6] delay value
17
+ ARGV[7] skip attempt
18
+ Output:
19
+ 0 - OK
20
+ -1 - Missing job.
21
+ -3 - Job not in active set.
22
+ Events:
23
+ - delayed key.
24
+ ]]
25
+ local rcall = redis.call
26
+ -- Includes
27
+ --[[
28
+ Add delay marker if needed.
29
+ ]]
30
+ -- Includes
31
+ --[[
32
+ Function to return the next delayed job timestamp.
33
+ ]]
34
+ local function getNextDelayedTimestamp(delayedKey)
35
+ local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
36
+ if #result then
37
+ local nextTimestamp = tonumber(result[2])
38
+ if (nextTimestamp ~= nil) then
39
+ nextTimestamp = nextTimestamp / 0x1000
40
+ end
41
+ return nextTimestamp
42
+ end
43
+ end
44
+ local function addDelayMarkerIfNeeded(markerKey, delayedKey)
45
+ local nextTimestamp = getNextDelayedTimestamp(delayedKey)
46
+ if nextTimestamp ~= nil then
47
+ -- Replace the score of the marker with the newest known
48
+ -- next timestamp.
49
+ rcall("ZADD", markerKey, nextTimestamp, "0")
50
+ end
51
+ end
52
+ --[[
53
+ Function to check for the meta.paused key to decide if we are paused or not
54
+ (since an empty list and !EXISTS are not really the same).
55
+ ]]
56
+ local function isQueuePaused(queueMetaKey)
57
+ return rcall("HEXISTS", queueMetaKey, "paused") == 1
58
+ end
59
+ local jobKey = KEYS[5]
60
+ local metaKey = KEYS[7]
61
+ if rcall("EXISTS", jobKey) == 1 then
62
+ local delayedKey = KEYS[4]
63
+ if ARGV[5] ~= "0" then
64
+ local lockKey = jobKey .. ':lock'
65
+ if rcall("GET", lockKey) == ARGV[5] then
66
+ rcall("DEL", lockKey)
67
+ else
68
+ return -2
69
+ end
70
+ end
71
+ local jobId = ARGV[4]
72
+ local score = tonumber(ARGV[3])
73
+ local delayedTimestamp = (score / 0x1000)
74
+ local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)
75
+ if numRemovedElements < 1 then return -3 end
76
+ if ARGV[7] == "0" then
77
+ rcall("HINCRBY", jobKey, "atm", 1)
78
+ end
79
+ rcall("HSET", jobKey, "delay", ARGV[6])
80
+ local maxEvents = rcall("HGET", metaKey, "opts.maxLenEvents") or 10000
81
+ rcall("ZADD", delayedKey, score, jobId)
82
+ rcall("XADD", KEYS[6], "MAXLEN", "~", maxEvents, "*", "event", "delayed",
83
+ "jobId", jobId, "delay", delayedTimestamp)
84
+ -- Check if we need to push a marker job to wake up sleeping workers.
85
+ local isPaused = isQueuePaused(metaKey)
86
+ if not isPaused then
87
+ local markerKey = KEYS[1]
88
+ addDelayMarkerIfNeeded(markerKey, delayedKey)
89
+ end
90
+ return 0
91
+ else
92
+ return -1
93
+ end
94
+ `;
95
+ export const moveToDelayed = {
96
+ name: 'moveToDelayed',
97
+ content,
98
+ keys: 7,
99
+ };
100
+ //# sourceMappingURL=moveToDelayed-7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moveToDelayed-7.js","sourceRoot":"","sources":["../../../src/scripts/moveToDelayed-7.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Ff,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -18,20 +18,19 @@ const content = `--[[
18
18
  KEYS[11] completed/failed key
19
19
  KEYS[12] jobId key
20
20
  KEYS[13] metrics key
21
+ KEYS[14] marker key
21
22
  ARGV[1] jobId
22
23
  ARGV[2] timestamp
23
24
  ARGV[3] msg property returnvalue / failedReason
24
25
  ARGV[4] return value / failed reason
25
26
  ARGV[5] target (completed/failed)
26
- ARGV[6] event data (? maybe just send jobid).
27
- ARGV[7] fetch next?
28
- ARGV[8] keys prefix
29
- ARGV[9] opts
27
+ ARGV[6] fetch next?
28
+ ARGV[7] keys prefix
29
+ ARGV[8] opts
30
30
  opts - token - lock token
31
31
  opts - keepJobs
32
32
  opts - lockDuration - lock duration in milliseconds
33
33
  opts - attempts max attempts
34
- opts - attemptsMade
35
34
  opts - maxMetricsSize
36
35
  opts - fpof - fail parent on fail
37
36
  opts - rdof - remove dependency on fail
@@ -187,7 +186,7 @@ local function prepareJobForProcessing(keys, keyPrefix, targetKey, jobId, proces
187
186
  end
188
187
  rcall("XADD", keys[4], "*", "event", "active", "jobId", jobId, "prev", "waiting")
189
188
  rcall("HSET", jobKey, "processedOn", processedOn)
190
- rcall("HINCRBY", jobKey, "attemptsMade", 1)
189
+ rcall("HINCRBY", jobKey, "ats", 1)
191
190
  return {rcall("HGETALL", jobKey), jobId, 0, 0} -- get job data
192
191
  end
193
192
  --[[
@@ -200,49 +199,32 @@ end
200
199
  -- Includes
201
200
  --[[
202
201
  Add delay marker if needed.
203
- ]]
202
+ ]]
204
203
  -- Includes
205
- local function addDelayMarkerIfNeeded(targetKey, delayedKey)
206
- local waitLen = rcall("LLEN", targetKey)
207
- if waitLen <= 1 then
204
+ local function addDelayMarkerIfNeeded(markerKey, delayedKey)
208
205
  local nextTimestamp = getNextDelayedTimestamp(delayedKey)
209
206
  if nextTimestamp ~= nil then
210
- -- Check if there is already a marker with older timestamp
211
- -- if there is, we need to replace it.
212
- if waitLen == 1 then
213
- local marker = rcall("LINDEX", targetKey, 0)
214
- local oldTimestamp = tonumber(marker:sub(3))
215
- if oldTimestamp and oldTimestamp > nextTimestamp then
216
- rcall("LSET", targetKey, 0, "0:" .. nextTimestamp)
217
- end
218
- else
219
- -- if there is no marker, then we need to add one
220
- rcall("LPUSH", targetKey, "0:" .. nextTimestamp)
221
- end
207
+ -- Replace the score of the marker with the newest known
208
+ -- next timestamp.
209
+ rcall("ZADD", markerKey, nextTimestamp, "0")
222
210
  end
223
- end
224
211
  end
225
212
  --[[
226
- Function to add job considering priority.
213
+ Function to check for the meta.paused key to decide if we are paused or not
214
+ (since an empty list and !EXISTS are not really the same).
227
215
  ]]
228
- -- Includes
216
+ local function isQueuePaused(queueMetaKey)
217
+ return rcall("HEXISTS", queueMetaKey, "paused") == 1
218
+ end
229
219
  --[[
230
- Function priority marker to wait if needed
231
- in order to wake up our workers and to respect priority
232
- order as much as possible
220
+ Function to add job considering priority.
233
221
  ]]
234
- local function addPriorityMarkerIfNeeded(waitKey)
235
- local waitLen = rcall("LLEN", waitKey)
236
- if waitLen == 0 then
237
- rcall("LPUSH", waitKey, "0:0")
238
- end
239
- end
240
- local function addJobWithPriority(waitKey, prioritizedKey, priority, paused, jobId, priorityCounterKey)
222
+ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
241
223
  local prioCounter = rcall("INCR", priorityCounterKey)
242
224
  local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
243
225
  rcall("ZADD", prioritizedKey, score, jobId)
244
- if not paused then
245
- addPriorityMarkerIfNeeded(waitKey)
226
+ if not isPaused then
227
+ rcall("ZADD", markerKey, 0, "0")
246
228
  end
247
229
  end
248
230
  --[[
@@ -256,35 +238,44 @@ local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
256
238
  return pausedKey, true
257
239
  end
258
240
  end
259
- local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
260
- local isParentActive = rcall("ZSCORE", parentQueueKey .. ":waiting-children", parentId)
261
- if rcall("SCARD", parentDependenciesKey) == 0 and isParentActive then
262
- rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
263
- local parentWaitKey = parentQueueKey .. ":wait"
264
- local parentTarget, paused = getTargetQueueList(parentQueueKey .. ":meta", parentWaitKey,
265
- parentQueueKey .. ":paused")
266
- local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
267
- local priority = tonumber(jobAttributes[1]) or 0
268
- local delay = tonumber(jobAttributes[2]) or 0
269
- if delay > 0 then
270
- local delayedTimestamp = tonumber(timestamp) + delay
271
- local score = delayedTimestamp * 0x1000
272
- local parentDelayedKey = parentQueueKey .. ":delayed"
273
- rcall("ZADD", parentDelayedKey, score, parentId)
274
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId,
275
- "delay", delayedTimestamp)
276
- addDelayMarkerIfNeeded(parentTarget, parentDelayedKey)
277
- else
278
- if priority == 0 then
279
- rcall("RPUSH", parentTarget, parentId)
280
- else
281
- addJobWithPriority(parentWaitKey, parentQueueKey .. ":prioritized", priority, paused,
282
- parentId, parentQueueKey .. ":pc")
283
- end
284
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId,
285
- "prev", "waiting-children")
241
+ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
242
+ parentKey, parentId, timestamp)
243
+ local isParentActive = rcall("ZSCORE",
244
+ parentQueueKey .. ":waiting-children", parentId)
245
+ if rcall("SCARD", parentDependenciesKey) == 0 and isParentActive then
246
+ rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
247
+ local parentWaitKey = parentQueueKey .. ":wait"
248
+ local parentPausedKey = parentQueueKey .. ":paused"
249
+ local parentMetaKey = parentQueueKey .. ":meta"
250
+ local parentMarkerKey = parentQueueKey .. ":marker"
251
+ local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
252
+ local priority = tonumber(jobAttributes[1]) or 0
253
+ local delay = tonumber(jobAttributes[2]) or 0
254
+ if delay > 0 then
255
+ local delayedTimestamp = tonumber(timestamp) + delay
256
+ local score = delayedTimestamp * 0x1000
257
+ local parentDelayedKey = parentQueueKey .. ":delayed"
258
+ rcall("ZADD", parentDelayedKey, score, parentId)
259
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed",
260
+ "jobId", parentId, "delay", delayedTimestamp)
261
+ addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
262
+ else
263
+ if priority == 0 then
264
+ local parentTarget, _paused =
265
+ getTargetQueueList(parentMetaKey, parentWaitKey,
266
+ parentPausedKey)
267
+ rcall("RPUSH", parentTarget, parentId)
268
+ rcall("ZADD", parentMarkerKey, 0, "0")
269
+ else
270
+ local isPaused = isQueuePaused(parentMetaKey)
271
+ addJobWithPriority(parentMarkerKey,
272
+ parentQueueKey .. ":prioritized", priority,
273
+ parentId, parentQueueKey .. ":pc", isPaused)
274
+ end
275
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
276
+ "jobId", parentId, "prev", "waiting-children")
277
+ end
286
278
  end
287
- end
288
279
  end
289
280
  local function moveParentFromWaitingChildrenToFailed( parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
290
281
  if rcall("ZREM", parentQueueKey .. ":waiting-children", parentId) == 1 then
@@ -323,8 +314,8 @@ end
323
314
  ]]
324
315
  -- Includes
325
316
  -- Try to get as much as 1000 jobs at once
326
- local function promoteDelayedJobs(delayedKey, waitKey, targetKey, prioritizedKey,
327
- eventStreamKey, prefix, timestamp, paused, priorityCounterKey)
317
+ local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,
318
+ eventStreamKey, prefix, timestamp, priorityCounterKey, isPaused)
328
319
  local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000, "LIMIT", 0, 1000)
329
320
  if (#jobs > 0) then
330
321
  rcall("ZREM", delayedKey, unpack(jobs))
@@ -335,9 +326,12 @@ local function promoteDelayedJobs(delayedKey, waitKey, targetKey, prioritizedKey
335
326
  if priority == 0 then
336
327
  -- LIFO or FIFO
337
328
  rcall("LPUSH", targetKey, jobId)
329
+ if not isPaused then
330
+ rcall("ZADD", markerKey, 0, "0")
331
+ end
338
332
  else
339
- addJobWithPriority(waitKey, prioritizedKey, priority, paused,
340
- jobId, priorityCounterKey)
333
+ addJobWithPriority(markerKey, prioritizedKey, priority,
334
+ jobId, priorityCounterKey, isPaused)
341
335
  end
342
336
  -- Emit waiting event
343
337
  rcall("XADD", eventStreamKey, "*", "event", "waiting", "jobId",
@@ -492,10 +486,9 @@ local function getRateLimitTTL(maxJobs, rateLimiterKey)
492
486
  end
493
487
  local jobIdKey = KEYS[12]
494
488
  if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
495
- local opts = cmsgpack.unpack(ARGV[9])
489
+ local opts = cmsgpack.unpack(ARGV[8])
496
490
  local token = opts['token']
497
491
  local attempts = opts['attempts']
498
- local attemptsMade = opts['attemptsMade']
499
492
  local maxMetricsSize = opts['maxMetricsSize']
500
493
  local maxCount = opts['keepJobs']['count']
501
494
  local maxAge = opts['keepJobs']['age']
@@ -532,8 +525,9 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
532
525
  -- Remove from active list (if not active we shall return error)
533
526
  local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)
534
527
  if (numRemovedElements < 1) then return -3 end
528
+ local metaKey = KEYS[9]
535
529
  -- Trim events before emiting them to avoid trimming events emitted in this script
536
- trimEvents(KEYS[9], KEYS[4])
530
+ trimEvents(metaKey, KEYS[4])
537
531
  -- If job has a parent we need to
538
532
  -- 1) remove this job id from parents dependencies
539
533
  -- 2) move the job Id to parent "processed" set
@@ -554,16 +548,18 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
554
548
  else
555
549
  if opts['fpof'] then
556
550
  moveParentFromWaitingChildrenToFailed(parentQueueKey, parentKey,
557
- parentId, jobIdKey, timestamp)
551
+ parentId, jobIdKey,
552
+ timestamp)
558
553
  elseif opts['rdof'] then
559
554
  local dependenciesSet = parentKey .. ":dependencies"
560
555
  if rcall("SREM", dependenciesSet, jobIdKey) == 1 then
561
556
  moveParentToWaitIfNeeded(parentQueueKey, dependenciesSet,
562
- parentKey, parentId, timestamp)
557
+ parentKey, parentId, timestamp)
563
558
  end
564
559
  end
565
560
  end
566
561
  end
562
+ local attemptsMade = rcall("HINCRBY", jobIdKey, "atm", 1)
567
563
  -- Remove job?
568
564
  if maxCount ~= 0 then
569
565
  local targetSet = KEYS[11]
@@ -572,7 +568,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
572
568
  rcall("HMSET", jobIdKey, ARGV[3], ARGV[4], "finishedOn", timestamp)
573
569
  -- "returnvalue" / "failedReason" and "finishedOn"
574
570
  -- Remove old jobs?
575
- local prefix = ARGV[8]
571
+ local prefix = ARGV[7]
576
572
  if maxAge ~= nil then
577
573
  removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix)
578
574
  end
@@ -599,11 +595,11 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
599
595
  end
600
596
  -- Try to get next job to avoid an extra roundtrip if the queue is not closing,
601
597
  -- and not rate limited.
602
- if (ARGV[7] == "1") then
603
- local target, paused = getTargetQueueList(KEYS[9], KEYS[1], KEYS[8])
598
+ if (ARGV[6] == "1") then
599
+ local target, paused = getTargetQueueList(metaKey, KEYS[1], KEYS[8])
604
600
  -- Check if there are delayed jobs that can be promoted
605
- promoteDelayedJobs(KEYS[7], KEYS[1], target, KEYS[3],
606
- KEYS[4], ARGV[8], timestamp, paused, KEYS[10])
601
+ promoteDelayedJobs(KEYS[7], KEYS[14], target, KEYS[3], KEYS[4], ARGV[7],
602
+ timestamp, KEYS[10], paused)
607
603
  local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
608
604
  -- Check if we are rate limited first.
609
605
  local expireTime = getRateLimitTTL(maxJobs, KEYS[6])
@@ -612,24 +608,29 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
612
608
  if paused then return {0, 0, 0, 0} end
613
609
  jobId = rcall("RPOPLPUSH", KEYS[1], KEYS[2])
614
610
  if jobId then
611
+ -- Markers in waitlist DEPRECATED in v5: Remove in v6.
615
612
  if string.sub(jobId, 1, 2) == "0:" then
616
613
  rcall("LREM", KEYS[2], 1, jobId)
617
614
  -- If jobId is special ID 0:delay (delay greater than 0), then there is no job to process
618
615
  -- but if ID is 0:0, then there is at least 1 prioritized job to process
619
616
  if jobId == "0:0" then
620
- jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2], KEYS[10])
621
- return prepareJobForProcessing(KEYS, ARGV[8], target, jobId, timestamp,
622
- maxJobs, expireTime, opts)
617
+ jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2],
618
+ KEYS[10])
619
+ return prepareJobForProcessing(KEYS, ARGV[7], target, jobId,
620
+ timestamp, maxJobs,
621
+ expireTime, opts)
623
622
  end
624
623
  else
625
- return prepareJobForProcessing(KEYS, ARGV[8], target, jobId, timestamp, maxJobs,
626
- expireTime, opts)
624
+ return prepareJobForProcessing(KEYS, ARGV[7], target, jobId,
625
+ timestamp, maxJobs, expireTime,
626
+ opts)
627
627
  end
628
628
  else
629
629
  jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2], KEYS[10])
630
630
  if jobId then
631
- return prepareJobForProcessing(KEYS, ARGV[8], target, jobId, timestamp, maxJobs,
632
- expireTime, opts)
631
+ return prepareJobForProcessing(KEYS, ARGV[7], target, jobId,
632
+ timestamp, maxJobs, expireTime,
633
+ opts)
633
634
  end
634
635
  end
635
636
  -- Return the timestamp for the next delayed job if any.
@@ -658,6 +659,6 @@ end
658
659
  export const moveToFinished = {
659
660
  name: 'moveToFinished',
660
661
  content,
661
- keys: 13,
662
+ keys: 14,
662
663
  };
663
- //# sourceMappingURL=moveToFinished-13.js.map
664
+ //# sourceMappingURL=moveToFinished-14.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"moveToFinished-13.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-13.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgpBf,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAipBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
@@ -17,7 +17,8 @@ const content = `--[[
17
17
  -3 - Job not in active set
18
18
  ]]
19
19
  local rcall = redis.call
20
- local function moveToWaitingChildren (activeKey, waitingChildrenKey, jobId, timestamp, lockKey, token)
20
+ local function moveToWaitingChildren (activeKey, waitingChildrenKey, jobId, timestamp,
21
+ lockKey, jobKey, token)
21
22
  if token ~= "0" then
22
23
  if rcall("GET", lockKey) == token then
23
24
  rcall("DEL", lockKey)
@@ -36,12 +37,14 @@ end
36
37
  if rcall("EXISTS", KEYS[4]) == 1 then
37
38
  if ARGV[2] ~= "" then
38
39
  if rcall("SISMEMBER", KEYS[4] .. ":dependencies", ARGV[2]) ~= 0 then
39
- return moveToWaitingChildren(KEYS[2], KEYS[3], ARGV[4], ARGV[3], KEYS[1], ARGV[1])
40
+ return moveToWaitingChildren(KEYS[2], KEYS[3], ARGV[4], ARGV[3], KEYS[1], KEYS[4],
41
+ ARGV[1])
40
42
  end
41
43
  return 1
42
44
  else
43
45
  if rcall("SCARD", KEYS[4] .. ":dependencies") ~= 0 then
44
- return moveToWaitingChildren(KEYS[2], KEYS[3], ARGV[4], ARGV[3], KEYS[1], ARGV[1])
46
+ return moveToWaitingChildren(KEYS[2], KEYS[3], ARGV[4], ARGV[3], KEYS[1], KEYS[4],
47
+ ARGV[1])
45
48
  end
46
49
  return 1
47
50
  end
@@ -1 +1 @@
1
- {"version":3,"file":"moveToWaitingChildren-4.js","sourceRoot":"","sources":["../../../src/scripts/moveToWaitingChildren-4.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDf,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"moveToWaitingChildren-4.js","sourceRoot":"","sources":["../../../src/scripts/moveToWaitingChildren-4.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDf,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}