bullmq 5.8.7 → 5.10.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 (205) 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/repeat.js +44 -30
  4. package/dist/cjs/classes/repeat.js.map +1 -1
  5. package/dist/cjs/classes/scripts.js +44 -5
  6. package/dist/cjs/classes/scripts.js.map +1 -1
  7. package/dist/cjs/classes/worker.js +1 -1
  8. package/dist/cjs/classes/worker.js.map +1 -1
  9. package/dist/cjs/commands/{addPrioritizedJob-7.lua → addPrioritizedJob-8.lua} +9 -7
  10. package/dist/cjs/commands/addRepeatableJob-2.lua +69 -0
  11. package/dist/cjs/commands/{addStandardJob-7.lua → addStandardJob-8.lua} +6 -5
  12. package/dist/cjs/commands/{changePriority-6.lua → changePriority-7.lua} +12 -10
  13. package/dist/cjs/commands/getCountsPerPriority-4.lua +6 -3
  14. package/dist/cjs/commands/includes/addBaseMarkerIfNeeded.lua +2 -2
  15. package/dist/cjs/commands/includes/addJobInTargetList.lua +2 -2
  16. package/dist/cjs/commands/includes/addJobWithPriority.lua +3 -2
  17. package/dist/cjs/commands/includes/getTargetQueueList.lua +14 -4
  18. package/dist/cjs/commands/includes/isQueueMaxed.lua +15 -0
  19. package/dist/cjs/commands/includes/isQueuePaused.lua +1 -1
  20. package/dist/cjs/commands/includes/isQueuePausedOrMaxed.lua +18 -0
  21. package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +8 -6
  22. package/dist/cjs/commands/includes/removeParentDependencyKey.lua +3 -3
  23. package/dist/cjs/commands/isMaxed-2.lua +17 -0
  24. package/dist/cjs/commands/moveJobFromActiveToWait-10.lua +2 -2
  25. package/dist/{esm/commands/moveJobsToWait-7.lua → cjs/commands/moveJobsToWait-8.lua} +4 -3
  26. package/dist/cjs/commands/moveStalledJobsToWait-9.lua +3 -3
  27. package/dist/cjs/commands/moveToActive-11.lua +4 -4
  28. package/dist/cjs/commands/moveToFinished-14.lua +4 -4
  29. package/dist/cjs/commands/moveToWaitingChildren-5.lua +4 -3
  30. package/dist/cjs/commands/obliterate-2.lua +23 -8
  31. package/dist/{esm/commands/promote-8.lua → cjs/commands/promote-9.lua} +9 -7
  32. package/dist/{esm/commands/removeJob-1.lua → cjs/commands/removeJob-2.lua} +2 -1
  33. package/dist/cjs/commands/removeRepeatable-2.lua +27 -6
  34. package/dist/{esm/commands/reprocessJob-7.lua → cjs/commands/reprocessJob-8.lua} +4 -3
  35. package/dist/cjs/commands/retryJob-11.lua +8 -4
  36. package/dist/cjs/interfaces/index.js +1 -0
  37. package/dist/cjs/interfaces/index.js.map +1 -1
  38. package/dist/cjs/interfaces/repeatable-options.js +3 -0
  39. package/dist/cjs/interfaces/repeatable-options.js.map +1 -0
  40. package/dist/cjs/scripts/addDelayedJob-6.js +39 -18
  41. package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
  42. package/dist/cjs/scripts/addParentJob-4.js +39 -18
  43. package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
  44. package/dist/cjs/scripts/{addPrioritizedJob-7.js → addPrioritizedJob-8.js} +49 -26
  45. package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -0
  46. package/dist/cjs/scripts/addRepeatableJob-2.js +66 -0
  47. package/dist/cjs/scripts/addRepeatableJob-2.js.map +1 -0
  48. package/dist/cjs/scripts/{addStandardJob-7.js → addStandardJob-8.js} +47 -25
  49. package/dist/cjs/scripts/addStandardJob-8.js.map +1 -0
  50. package/dist/cjs/scripts/{changePriority-6.js → changePriority-7.js} +33 -21
  51. package/dist/cjs/scripts/changePriority-7.js.map +1 -0
  52. package/dist/cjs/scripts/cleanJobsInSet-2.js +20 -11
  53. package/dist/cjs/scripts/cleanJobsInSet-2.js.map +1 -1
  54. package/dist/cjs/scripts/drain-4.js +20 -11
  55. package/dist/cjs/scripts/drain-4.js.map +1 -1
  56. package/dist/cjs/scripts/getCountsPerPriority-4.js +7 -8
  57. package/dist/cjs/scripts/getCountsPerPriority-4.js.map +1 -1
  58. package/dist/cjs/scripts/index.js +9 -7
  59. package/dist/cjs/scripts/index.js.map +1 -1
  60. package/dist/cjs/scripts/isMaxed-2.js +34 -0
  61. package/dist/cjs/scripts/isMaxed-2.js.map +1 -0
  62. package/dist/cjs/scripts/moveJobFromActiveToWait-10.js +19 -10
  63. package/dist/cjs/scripts/moveJobFromActiveToWait-10.js.map +1 -1
  64. package/dist/cjs/scripts/{moveJobsToWait-7.js → moveJobsToWait-8.js} +21 -11
  65. package/dist/cjs/scripts/moveJobsToWait-8.js.map +1 -0
  66. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +45 -24
  67. package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
  68. package/dist/cjs/scripts/moveToActive-11.js +24 -14
  69. package/dist/cjs/scripts/moveToActive-11.js.map +1 -1
  70. package/dist/cjs/scripts/moveToFinished-14.js +46 -25
  71. package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
  72. package/dist/cjs/scripts/moveToWaitingChildren-5.js +4 -3
  73. package/dist/cjs/scripts/moveToWaitingChildren-5.js.map +1 -1
  74. package/dist/cjs/scripts/obliterate-2.js +41 -18
  75. package/dist/cjs/scripts/obliterate-2.js.map +1 -1
  76. package/dist/cjs/scripts/{promote-8.js → promote-9.js} +31 -19
  77. package/dist/cjs/scripts/promote-9.js.map +1 -0
  78. package/dist/cjs/scripts/removeChildDependency-1.js +20 -11
  79. package/dist/cjs/scripts/removeChildDependency-1.js.map +1 -1
  80. package/dist/cjs/scripts/{removeJob-1.js → removeJob-2.js} +24 -14
  81. package/dist/cjs/scripts/{removeJob-1.js.map → removeJob-2.js.map} +1 -1
  82. package/dist/cjs/scripts/removeRepeatable-2.js +29 -6
  83. package/dist/cjs/scripts/removeRepeatable-2.js.map +1 -1
  84. package/dist/cjs/scripts/{reprocessJob-7.js → reprocessJob-8.js} +23 -13
  85. package/dist/cjs/scripts/reprocessJob-8.js.map +1 -0
  86. package/dist/cjs/scripts/retryJob-11.js +42 -14
  87. package/dist/cjs/scripts/retryJob-11.js.map +1 -1
  88. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  89. package/dist/esm/classes/queue.d.ts +17 -0
  90. package/dist/esm/classes/queue.js +29 -0
  91. package/dist/esm/classes/queue.js.map +1 -1
  92. package/dist/esm/classes/repeat.d.ts +2 -0
  93. package/dist/esm/classes/repeat.js +44 -30
  94. package/dist/esm/classes/repeat.js.map +1 -1
  95. package/dist/esm/classes/scripts.d.ts +6 -2
  96. package/dist/esm/classes/scripts.js +44 -5
  97. package/dist/esm/classes/scripts.js.map +1 -1
  98. package/dist/esm/classes/worker.js +1 -1
  99. package/dist/esm/classes/worker.js.map +1 -1
  100. package/dist/esm/commands/{addPrioritizedJob-7.lua → addPrioritizedJob-8.lua} +9 -7
  101. package/dist/esm/commands/addRepeatableJob-2.lua +69 -0
  102. package/dist/esm/commands/{addStandardJob-7.lua → addStandardJob-8.lua} +6 -5
  103. package/dist/esm/commands/{changePriority-6.lua → changePriority-7.lua} +12 -10
  104. package/dist/esm/commands/getCountsPerPriority-4.lua +6 -3
  105. package/dist/esm/commands/includes/addBaseMarkerIfNeeded.lua +2 -2
  106. package/dist/esm/commands/includes/addJobInTargetList.lua +2 -2
  107. package/dist/esm/commands/includes/addJobWithPriority.lua +3 -2
  108. package/dist/esm/commands/includes/getTargetQueueList.lua +14 -4
  109. package/dist/esm/commands/includes/isQueueMaxed.lua +15 -0
  110. package/dist/esm/commands/includes/isQueuePaused.lua +1 -1
  111. package/dist/esm/commands/includes/isQueuePausedOrMaxed.lua +18 -0
  112. package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +8 -6
  113. package/dist/esm/commands/includes/removeParentDependencyKey.lua +3 -3
  114. package/dist/esm/commands/isMaxed-2.lua +17 -0
  115. package/dist/esm/commands/moveJobFromActiveToWait-10.lua +2 -2
  116. package/dist/{cjs/commands/moveJobsToWait-7.lua → esm/commands/moveJobsToWait-8.lua} +4 -3
  117. package/dist/esm/commands/moveStalledJobsToWait-9.lua +3 -3
  118. package/dist/esm/commands/moveToActive-11.lua +4 -4
  119. package/dist/esm/commands/moveToFinished-14.lua +4 -4
  120. package/dist/esm/commands/moveToWaitingChildren-5.lua +4 -3
  121. package/dist/esm/commands/obliterate-2.lua +23 -8
  122. package/dist/{cjs/commands/promote-8.lua → esm/commands/promote-9.lua} +9 -7
  123. package/dist/{cjs/commands/removeJob-1.lua → esm/commands/removeJob-2.lua} +2 -1
  124. package/dist/esm/commands/removeRepeatable-2.lua +27 -6
  125. package/dist/{cjs/commands/reprocessJob-7.lua → esm/commands/reprocessJob-8.lua} +4 -3
  126. package/dist/esm/commands/retryJob-11.lua +8 -4
  127. package/dist/esm/interfaces/index.d.ts +1 -0
  128. package/dist/esm/interfaces/index.js +1 -0
  129. package/dist/esm/interfaces/index.js.map +1 -1
  130. package/dist/esm/interfaces/repeatable-job.d.ts +3 -2
  131. package/dist/esm/interfaces/repeatable-options.d.ts +7 -0
  132. package/dist/esm/interfaces/repeatable-options.js +2 -0
  133. package/dist/esm/interfaces/repeatable-options.js.map +1 -0
  134. package/dist/esm/scripts/addDelayedJob-6.js +39 -18
  135. package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
  136. package/dist/esm/scripts/addParentJob-4.js +39 -18
  137. package/dist/esm/scripts/addParentJob-4.js.map +1 -1
  138. package/dist/esm/scripts/{addPrioritizedJob-7.js → addPrioritizedJob-8.js} +49 -26
  139. package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -0
  140. package/dist/esm/scripts/addRepeatableJob-2.d.ts +5 -0
  141. package/dist/esm/scripts/addRepeatableJob-2.js +63 -0
  142. package/dist/esm/scripts/addRepeatableJob-2.js.map +1 -0
  143. package/dist/esm/scripts/{addStandardJob-7.js → addStandardJob-8.js} +47 -25
  144. package/dist/esm/scripts/addStandardJob-8.js.map +1 -0
  145. package/dist/esm/scripts/{changePriority-6.js → changePriority-7.js} +33 -21
  146. package/dist/esm/scripts/changePriority-7.js.map +1 -0
  147. package/dist/esm/scripts/cleanJobsInSet-2.js +20 -11
  148. package/dist/esm/scripts/cleanJobsInSet-2.js.map +1 -1
  149. package/dist/esm/scripts/drain-4.js +20 -11
  150. package/dist/esm/scripts/drain-4.js.map +1 -1
  151. package/dist/esm/scripts/getCountsPerPriority-4.js +7 -8
  152. package/dist/esm/scripts/getCountsPerPriority-4.js.map +1 -1
  153. package/dist/esm/scripts/index.d.ts +9 -7
  154. package/dist/esm/scripts/index.js +9 -7
  155. package/dist/esm/scripts/index.js.map +1 -1
  156. package/dist/esm/scripts/isMaxed-2.d.ts +5 -0
  157. package/dist/esm/scripts/isMaxed-2.js +31 -0
  158. package/dist/esm/scripts/isMaxed-2.js.map +1 -0
  159. package/dist/esm/scripts/moveJobFromActiveToWait-10.js +19 -10
  160. package/dist/esm/scripts/moveJobFromActiveToWait-10.js.map +1 -1
  161. package/dist/esm/scripts/{moveJobsToWait-7.js → moveJobsToWait-8.js} +21 -11
  162. package/dist/esm/scripts/moveJobsToWait-8.js.map +1 -0
  163. package/dist/esm/scripts/moveStalledJobsToWait-9.js +45 -24
  164. package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
  165. package/dist/esm/scripts/moveToActive-11.js +24 -14
  166. package/dist/esm/scripts/moveToActive-11.js.map +1 -1
  167. package/dist/esm/scripts/moveToFinished-14.js +46 -25
  168. package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
  169. package/dist/esm/scripts/moveToWaitingChildren-5.js +4 -3
  170. package/dist/esm/scripts/moveToWaitingChildren-5.js.map +1 -1
  171. package/dist/esm/scripts/obliterate-2.js +41 -18
  172. package/dist/esm/scripts/obliterate-2.js.map +1 -1
  173. package/dist/esm/scripts/{promote-8.js → promote-9.js} +31 -19
  174. package/dist/esm/scripts/promote-9.js.map +1 -0
  175. package/dist/esm/scripts/removeChildDependency-1.js +20 -11
  176. package/dist/esm/scripts/removeChildDependency-1.js.map +1 -1
  177. package/dist/esm/scripts/{removeJob-1.js → removeJob-2.js} +24 -14
  178. package/dist/esm/scripts/{removeJob-1.js.map → removeJob-2.js.map} +1 -1
  179. package/dist/esm/scripts/removeRepeatable-2.js +29 -6
  180. package/dist/esm/scripts/removeRepeatable-2.js.map +1 -1
  181. package/dist/esm/scripts/{reprocessJob-7.js → reprocessJob-8.js} +23 -13
  182. package/dist/esm/scripts/reprocessJob-8.js.map +1 -0
  183. package/dist/esm/scripts/retryJob-11.js +42 -14
  184. package/dist/esm/scripts/retryJob-11.js.map +1 -1
  185. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  186. package/package.json +2 -1
  187. package/dist/cjs/scripts/addPrioritizedJob-7.js.map +0 -1
  188. package/dist/cjs/scripts/addStandardJob-7.js.map +0 -1
  189. package/dist/cjs/scripts/changePriority-6.js.map +0 -1
  190. package/dist/cjs/scripts/moveJobsToWait-7.js.map +0 -1
  191. package/dist/cjs/scripts/promote-8.js.map +0 -1
  192. package/dist/cjs/scripts/reprocessJob-7.js.map +0 -1
  193. package/dist/esm/scripts/addPrioritizedJob-7.js.map +0 -1
  194. package/dist/esm/scripts/addStandardJob-7.js.map +0 -1
  195. package/dist/esm/scripts/changePriority-6.js.map +0 -1
  196. package/dist/esm/scripts/moveJobsToWait-7.js.map +0 -1
  197. package/dist/esm/scripts/promote-8.js.map +0 -1
  198. package/dist/esm/scripts/reprocessJob-7.js.map +0 -1
  199. /package/dist/esm/scripts/{addPrioritizedJob-7.d.ts → addPrioritizedJob-8.d.ts} +0 -0
  200. /package/dist/esm/scripts/{addStandardJob-7.d.ts → addStandardJob-8.d.ts} +0 -0
  201. /package/dist/esm/scripts/{changePriority-6.d.ts → changePriority-7.d.ts} +0 -0
  202. /package/dist/esm/scripts/{moveJobsToWait-7.d.ts → moveJobsToWait-8.d.ts} +0 -0
  203. /package/dist/esm/scripts/{promote-8.d.ts → promote-9.d.ts} +0 -0
  204. /package/dist/esm/scripts/{removeJob-1.d.ts → removeJob-2.d.ts} +0 -0
  205. /package/dist/esm/scripts/{reprocessJob-7.d.ts → reprocessJob-8.d.ts} +0 -0
