bullmq 5.8.7 → 5.9.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 (174) hide show
  1. package/dist/cjs/classes/queue.js +29 -0
  2. package/dist/cjs/classes/queue.js.map +1 -1
  3. package/dist/cjs/classes/scripts.js +17 -1
  4. package/dist/cjs/classes/scripts.js.map +1 -1
  5. package/dist/cjs/classes/worker.js +1 -1
  6. package/dist/cjs/classes/worker.js.map +1 -1
  7. package/dist/cjs/commands/{addPrioritizedJob-7.lua → addPrioritizedJob-8.lua} +9 -7
  8. package/dist/cjs/commands/{addStandardJob-7.lua → addStandardJob-8.lua} +6 -5
  9. package/dist/cjs/commands/{changePriority-6.lua → changePriority-7.lua} +12 -10
  10. package/dist/cjs/commands/getCountsPerPriority-4.lua +6 -3
  11. package/dist/cjs/commands/includes/addBaseMarkerIfNeeded.lua +2 -2
  12. package/dist/cjs/commands/includes/addJobInTargetList.lua +2 -2
  13. package/dist/cjs/commands/includes/addJobWithPriority.lua +3 -2
  14. package/dist/cjs/commands/includes/getTargetQueueList.lua +14 -4
  15. package/dist/cjs/commands/includes/isQueueMaxed.lua +15 -0
  16. package/dist/cjs/commands/includes/isQueuePaused.lua +1 -1
  17. package/dist/cjs/commands/includes/isQueuePausedOrMaxed.lua +18 -0
  18. package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +8 -6
  19. package/dist/cjs/commands/includes/removeParentDependencyKey.lua +3 -3
  20. package/dist/cjs/commands/isMaxed-2.lua +17 -0
  21. package/dist/cjs/commands/moveJobFromActiveToWait-10.lua +2 -2
  22. package/dist/{esm/commands/moveJobsToWait-7.lua → cjs/commands/moveJobsToWait-8.lua} +4 -3
  23. package/dist/cjs/commands/moveStalledJobsToWait-9.lua +3 -3
  24. package/dist/cjs/commands/moveToActive-11.lua +4 -4
  25. package/dist/cjs/commands/moveToFinished-14.lua +4 -4
  26. package/dist/cjs/commands/moveToWaitingChildren-5.lua +4 -3
  27. package/dist/{esm/commands/promote-8.lua → cjs/commands/promote-9.lua} +9 -7
  28. package/dist/{esm/commands/removeJob-1.lua → cjs/commands/removeJob-2.lua} +2 -1
  29. package/dist/{esm/commands/reprocessJob-7.lua → cjs/commands/reprocessJob-8.lua} +4 -3
  30. package/dist/cjs/commands/retryJob-11.lua +8 -4
  31. package/dist/cjs/scripts/addDelayedJob-6.js +39 -18
  32. package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
  33. package/dist/cjs/scripts/addParentJob-4.js +39 -18
  34. package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
  35. package/dist/cjs/scripts/{addPrioritizedJob-7.js → addPrioritizedJob-8.js} +49 -26
  36. package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -0
  37. package/dist/cjs/scripts/{addStandardJob-7.js → addStandardJob-8.js} +47 -25
  38. package/dist/cjs/scripts/addStandardJob-8.js.map +1 -0
  39. package/dist/cjs/scripts/{changePriority-6.js → changePriority-7.js} +33 -21
  40. package/dist/cjs/scripts/changePriority-7.js.map +1 -0
  41. package/dist/cjs/scripts/cleanJobsInSet-2.js +20 -11
  42. package/dist/cjs/scripts/cleanJobsInSet-2.js.map +1 -1
  43. package/dist/cjs/scripts/drain-4.js +20 -11
  44. package/dist/cjs/scripts/drain-4.js.map +1 -1
  45. package/dist/cjs/scripts/getCountsPerPriority-4.js +7 -8
  46. package/dist/cjs/scripts/getCountsPerPriority-4.js.map +1 -1
  47. package/dist/cjs/scripts/index.js +8 -7
  48. package/dist/cjs/scripts/index.js.map +1 -1
  49. package/dist/cjs/scripts/isMaxed-2.js +34 -0
  50. package/dist/cjs/scripts/isMaxed-2.js.map +1 -0
  51. package/dist/cjs/scripts/moveJobFromActiveToWait-10.js +19 -10
  52. package/dist/cjs/scripts/moveJobFromActiveToWait-10.js.map +1 -1
  53. package/dist/cjs/scripts/{moveJobsToWait-7.js → moveJobsToWait-8.js} +21 -11
  54. package/dist/cjs/scripts/moveJobsToWait-8.js.map +1 -0
  55. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +45 -24
  56. package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
  57. package/dist/cjs/scripts/moveToActive-11.js +24 -14
  58. package/dist/cjs/scripts/moveToActive-11.js.map +1 -1
  59. package/dist/cjs/scripts/moveToFinished-14.js +46 -25
  60. package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
  61. package/dist/cjs/scripts/moveToWaitingChildren-5.js +4 -3
  62. package/dist/cjs/scripts/moveToWaitingChildren-5.js.map +1 -1
  63. package/dist/cjs/scripts/obliterate-2.js +20 -11
  64. package/dist/cjs/scripts/obliterate-2.js.map +1 -1
  65. package/dist/cjs/scripts/{promote-8.js → promote-9.js} +31 -19
  66. package/dist/cjs/scripts/promote-9.js.map +1 -0
  67. package/dist/cjs/scripts/removeChildDependency-1.js +20 -11
  68. package/dist/cjs/scripts/removeChildDependency-1.js.map +1 -1
  69. package/dist/cjs/scripts/{removeJob-1.js → removeJob-2.js} +24 -14
  70. package/dist/cjs/scripts/{removeJob-1.js.map → removeJob-2.js.map} +1 -1
  71. package/dist/cjs/scripts/{reprocessJob-7.js → reprocessJob-8.js} +23 -13
  72. package/dist/cjs/scripts/reprocessJob-8.js.map +1 -0
  73. package/dist/cjs/scripts/retryJob-11.js +42 -14
  74. package/dist/cjs/scripts/retryJob-11.js.map +1 -1
  75. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  76. package/dist/esm/classes/queue.d.ts +17 -0
  77. package/dist/esm/classes/queue.js +29 -0
  78. package/dist/esm/classes/queue.js.map +1 -1
  79. package/dist/esm/classes/scripts.d.ts +2 -0
  80. package/dist/esm/classes/scripts.js +17 -1
  81. package/dist/esm/classes/scripts.js.map +1 -1
  82. package/dist/esm/classes/worker.js +1 -1
  83. package/dist/esm/classes/worker.js.map +1 -1
  84. package/dist/esm/commands/{addPrioritizedJob-7.lua → addPrioritizedJob-8.lua} +9 -7
  85. package/dist/esm/commands/{addStandardJob-7.lua → addStandardJob-8.lua} +6 -5
  86. package/dist/esm/commands/{changePriority-6.lua → changePriority-7.lua} +12 -10
  87. package/dist/esm/commands/getCountsPerPriority-4.lua +6 -3
  88. package/dist/esm/commands/includes/addBaseMarkerIfNeeded.lua +2 -2
  89. package/dist/esm/commands/includes/addJobInTargetList.lua +2 -2
  90. package/dist/esm/commands/includes/addJobWithPriority.lua +3 -2
  91. package/dist/esm/commands/includes/getTargetQueueList.lua +14 -4
  92. package/dist/esm/commands/includes/isQueueMaxed.lua +15 -0
  93. package/dist/esm/commands/includes/isQueuePaused.lua +1 -1
  94. package/dist/esm/commands/includes/isQueuePausedOrMaxed.lua +18 -0
  95. package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +8 -6
  96. package/dist/esm/commands/includes/removeParentDependencyKey.lua +3 -3
  97. package/dist/esm/commands/isMaxed-2.lua +17 -0
  98. package/dist/esm/commands/moveJobFromActiveToWait-10.lua +2 -2
  99. package/dist/{cjs/commands/moveJobsToWait-7.lua → esm/commands/moveJobsToWait-8.lua} +4 -3
  100. package/dist/esm/commands/moveStalledJobsToWait-9.lua +3 -3
  101. package/dist/esm/commands/moveToActive-11.lua +4 -4
  102. package/dist/esm/commands/moveToFinished-14.lua +4 -4
  103. package/dist/esm/commands/moveToWaitingChildren-5.lua +4 -3
  104. package/dist/{cjs/commands/promote-8.lua → esm/commands/promote-9.lua} +9 -7
  105. package/dist/{cjs/commands/removeJob-1.lua → esm/commands/removeJob-2.lua} +2 -1
  106. package/dist/{cjs/commands/reprocessJob-7.lua → esm/commands/reprocessJob-8.lua} +4 -3
  107. package/dist/esm/commands/retryJob-11.lua +8 -4
  108. package/dist/esm/scripts/addDelayedJob-6.js +39 -18
  109. package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
  110. package/dist/esm/scripts/addParentJob-4.js +39 -18
  111. package/dist/esm/scripts/addParentJob-4.js.map +1 -1
  112. package/dist/esm/scripts/{addPrioritizedJob-7.js → addPrioritizedJob-8.js} +49 -26
  113. package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -0
  114. package/dist/esm/scripts/{addStandardJob-7.js → addStandardJob-8.js} +47 -25
  115. package/dist/esm/scripts/addStandardJob-8.js.map +1 -0
  116. package/dist/esm/scripts/{changePriority-6.js → changePriority-7.js} +33 -21
  117. package/dist/esm/scripts/changePriority-7.js.map +1 -0
  118. package/dist/esm/scripts/cleanJobsInSet-2.js +20 -11
  119. package/dist/esm/scripts/cleanJobsInSet-2.js.map +1 -1
  120. package/dist/esm/scripts/drain-4.js +20 -11
  121. package/dist/esm/scripts/drain-4.js.map +1 -1
  122. package/dist/esm/scripts/getCountsPerPriority-4.js +7 -8
  123. package/dist/esm/scripts/getCountsPerPriority-4.js.map +1 -1
  124. package/dist/esm/scripts/index.d.ts +8 -7
  125. package/dist/esm/scripts/index.js +8 -7
  126. package/dist/esm/scripts/index.js.map +1 -1
  127. package/dist/esm/scripts/isMaxed-2.d.ts +5 -0
  128. package/dist/esm/scripts/isMaxed-2.js +31 -0
  129. package/dist/esm/scripts/isMaxed-2.js.map +1 -0
  130. package/dist/esm/scripts/moveJobFromActiveToWait-10.js +19 -10
  131. package/dist/esm/scripts/moveJobFromActiveToWait-10.js.map +1 -1
  132. package/dist/esm/scripts/{moveJobsToWait-7.js → moveJobsToWait-8.js} +21 -11
  133. package/dist/esm/scripts/moveJobsToWait-8.js.map +1 -0
  134. package/dist/esm/scripts/moveStalledJobsToWait-9.js +45 -24
  135. package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
  136. package/dist/esm/scripts/moveToActive-11.js +24 -14
  137. package/dist/esm/scripts/moveToActive-11.js.map +1 -1
  138. package/dist/esm/scripts/moveToFinished-14.js +46 -25
  139. package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
  140. package/dist/esm/scripts/moveToWaitingChildren-5.js +4 -3
  141. package/dist/esm/scripts/moveToWaitingChildren-5.js.map +1 -1
  142. package/dist/esm/scripts/obliterate-2.js +20 -11
  143. package/dist/esm/scripts/obliterate-2.js.map +1 -1
  144. package/dist/esm/scripts/{promote-8.js → promote-9.js} +31 -19
  145. package/dist/esm/scripts/promote-9.js.map +1 -0
  146. package/dist/esm/scripts/removeChildDependency-1.js +20 -11
  147. package/dist/esm/scripts/removeChildDependency-1.js.map +1 -1
  148. package/dist/esm/scripts/{removeJob-1.js → removeJob-2.js} +24 -14
  149. package/dist/esm/scripts/{removeJob-1.js.map → removeJob-2.js.map} +1 -1
  150. package/dist/esm/scripts/{reprocessJob-7.js → reprocessJob-8.js} +23 -13
  151. package/dist/esm/scripts/reprocessJob-8.js.map +1 -0
  152. package/dist/esm/scripts/retryJob-11.js +42 -14
  153. package/dist/esm/scripts/retryJob-11.js.map +1 -1
  154. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  155. package/package.json +2 -1
  156. package/dist/cjs/scripts/addPrioritizedJob-7.js.map +0 -1
  157. package/dist/cjs/scripts/addStandardJob-7.js.map +0 -1
  158. package/dist/cjs/scripts/changePriority-6.js.map +0 -1
  159. package/dist/cjs/scripts/moveJobsToWait-7.js.map +0 -1
  160. package/dist/cjs/scripts/promote-8.js.map +0 -1
  161. package/dist/cjs/scripts/reprocessJob-7.js.map +0 -1
  162. package/dist/esm/scripts/addPrioritizedJob-7.js.map +0 -1
  163. package/dist/esm/scripts/addStandardJob-7.js.map +0 -1
  164. package/dist/esm/scripts/changePriority-6.js.map +0 -1
  165. package/dist/esm/scripts/moveJobsToWait-7.js.map +0 -1
  166. package/dist/esm/scripts/promote-8.js.map +0 -1
  167. package/dist/esm/scripts/reprocessJob-7.js.map +0 -1
  168. /package/dist/esm/scripts/{addPrioritizedJob-7.d.ts → addPrioritizedJob-8.d.ts} +0 -0
  169. /package/dist/esm/scripts/{addStandardJob-7.d.ts → addStandardJob-8.d.ts} +0 -0
  170. /package/dist/esm/scripts/{changePriority-6.d.ts → changePriority-7.d.ts} +0 -0
  171. /package/dist/esm/scripts/{moveJobsToWait-7.d.ts → moveJobsToWait-8.d.ts} +0 -0
  172. /package/dist/esm/scripts/{promote-8.d.ts → promote-9.d.ts} +0 -0
  173. /package/dist/esm/scripts/{removeJob-1.d.ts → removeJob-2.d.ts} +0 -0
  174. /package/dist/esm/scripts/{reprocessJob-7.d.ts → reprocessJob-8.d.ts} +0 -0
