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