@@ -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,11 @@ 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("./addRepeatableJob-2"), exports);
9
+ tslib_1.__exportStar(require("./addStandardJob-8"), exports);
9
10
  tslib_1.__exportStar(require("./changeDelay-4"), exports);
10
- tslib_1.__exportStar(require("./changePriority-6"), exports);
11
+ tslib_1.__exportStar(require("./changePriority-7"), exports);
11
12
  tslib_1.__exportStar(require("./cleanJobsInSet-2"), exports);
12
13
  tslib_1.__exportStar(require("./drain-4"), exports);
13
14
  tslib_1.__exportStar(require("./extendLock-2"), exports);
@@ -19,8 +20,9 @@ tslib_1.__exportStar(require("./getState-8"), exports);
19
20
  tslib_1.__exportStar(require("./getStateV2-8"), exports);
20
21
  tslib_1.__exportStar(require("./isFinished-3"), exports);
21
22
  tslib_1.__exportStar(require("./isJobInList-1"), exports);
23
+ tslib_1.__exportStar(require("./isMaxed-2"), exports);
22
24
  tslib_1.__exportStar(require("./moveJobFromActiveToWait-10"), exports);
23
- tslib_1.__exportStar(require("./moveJobsToWait-7"), exports);
25
+ tslib_1.__exportStar(require("./moveJobsToWait-8"), exports);
24
26
  tslib_1.__exportStar(require("./moveStalledJobsToWait-9"), exports);