@@ -12,8 +12,9 @@ const content = `--[[
12
12
  KEYS[3] 'id'
13
13
  KEYS[4] 'prioritized'
14
14
  KEYS[5] 'completed'
15
- KEYS[6] events stream key
16
- KEYS[7] 'pc' priority counter
15
+ KEYS[6] 'active'
16
+ KEYS[7] events stream key
17
+ KEYS[8] 'pc' priority counter
17
18
  ARGV[1] msgpacked arguments array
18
19
  [1] key prefix,
19
20
  [2] custom id (will not generate one automatically)
@@ -34,8 +35,9 @@ local metaKey = KEYS[2]
34
35
  local idKey = KEYS[3]
35
36
  local priorityKey = KEYS[4]
36
37
  local completedKey = KEYS[5]
37
- local eventsKey = KEYS[6]
38
- local priorityCounterKey = KEYS[7]
38
+ local activeKey = KEYS[6]
39
+ local eventsKey = KEYS[7]
40
+ local priorityCounterKey = KEYS[8]
39
41
  local jobId
40
42
  local jobIdKey
41
43
  local rcall = redis.call
@@ -54,16 +56,17 @@ local parentData
54
56
  --[[
55
57
  Add marker if needed when a job is available.
56
58
  ]]
57
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
58
- if not isPaused then
59
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
60
+ if not isPausedOrMaxed then
59
61
  rcall("ZADD", markerKey, 0, "0")
60
62
  end
61
63
  end
62
- local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
64
+ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
65
+ isPausedOrMaxed)
63
66
  local prioCounter = rcall("INCR", priorityCounterKey)
64
67
  local score = priority * 0x100000000 + prioCounter % 0x100000000
65
68
  rcall("ZADD", prioritizedKey, score, jobId)
66
- addBaseMarkerIfNeeded(markerKey, isPaused)
69
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
67
70
  end
68
71
  --[[
69
72
  Function to store a job
@@ -148,27 +151,45 @@ end
148
151
  Function to add job in target list and add marker if needed.
149
152
  ]]
150
153
  -- Includes
151
- local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
154
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
152
155
  rcall(pushCmd, targetKey, jobId)
153
- addBaseMarkerIfNeeded(markerKey, isPaused)
156
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
154
157
  end
155
158
  --[[
156
- Function to check for the meta.paused key to decide if we are paused or not
159
+ Function to check if queue is paused or maxed
157
160
  (since an empty list and !EXISTS are not really the same).
158
161
  ]]
159
- local function isQueuePaused(queueMetaKey)
160
- return rcall("HEXISTS", queueMetaKey, "paused") == 1
162
+ local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
163
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
164
+ if queueAttributes[1] then
165
+ return true
166
+ else
167
+ if queueAttributes[2] then
168
+ local activeCount = rcall("LLEN", activeKey)
169
+ return activeCount >= tonumber(queueAttributes[2])
170
+ end
171
+ end
172
+ return false
161
173
  end
162
174
  --[[
163
175
  Function to check for the meta.paused key to decide if we are paused or not
164
176
  (since an empty list and !EXISTS are not really the same).
165
177
  ]]
166
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
167
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
168
- return waitKey, false
169
- else
178
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
179
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
180
+ if queueAttributes[1] then
170
181
  return pausedKey, true
182
+ else
183
+ if queueAttributes[2] then
184
+ local activeCount = rcall("LLEN", activeKey)
185
+ if activeCount >= tonumber(queueAttributes[2]) then
186
+ return waitKey, true
187
+ else
188
+ return waitKey, false
189
+ end
190
+ end
171
191
  end
192
+ return waitKey, false
172
193
  end
173
194
  local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
174
195
  parentKey, parentId, timestamp)
@@ -178,6 +199,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
178
199
  rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
179
200
  local parentWaitKey = parentQueueKey .. ":wait"
180
201
  local parentPausedKey = parentQueueKey .. ":paused"
202
+ local parentActiveKey = parentQueueKey .. ":active"
181
203
  local parentMetaKey = parentQueueKey .. ":meta"
182
204
  local parentMarkerKey = parentQueueKey .. ":marker"
183
205
  local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
@@ -193,15 +215,16 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
193
215
  addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
194
216
  else
195
217
  if priority == 0 then
196
- local parentTarget, isParentPaused =
197
- getTargetQueueList(parentMetaKey, parentWaitKey,
218
+ local parentTarget, isParentPausedOrMaxed =
219
+ getTargetQueueList(parentMetaKey, parentActiveKey, parentWaitKey,
198
220
  parentPausedKey)
199
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPaused, parentId)
221
+ addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
222
+ parentId)
200
223
  else
201
- local isPaused = isQueuePaused(parentMetaKey)
224
+ local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
202
225
  addJobWithPriority(parentMarkerKey,
203
226
  parentQueueKey .. ":prioritized", priority,
204
- parentId, parentQueueKey .. ":pc", isPaused)
227
+ parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
205
228
  end
206
229
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
207
230
  "jobId", parentId, "prev", "waiting-children")
@@ -273,8 +296,8 @@ local delay, priority = storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2],
273
296
  opts, timestamp, parentKey, parentData,
274
297
  repeatJobKey)
275
298
  -- Add the job to the prioritized set
276
- local isPause = isQueuePaused(metaKey)
277
- addJobWithPriority( KEYS[1], priorityKey, priority, jobId, priorityCounterKey, isPause)
299
+ local isPausedOrMaxed = isQueuePausedOrMaxed(metaKey, activeKey)
300
+ addJobWithPriority( KEYS[1], priorityKey, priority, jobId, priorityCounterKey, isPausedOrMaxed)
278
301
  -- Emit waiting event
279
302
  rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",
280
303
  "jobId", jobId)
@@ -287,6 +310,6 @@ return jobId .. "" -- convert to string
287
310
  exports.addPrioritizedJob = {
288
311
  name: 'addPrioritizedJob',
289
312
  content,
290
- keys: 7,
313
+ keys: 8,
291
314
  };
292
- //# sourceMappingURL=addPrioritizedJob-7.js.map
315
+ //# sourceMappingURL=addPrioritizedJob-8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addPrioritizedJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiTf,CAAC;AACW,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,mBAAmB;IACzB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -21,8 +21,9 @@ const content = `--[[
21
21
  KEYS[3] 'meta'
22
22
  KEYS[4] 'id'
23
23
  KEYS[5] 'completed'
24
- KEYS[6] events stream key
25
- KEYS[7] marker key
24
+ KEYS[6] 'active'
25
+ KEYS[7] events stream key
26
+ KEYS[8] marker key
26
27
  ARGV[1] msgpacked arguments array
27
28
  [1] key prefix,
28
29
  [2] custom id (will not generate one automatically)
@@ -39,7 +40,7 @@ const content = `--[[
39
40
  jobId - OK
40
41
  -5 - Missing parent key
41
42
  ]]
42
- local eventsKey = KEYS[6]
43
+ local eventsKey = KEYS[7]
43
44
  local jobId
44
45
  local jobIdKey
45
46
  local rcall = redis.call
@@ -58,14 +59,14 @@ local parentData
58
59
  --[[
59
60
  Add marker if needed when a job is available.
60
61
  ]]
61
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
62
- if not isPaused then
62
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
63
+ if not isPausedOrMaxed then
63
64
  rcall("ZADD", markerKey, 0, "0")
64
65
  end
65
66
  end
66
- local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
67
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
67
68
  rcall(pushCmd, targetKey, jobId)
68
- addBaseMarkerIfNeeded(markerKey, isPaused)
69
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
69
70
  end
70
71
  --[[
71
72
  Function to get max events value or set by default 10000.
@@ -82,12 +83,21 @@ end
82
83
  Function to check for the meta.paused key to decide if we are paused or not
83
84
  (since an empty list and !EXISTS are not really the same).
84
85
  ]]
85
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
86
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
87
- return waitKey, false
88
- else
86
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
87
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
88
+ if queueAttributes[1] then
89
89
  return pausedKey, true
90
+ else
91
+ if queueAttributes[2] then
92
+ local activeCount = rcall("LLEN", activeKey)
93
+ if activeCount >= tonumber(queueAttributes[2]) then
94
+ return waitKey, true
95
+ else
96
+ return waitKey, false
97
+ end
98
+ end
90
99
  end
100
+ return waitKey, false
91
101
  end
92
102
  --[[
93
103
  Function to handle the case when job is duplicated.
@@ -136,18 +146,28 @@ end
136
146
  Function to add job considering priority.
137
147
  ]]
138
148
  -- Includes
139
- local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
149
+ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
150
+ isPausedOrMaxed)
140
151
  local prioCounter = rcall("INCR", priorityCounterKey)
141
152
  local score = priority * 0x100000000 + prioCounter % 0x100000000
142
153
  rcall("ZADD", prioritizedKey, score, jobId)
143
- addBaseMarkerIfNeeded(markerKey, isPaused)
154
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
144
155
  end
145
156
  --[[
146
- Function to check for the meta.paused key to decide if we are paused or not
157
+ Function to check if queue is paused or maxed
147
158
  (since an empty list and !EXISTS are not really the same).
148
159
  ]]
149
- local function isQueuePaused(queueMetaKey)
150
- return rcall("HEXISTS", queueMetaKey, "paused") == 1
160
+ local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
161
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
162
+ if queueAttributes[1] then
163
+ return true
164
+ else
165
+ if queueAttributes[2] then
166
+ local activeCount = rcall("LLEN", activeKey)
167
+ return activeCount >= tonumber(queueAttributes[2])
168
+ end
169
+ end
170
+ return false
151
171
  end
152
172
  local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
153
173
  parentKey, parentId, timestamp)
@@ -157,6 +177,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
157
177
  rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
158
178
  local parentWaitKey = parentQueueKey .. ":wait"
159
179
  local parentPausedKey = parentQueueKey .. ":paused"
180
+ local parentActiveKey = parentQueueKey .. ":active"
160
181
  local parentMetaKey = parentQueueKey .. ":meta"
161
182
  local parentMarkerKey = parentQueueKey .. ":marker"
162
183
  local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
@@ -172,15 +193,16 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
172
193
  addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
173
194
  else
174
195
  if priority == 0 then
175
- local parentTarget, isParentPaused =
176
- getTargetQueueList(parentMetaKey, parentWaitKey,
196
+ local parentTarget, isParentPausedOrMaxed =
197
+ getTargetQueueList(parentMetaKey, parentActiveKey, parentWaitKey,
177
198
  parentPausedKey)
178
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPaused, parentId)
199
+ addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
200
+ parentId)
179
201
  else
180
- local isPaused = isQueuePaused(parentMetaKey)
202
+ local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
181
203
  addJobWithPriority(parentMarkerKey,
182
204
  parentQueueKey .. ":prioritized", priority,
183
- parentId, parentQueueKey .. ":pc", isPaused)
205
+ parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
184
206
  end
185
207
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
186
208
  "jobId", parentId, "prev", "waiting-children")
@@ -276,10 +298,10 @@ end
276
298
  -- Store the job.
277
299
  storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2], opts, timestamp,
278
300
  parentKey, parentData, repeatJobKey)
279
- local target, paused = getTargetQueueList(metaKey, KEYS[1], KEYS[2])
301
+ local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[6], KEYS[1], KEYS[2])
280
302
  -- LIFO or FIFO
281
303
  local pushCmd = opts['lifo'] and 'RPUSH' or 'LPUSH'
282
- addJobInTargetList(target, KEYS[7], pushCmd, paused, jobId)
304
+ addJobInTargetList(target, KEYS[8], pushCmd, isPausedOrMaxed, jobId)
283
305
  -- Emit waiting event
284
306
  rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",
285
307
  "jobId", jobId)
@@ -292,6 +314,6 @@ return jobId .. "" -- convert to string
292
314
  exports.addStandardJob = {
293
315
  name: 'addStandardJob',
294
316
  content,
295
- keys: 7,
317
+ keys: 8,
296
318
  };
297
- //# sourceMappingURL=addStandardJob-7.js.map
319
+ //# sourceMappingURL=addStandardJob-8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addStandardJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqTf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -8,8 +8,9 @@ const content = `--[[
8
8
  KEYS[2] 'paused'
9
9
  KEYS[3] 'meta'
10
10
  KEYS[4] 'prioritized'
11
- KEYS[5] 'pc' priority counter
12
- KEYS[6] 'marker'
11
+ KEYS[5] 'active'
12
+ KEYS[6] 'pc' priority counter
13
+ KEYS[7] 'marker'
13
14
  ARGV[1] priority value
14
15
  ARGV[2] job key
15
16
  ARGV[3] job id
@@ -30,35 +31,45 @@ local rcall = redis.call
30
31
  --[[
31
32
  Add marker if needed when a job is available.
32
33
  ]]
33
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
34
- if not isPaused then
34
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
35
+ if not isPausedOrMaxed then
35
36
  rcall("ZADD", markerKey, 0, "0")
36
37
  end
37
38
  end
38
- local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
39
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
39
40
  rcall(pushCmd, targetKey, jobId)
40
- addBaseMarkerIfNeeded(markerKey, isPaused)
41
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
41
42
  end
42
43
  --[[
43
44
  Function to add job considering priority.
44
45
  ]]
45
46
  -- Includes
46
- local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
47
+ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
48
+ isPausedOrMaxed)
47
49
  local prioCounter = rcall("INCR", priorityCounterKey)
48
50
  local score = priority * 0x100000000 + prioCounter % 0x100000000
49
51
  rcall("ZADD", prioritizedKey, score, jobId)
50
- addBaseMarkerIfNeeded(markerKey, isPaused)
52
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
51
53
  end
52
54
  --[[
53
55
  Function to check for the meta.paused key to decide if we are paused or not
54
56
  (since an empty list and !EXISTS are not really the same).
55
57
  ]]
56
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
57
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
58
- return waitKey, false
59
- else
58
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
59
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
60
+ if queueAttributes[1] then
60
61
  return pausedKey, true
62
+ else
63
+ if queueAttributes[2] then
64
+ local activeCount = rcall("LLEN", activeKey)
65
+ if activeCount >= tonumber(queueAttributes[2]) then
66
+ return waitKey, true
67
+ else
68
+ return waitKey, false
69
+ end
70
+ end
61
71
  end
72
+ return waitKey, false
62
73
  end
63
74
  --[[
64
75
  Function to push back job considering priority in front of same prioritized jobs.
@@ -70,31 +81,32 @@ local function pushBackJobWithPriority(prioritizedKey, priority, jobId)
70
81
  rcall("ZADD", prioritizedKey, score, jobId)
71
82
  end
72
83
  local function reAddJobWithNewPriority( prioritizedKey, markerKey, targetKey,
73
- priorityCounter, lifo, priority, jobId, paused)
84
+ priorityCounter, lifo, priority, jobId, isPausedOrMaxed)
74
85
  if priority == 0 then
75
86
  local pushCmd = lifo and 'RPUSH' or 'LPUSH'
76
- addJobInTargetList(targetKey, markerKey, pushCmd, paused, jobId)
87
+ addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
77
88
  else
78
89
  if lifo then
79
90
  pushBackJobWithPriority(prioritizedKey, priority, jobId)
80
91
  else
81
92
  addJobWithPriority(markerKey, prioritizedKey, priority, jobId,
82
- priorityCounter, paused)
93
+ priorityCounter, isPausedOrMaxed)
83
94
  end
84
95
  end
85
96
  end
86
97
  if rcall("EXISTS", jobKey) == 1 then
87
98
  local metaKey = KEYS[3]
88
- local target, isPaused = getTargetQueueList(metaKey, KEYS[1], KEYS[2])
89
- local markerKey = KEYS[6]
99
+ local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[5], KEYS[1], KEYS[2])
90
100
  local prioritizedKey = KEYS[4]
101
+ local priorityCounterKey = KEYS[6]
102
+ local markerKey = KEYS[7]
91
103
  -- Re-add with the new priority
92
104
  if rcall("ZREM", KEYS[4], jobId) > 0 then
93
105
  reAddJobWithNewPriority( prioritizedKey, markerKey, target,
94
- KEYS[5], ARGV[4] == '1', priority, jobId, isPaused)
106
+ priorityCounterKey, ARGV[4] == '1', priority, jobId, isPausedOrMaxed)
95
107
  elseif rcall("LREM", target, -1, jobId) > 0 then
96
108
  reAddJobWithNewPriority( prioritizedKey, markerKey, target,
97
- KEYS[5], ARGV[4] == '1', priority, jobId, isPaused)
109
+ priorityCounterKey, ARGV[4] == '1', priority, jobId, isPausedOrMaxed)
98
110
  end
99
111
  rcall("HSET", jobKey, "priority", priority)
100
112
  return 0
@@ -105,6 +117,6 @@ end
105
117
  exports.changePriority = {
106
118
  name: 'changePriority',
107
119
  content,
108
- keys: 6,
120
+ keys: 7,
109
121
  };
110
- //# sourceMappingURL=changePriority-6.js.map
122
+ //# sourceMappingURL=changePriority-7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changePriority-7.js","sourceRoot":"","sources":["../../../src/scripts/changePriority-7.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgHf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -70,14 +70,14 @@ end
70
70
  --[[
71
71
  Add marker if needed when a job is available.
72
72
  ]]
73
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
74
- if not isPaused then
73
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
74
+ if not isPausedOrMaxed then
75
75
  rcall("ZADD", markerKey, 0, "0")
76
76
  end
77
77
  end
78
- local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
78
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
79
79
  rcall(pushCmd, targetKey, jobId)
80
- addBaseMarkerIfNeeded(markerKey, isPaused)
80
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
81
81
  end
82
82
  --[[
83
83
  Functions to destructure job key.
@@ -93,17 +93,26 @@ end
93
93
  Function to check for the meta.paused key to decide if we are paused or not
94
94
  (since an empty list and !EXISTS are not really the same).
95
95
  ]]