25
27
  tslib_1.__exportStar(require("./moveToActive-11"), exports);
26
28
  tslib_1.__exportStar(require("./moveToDelayed-8"), exports);
@@ -29,12 +31,12 @@ tslib_1.__exportStar(require("./moveToWaitingChildren-5"), exports);
29
31
  tslib_1.__exportStar(require("./obliterate-2"), exports);
30
32
  tslib_1.__exportStar(require("./paginate-1"), exports);
31
33
  tslib_1.__exportStar(require("./pause-7"), exports);
32
- tslib_1.__exportStar(require("./promote-8"), exports);
34
+ tslib_1.__exportStar(require("./promote-9"), exports);
33
35
  tslib_1.__exportStar(require("./releaseLock-1"), exports);
34
36
  tslib_1.__exportStar(require("./removeChildDependency-1"), exports);
35
- tslib_1.__exportStar(require("./removeJob-1"), exports);
37
+ tslib_1.__exportStar(require("./removeJob-2"), exports);
36
38
  tslib_1.__exportStar(require("./removeRepeatable-2"), exports);
37
- tslib_1.__exportStar(require("./reprocessJob-7"), exports);
39
+ tslib_1.__exportStar(require("./reprocessJob-8"), exports);
38
40
  tslib_1.__exportStar(require("./retryJob-11"), exports);
39
41
  tslib_1.__exportStar(require("./saveStacktrace-1"), exports);
40
42
  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,+DAAqC;AACrC,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"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMaxed = void 0;
4
+ const content = `--[[
5
+ Checks if queue is maxed.
6
+ Input:
7
+ KEYS[1] meta key
8
+ KEYS[2] active key
9
+ Output:
10
+ 1 if element found in the list.
11
+ ]]
12
+ local rcall = redis.call
13
+ -- Includes
14
+ --[[
15
+ Function to check if queue is maxed or not.
16
+ ]]
17
+ local function isQueueMaxed(queueMetaKey, activeKey)
18
+ local maxConcurrency = rcall("HGET", queueMetaKey, "concurrency")
19
+ if maxConcurrency then
20
+ local activeCount = rcall("LLEN", activeKey)
21
+ if activeCount >= tonumber(maxConcurrency) then
22
+ return true
23
+ end
24
+ end
25
+ return false
26
+ end
27
+ return isQueueMaxed(KEYS[1], KEYS[2])
28
+ `;
29
+ exports.isMaxed = {
30
+ name: 'isMaxed',
31
+ content,
32
+ keys: 2,
33
+ };
34
+ //# sourceMappingURL=isMaxed-2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isMaxed-2.js","sourceRoot":"","sources":["../../../src/scripts/isMaxed-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBf,CAAC;AACW,QAAA,OAAO,GAAG;IACrB,IAAI,EAAE,SAAS;IACf,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -27,14 +27,14 @@ local rcall = redis.call
27
27
  --[[
28
28
  Add marker if needed when a job is available.
29
29
  ]]