96
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
97
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
98
- return waitKey, false
99
- else
96
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
97
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
98
+ if queueAttributes[1] then
100
99
  return pausedKey, true
100
+ else
101
+ if queueAttributes[2] then
102
+ local activeCount = rcall("LLEN", activeKey)
103
+ if activeCount >= tonumber(queueAttributes[2]) then
104
+ return waitKey, true
105
+ else
106
+ return waitKey, false
107
+ end
108
+ end
101
109
  end
110
+ return waitKey, false
102
111
  end
103
112
  local function moveParentToWait(parentPrefix, parentId, emitEvent)
104
- local parentTarget, isPaused = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
105
- parentPrefix .. "paused")
106
- addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPaused, parentId)
113
+ local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
114
+ parentPrefix .. "wait", parentPrefix .. "paused")
115
+ addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
107
116
  if emitEvent then
108
117
  local parentEventStream = parentPrefix .. "events"
109
118
  rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
@@ -1 +1 @@
1
- {"version":3,"file":"cleanJobsInSet-2.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiSf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"cleanJobsInSet-2.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Sf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -45,14 +45,14 @@ end
45
45
  --[[
46
46
  Add marker if needed when a job is available.
47
47
  ]]
48
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
49
- if not isPaused then
48
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
49
+ if not isPausedOrMaxed then
50
50
  rcall("ZADD", markerKey, 0, "0")
51
51
  end
52
52
  end
53
- local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
53
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
54
54
  rcall(pushCmd, targetKey, jobId)
55
- addBaseMarkerIfNeeded(markerKey, isPaused)
55
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
56
56
  end
57
57
  --[[
58
58
  Functions to destructure job key.
@@ -68,17 +68,26 @@ end
68
68
  Function to check for the meta.paused key to decide if we are paused or not
69
69
  (since an empty list and !EXISTS are not really the same).
70
70
  ]]
71
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
72
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
73
- return waitKey, false
74
- else
71
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
72
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
73
+ if queueAttributes[1] then
75
74
  return pausedKey, true
75
+ else
76
+ if queueAttributes[2] then
77
+ local activeCount = rcall("LLEN", activeKey)
78
+ if activeCount >= tonumber(queueAttributes[2]) then
79
+ return waitKey, true
80
+ else
81
+ return waitKey, false
82
+ end
83
+ end
76
84
  end
85
+ return waitKey, false
77
86
  end
78
87
  local function moveParentToWait(parentPrefix, parentId, emitEvent)
79
- local parentTarget, isPaused = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
80
- parentPrefix .. "paused")
81
- addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPaused, parentId)
88
+ local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
89
+ parentPrefix .. "wait", parentPrefix .. "paused")
90
+ addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
82
91
  if emitEvent then
83
92
  local parentEventStream = parentPrefix .. "events"
84
93
  rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
@@ -1 +1 @@
1
- {"version":3,"file":"drain-4.js","sourceRoot":"","sources":["../../../src/scripts/drain-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsMf,CAAC;AACW,QAAA,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"drain-4.js","sourceRoot":"","sources":["../../../src/scripts/drain-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Mf,CAAC;AACW,QAAA,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -20,18 +20,17 @@ local prioritizedKey = KEYS[4]
20
20
  Function to check for the meta.paused key to decide if we are paused or not
21
21
  (since an empty list and !EXISTS are not really the same).
22
22
  ]]
23
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
24
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
25
- return waitKey, false
26
- else
27
- return pausedKey, true
28
- end
23
+ local function isQueuePaused(queueMetaKey)
24
+ return rcall("HEXISTS", queueMetaKey, "paused") == 1
29
25
  end
30
26
  for i = 1, #ARGV do
31
27
  local priority = tonumber(ARGV[i])
32
28
  if priority == 0 then
33
- local target = getTargetQueueList(KEYS[3], waitKey, pausedKey)
34
- results[#results+1] = rcall("LLEN", target)
29
+ if isQueuePaused(KEYS[3]) then
30
+ results[#results+1] = rcall("LLEN", pausedKey)
31
+ else
32
+ results[#results+1] = rcall("LLEN", waitKey)
33
+ end
35
34
  else
36
35
  results[#results+1] = rcall("ZCOUNT", prioritizedKey,
37
36
  priority * 0x100000000, (priority + 1) * 0x100000000 - 1)
@@ -1 +1 @@
1
- {"version":3,"file":"getCountsPerPriority-4.js","sourceRoot":"","sources":["../../../src/scripts/getCountsPerPriority-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCf,CAAC;AACW,QAAA,oBAAoB,GAAG;IAClC,IAAI,EAAE,sBAAsB;IAC5B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"getCountsPerPriority-4.js","sourceRoot":"","sources":["../../../src/scripts/getCountsPerPriority-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCf,CAAC;AACW,QAAA,oBAAoB,GAAG;IAClC,IAAI,EAAE,sBAAsB;IAC5B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -4,10 +4,10 @@ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./addDelayedJob-6"), exports);
5
5
  tslib_1.__exportStar(require("./addLog-2"), exports);
6
6
  tslib_1.__exportStar(require("./addParentJob-4"), exports);
7
- tslib_1.__exportStar(require("./addPrioritizedJob-7"), exports);
8
- tslib_1.__exportStar(require("./addStandardJob-7"), exports);
7
+ tslib_1.__exportStar(require("./addPrioritizedJob-8"), exports);
8
+ tslib_1.__exportStar(require("./addStandardJob-8"), exports);
9
9
  tslib_1.__exportStar(require("./changeDelay-4"), exports);
10
- tslib_1.__exportStar(require("./changePriority-6"), exports);
10
+ tslib_1.__exportStar(require("./changePriority-7"), exports);
11
11
  tslib_1.__exportStar(require("./cleanJobsInSet-2"), exports);
12
12
  tslib_1.__exportStar(require("./drain-4"), exports);
13
13
  tslib_1.__exportStar(require("./extendLock-2"), exports);
@@ -19,8 +19,9 @@ tslib_1.__exportStar(require("./getState-8"), exports);
19
19
  tslib_1.__exportStar(require("./getStateV2-8"), exports);
20
20
  tslib_1.__exportStar(require("./isFinished-3"), exports);
21
21
  tslib_1.__exportStar(require("./isJobInList-1"), exports);
22
+ tslib_1.__exportStar(require("./isMaxed-2"), exports);
22
23
  tslib_1.__exportStar(require("./moveJobFromActiveToWait-10"), exports);
23
- tslib_1.__exportStar(require("./moveJobsToWait-7"), exports);
24
+ tslib_1.__exportStar(require("./moveJobsToWait-8"), exports);
24
25
  tslib_1.__exportStar(require("./moveStalledJobsToWait-9"), exports);
25
26
  tslib_1.__exportStar(require("./moveToActive-11"), exports);
26
27
  tslib_1.__exportStar(require("./moveToDelayed-8"), exports);
@@ -29,12 +30,12 @@ tslib_1.__exportStar(require("./moveToWaitingChildren-5"), exports);
29
30
  tslib_1.__exportStar(require("./obliterate-2"), exports);
30
31
  tslib_1.__exportStar(require("./paginate-1"), exports);
31
32
  tslib_1.__exportStar(require("./pause-7"), exports);
32
- tslib_1.__exportStar(require("./promote-8"), exports);
33
+ tslib_1.__exportStar(require("./promote-9"), exports);
33
34
  tslib_1.__exportStar(require("./releaseLock-1"), exports);
34
35
  tslib_1.__exportStar(require("./removeChildDependency-1"), exports);
35
- tslib_1.__exportStar(require("./removeJob-1"), exports);
36
+ tslib_1.__exportStar(require("./removeJob-2"), exports);
36
37
  tslib_1.__exportStar(require("./removeRepeatable-2"), exports);
37
- tslib_1.__exportStar(require("./reprocessJob-7"), exports);
38
+ tslib_1.__exportStar(require("./reprocessJob-8"), exports);
38
39
  tslib_1.__exportStar(require("./retryJob-11"), exports);
39
40
  tslib_1.__exportStar(require("./saveStacktrace-1"), exports);
40
41
  tslib_1.__exportStar(require("./updateData-1"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,qDAA2B;AAC3B,2DAAiC;AACjC,gEAAsC;AACtC,6DAAmC;AACnC,0DAAgC;AAChC,6DAAmC;AACnC,6DAAmC;AACnC,oDAA0B;AAC1B,yDAA+B;AAC/B,wDAA8B;AAC9B,mEAAyC;AACzC,wDAA8B;AAC9B,8DAAoC;AACpC,uDAA6B;AAC7B,yDAA+B;AAC/B,yDAA+B;AAC/B,0DAAgC;AAChC,uEAA6C;AAC7C,6DAAmC;AACnC,oEAA0C;AAC1C,4DAAkC;AAClC,4DAAkC;AAClC,8DAAoC;AACpC,oEAA0C;AAC1C,yDAA+B;AAC/B,uDAA6B;AAC7B,oDAA0B;AAC1B,sDAA4B;AAC5B,0DAAgC;AAChC,oEAA0C;AAC1C,wDAA8B;AAC9B,+DAAqC;AACrC,2DAAiC;AACjC,wDAA8B;AAC9B,6DAAmC;AACnC,yDAA+B;AAC/B,6DAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,qDAA2B;AAC3B,2DAAiC;AACjC,gEAAsC;AACtC,6DAAmC;AACnC,0DAAgC;AAChC,6DAAmC;AACnC,6DAAmC;AACnC,oDAA0B;AAC1B,yDAA+B;AAC/B,wDAA8B;AAC9B,mEAAyC;AACzC,wDAA8B;AAC9B,8DAAoC;AACpC,uDAA6B;AAC7B,yDAA+B;AAC/B,yDAA+B;AAC/B,0DAAgC;AAChC,sDAA4B;AAC5B,uEAA6C;AAC7C,6DAAmC;AACnC,oEAA0C;AAC1C,4DAAkC;AAClC,4DAAkC;AAClC,8DAAoC;AACpC,oEAA0C;AAC1C,yDAA+B;AAC/B,uDAA6B;AAC7B,oDAA0B;AAC1B,sDAA4B;AAC5B,0DAAgC;AAChC,oEAA0C;AAC1C,wDAA8B;AAC9B,+DAAqC;AACrC,2DAAiC;AACjC,wDAA8B;AAC9B,6DAAmC;AACnC,yDAA+B;AAC/B,6DAAmC"}