30
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
31
- if not isPaused then
30
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
31
+ if not isPausedOrMaxed then
32
32
  rcall("ZADD", markerKey, 0, "0")
33
33
  end
34
34
  end
35
- local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
35
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
36
36
  rcall(pushCmd, targetKey, jobId)
37
- addBaseMarkerIfNeeded(markerKey, isPaused)
37
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
38
38
  end
39
39
  --[[
40
40
  Function to push back job considering priority in front of same prioritized jobs.
@@ -60,12 +60,21 @@ end
60
60
  Function to check for the meta.paused key to decide if we are paused or not
61
61
  (since an empty list and !EXISTS are not really the same).
62
62
  ]]
63
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
64
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
65
- return waitKey, false
66
- else
63
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
64
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
65
+ if queueAttributes[1] then
67
66
  return pausedKey, true
67
+ else
68
+ if queueAttributes[2] then
69
+ local activeCount = rcall("LLEN", activeKey)
70
+ if activeCount >= tonumber(queueAttributes[2]) then
71
+ return waitKey, true
72
+ else
73
+ return waitKey, false
74
+ end
75
+ end
68
76
  end
77
+ return waitKey, false
69
78
  end
70
79
  local jobId = ARGV[1]
71
80
  local token = ARGV[2]
@@ -76,13 +85,13 @@ if lockToken == token then
76
85
  local metaKey = KEYS[6]
77
86
  local removed = rcall("LREM", KEYS[1], 1, jobId)
78
87
  if removed > 0 then
79
- local target, isPaused = getTargetQueueList(metaKey, KEYS[2], KEYS[5])
88
+ local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[1], KEYS[2], KEYS[5])
80
89
  rcall("SREM", KEYS[3], jobId)
81
90
  local priority = tonumber(rcall("HGET", ARGV[3], "priority")) or 0
82
91
  if priority > 0 then
83
92
  pushBackJobWithPriority(KEYS[8], priority, jobId)
84
93
  else
85
- addJobInTargetList(target, KEYS[9], "RPUSH", isPaused, jobId)
94
+ addJobInTargetList(target, KEYS[9], "RPUSH", isPausedOrMaxed, jobId)
86
95
  end
87
96
  rcall("DEL", lockKey)
88
97
  local maxEvents = getOrSetMaxEvents(metaKey)
@@ -1 +1 @@
1
- {"version":3,"file":"moveJobFromActiveToWait-10.js","sourceRoot":"","sources":["../../../src/scripts/moveJobFromActiveToWait-10.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Ff,CAAC;AACW,QAAA,uBAAuB,GAAG;IACrC,IAAI,EAAE,yBAAyB;IAC/B,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
1
+ {"version":3,"file":"moveJobFromActiveToWait-10.js","sourceRoot":"","sources":["../../../src/scripts/moveJobFromActiveToWait-10.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoGf,CAAC;AACW,QAAA,uBAAuB,GAAG;IACrC,IAAI,EAAE,yBAAyB;IAC/B,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
@@ -11,7 +11,8 @@ const content = `--[[
11
11
  KEYS[4] 'wait'
12
12
  KEYS[5] 'paused'
13
13
  KEYS[6] 'meta'
14
- KEYS[7] 'marker'
14
+ KEYS[7] 'active'
15
+ KEYS[8] 'marker'
15
16
  ARGV[1] count
16
17
  ARGV[2] timestamp
17
18
  ARGV[3] prev state
@@ -26,8 +27,8 @@ local rcall = redis.call;
26
27
  --[[
27
28
  Add marker if needed when a job is available.
28
29
  ]]
29
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
30
- if not isPaused then
30
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
31
+ if not isPausedOrMaxed then
31
32
  rcall("ZADD", markerKey, 0, "0")
32
33
  end
33
34
  end
@@ -62,15 +63,24 @@ end
62
63
  Function to check for the meta.paused key to decide if we are paused or not
63
64
  (since an empty list and !EXISTS are not really the same).
64
65
  ]]
65
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
66
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
67
- return waitKey, false
68
- else
66
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
67
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
68
+ if queueAttributes[1] then
69
69
  return pausedKey, true
70
+ else
71
+ if queueAttributes[2] then
72
+ local activeCount = rcall("LLEN", activeKey)
73
+ if activeCount >= tonumber(queueAttributes[2]) then
74
+ return waitKey, true
75
+ else
76
+ return waitKey, false
77
+ end
78
+ end
70
79
  end
80
+ return waitKey, false
71
81
  end
72
82
  local metaKey = KEYS[6]
73
- local target, paused = getTargetQueueList(metaKey, KEYS[4], KEYS[5])
83
+ local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[7], KEYS[4], KEYS[5])
74
84
  local jobs = rcall('ZRANGEBYSCORE', KEYS[3], 0, timestamp, 'LIMIT', 0, maxCount)
75
85
  if (#jobs > 0) then
76
86
  if ARGV[3] == "failed" then
@@ -94,7 +104,7 @@ if (#jobs > 0) then
94
104
  rcall("ZREM", KEYS[3], unpack(jobs, from, to))
95
105
  rcall("LPUSH", target, unpack(jobs, from, to))
96
106
  end
97
- addBaseMarkerIfNeeded(KEYS[7], paused)
107
+ addBaseMarkerIfNeeded(KEYS[8], isPausedOrMaxed)
98
108
  end
99
109
  maxCount = maxCount - #jobs
100
110
  if (maxCount <= 0) then return 1 end
@@ -103,6 +113,6 @@ return 0
103
113
  exports.moveJobsToWait = {
104
114
  name: 'moveJobsToWait',
105
115
  content,
106
- keys: 7,
116
+ keys: 8,
107
117
  };
108
- //# sourceMappingURL=moveJobsToWait-7.js.map
118
+ //# sourceMappingURL=moveJobsToWait-8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moveJobsToWait-8.js","sourceRoot":"","sources":["../../../src/scripts/moveJobsToWait-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Gf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}