bullmq 5.8.6 → 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 (188) 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/addDelayedJob-6.lua +2 -6
  8. package/dist/cjs/commands/{addPrioritizedJob-7.lua → addPrioritizedJob-8.lua} +9 -7
  9. package/dist/cjs/commands/{addStandardJob-7.lua → addStandardJob-8.lua} +6 -5
  10. package/dist/cjs/commands/changeDelay-4.lua +1 -5
  11. package/dist/cjs/commands/{changePriority-6.lua → changePriority-7.lua} +12 -10
  12. package/dist/cjs/commands/getCountsPerPriority-4.lua +6 -3
  13. package/dist/cjs/commands/includes/addBaseMarkerIfNeeded.lua +2 -2
  14. package/dist/cjs/commands/includes/addJobInTargetList.lua +2 -2
  15. package/dist/cjs/commands/includes/addJobWithPriority.lua +3 -2
  16. package/dist/cjs/commands/includes/getTargetQueueList.lua +14 -4
  17. package/dist/cjs/commands/includes/isQueueMaxed.lua +15 -0
  18. package/dist/cjs/commands/includes/isQueuePaused.lua +1 -1
  19. package/dist/cjs/commands/includes/isQueuePausedOrMaxed.lua +18 -0
  20. package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +8 -6
  21. package/dist/cjs/commands/includes/removeParentDependencyKey.lua +3 -3
  22. package/dist/cjs/commands/isMaxed-2.lua +17 -0
  23. package/dist/cjs/commands/moveJobFromActiveToWait-10.lua +2 -2
  24. package/dist/{esm/commands/moveJobsToWait-7.lua → cjs/commands/moveJobsToWait-8.lua} +4 -3
  25. package/dist/cjs/commands/moveStalledJobsToWait-9.lua +3 -3
  26. package/dist/cjs/commands/moveToActive-11.lua +4 -4
  27. package/dist/cjs/commands/moveToDelayed-8.lua +2 -6
  28. package/dist/cjs/commands/moveToFinished-14.lua +4 -4
  29. package/dist/cjs/commands/moveToWaitingChildren-5.lua +4 -3
  30. package/dist/{esm/commands/promote-8.lua → cjs/commands/promote-9.lua} +9 -7
  31. package/dist/{esm/commands/removeJob-1.lua → cjs/commands/removeJob-2.lua} +2 -1
  32. package/dist/{esm/commands/reprocessJob-7.lua → cjs/commands/reprocessJob-8.lua} +4 -3
  33. package/dist/cjs/commands/retryJob-11.lua +8 -4
  34. package/dist/cjs/scripts/addDelayedJob-6.js +41 -23
  35. package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
  36. package/dist/cjs/scripts/addParentJob-4.js +39 -18
  37. package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
  38. package/dist/cjs/scripts/{addPrioritizedJob-7.js → addPrioritizedJob-8.js} +49 -26
  39. package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -0
  40. package/dist/cjs/scripts/{addStandardJob-7.js → addStandardJob-8.js} +47 -25
  41. package/dist/cjs/scripts/addStandardJob-8.js.map +1 -0
  42. package/dist/cjs/scripts/changeDelay-4.js +1 -11
  43. package/dist/cjs/scripts/changeDelay-4.js.map +1 -1
  44. package/dist/cjs/scripts/{changePriority-6.js → changePriority-7.js} +33 -21
  45. package/dist/cjs/scripts/changePriority-7.js.map +1 -0
  46. package/dist/cjs/scripts/cleanJobsInSet-2.js +20 -11
  47. package/dist/cjs/scripts/cleanJobsInSet-2.js.map +1 -1
  48. package/dist/cjs/scripts/drain-4.js +20 -11
  49. package/dist/cjs/scripts/drain-4.js.map +1 -1
  50. package/dist/cjs/scripts/getCountsPerPriority-4.js +7 -8
  51. package/dist/cjs/scripts/getCountsPerPriority-4.js.map +1 -1
  52. package/dist/cjs/scripts/index.js +8 -7
  53. package/dist/cjs/scripts/index.js.map +1 -1
  54. package/dist/cjs/scripts/isMaxed-2.js +34 -0
  55. package/dist/cjs/scripts/isMaxed-2.js.map +1 -0
  56. package/dist/cjs/scripts/moveJobFromActiveToWait-10.js +19 -10
  57. package/dist/cjs/scripts/moveJobFromActiveToWait-10.js.map +1 -1
  58. package/dist/cjs/scripts/{moveJobsToWait-7.js → moveJobsToWait-8.js} +21 -11
  59. package/dist/cjs/scripts/moveJobsToWait-8.js.map +1 -0
  60. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +45 -24
  61. package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
  62. package/dist/cjs/scripts/moveToActive-11.js +24 -14
  63. package/dist/cjs/scripts/moveToActive-11.js.map +1 -1
  64. package/dist/cjs/scripts/moveToDelayed-8.js +2 -12
  65. package/dist/cjs/scripts/moveToDelayed-8.js.map +1 -1
  66. package/dist/cjs/scripts/moveToFinished-14.js +46 -25
  67. package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
  68. package/dist/cjs/scripts/moveToWaitingChildren-5.js +4 -3
  69. package/dist/cjs/scripts/moveToWaitingChildren-5.js.map +1 -1
  70. package/dist/cjs/scripts/obliterate-2.js +20 -11
  71. package/dist/cjs/scripts/obliterate-2.js.map +1 -1
  72. package/dist/cjs/scripts/{promote-8.js → promote-9.js} +31 -19
  73. package/dist/cjs/scripts/promote-9.js.map +1 -0
  74. package/dist/cjs/scripts/removeChildDependency-1.js +20 -11
  75. package/dist/cjs/scripts/removeChildDependency-1.js.map +1 -1
  76. package/dist/cjs/scripts/{removeJob-1.js → removeJob-2.js} +24 -14
  77. package/dist/cjs/scripts/{removeJob-1.js.map → removeJob-2.js.map} +1 -1
  78. package/dist/cjs/scripts/{reprocessJob-7.js → reprocessJob-8.js} +23 -13
  79. package/dist/cjs/scripts/reprocessJob-8.js.map +1 -0
  80. package/dist/cjs/scripts/retryJob-11.js +42 -14
  81. package/dist/cjs/scripts/retryJob-11.js.map +1 -1
  82. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  83. package/dist/esm/classes/queue.d.ts +17 -0
  84. package/dist/esm/classes/queue.js +29 -0
  85. package/dist/esm/classes/queue.js.map +1 -1
  86. package/dist/esm/classes/scripts.d.ts +2 -0
  87. package/dist/esm/classes/scripts.js +17 -1
  88. package/dist/esm/classes/scripts.js.map +1 -1
  89. package/dist/esm/classes/worker.js +1 -1
  90. package/dist/esm/classes/worker.js.map +1 -1
  91. package/dist/esm/commands/addDelayedJob-6.lua +2 -6
  92. package/dist/esm/commands/{addPrioritizedJob-7.lua → addPrioritizedJob-8.lua} +9 -7
  93. package/dist/esm/commands/{addStandardJob-7.lua → addStandardJob-8.lua} +6 -5
  94. package/dist/esm/commands/changeDelay-4.lua +1 -5
  95. package/dist/esm/commands/{changePriority-6.lua → changePriority-7.lua} +12 -10
  96. package/dist/esm/commands/getCountsPerPriority-4.lua +6 -3
  97. package/dist/esm/commands/includes/addBaseMarkerIfNeeded.lua +2 -2
  98. package/dist/esm/commands/includes/addJobInTargetList.lua +2 -2
  99. package/dist/esm/commands/includes/addJobWithPriority.lua +3 -2
  100. package/dist/esm/commands/includes/getTargetQueueList.lua +14 -4
  101. package/dist/esm/commands/includes/isQueueMaxed.lua +15 -0
  102. package/dist/esm/commands/includes/isQueuePaused.lua +1 -1
  103. package/dist/esm/commands/includes/isQueuePausedOrMaxed.lua +18 -0
  104. package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +8 -6
  105. package/dist/esm/commands/includes/removeParentDependencyKey.lua +3 -3
  106. package/dist/esm/commands/isMaxed-2.lua +17 -0
  107. package/dist/esm/commands/moveJobFromActiveToWait-10.lua +2 -2
  108. package/dist/{cjs/commands/moveJobsToWait-7.lua → esm/commands/moveJobsToWait-8.lua} +4 -3
  109. package/dist/esm/commands/moveStalledJobsToWait-9.lua +3 -3
  110. package/dist/esm/commands/moveToActive-11.lua +4 -4
  111. package/dist/esm/commands/moveToDelayed-8.lua +2 -6
  112. package/dist/esm/commands/moveToFinished-14.lua +4 -4
  113. package/dist/esm/commands/moveToWaitingChildren-5.lua +4 -3
  114. package/dist/{cjs/commands/promote-8.lua → esm/commands/promote-9.lua} +9 -7
  115. package/dist/{cjs/commands/removeJob-1.lua → esm/commands/removeJob-2.lua} +2 -1
  116. package/dist/{cjs/commands/reprocessJob-7.lua → esm/commands/reprocessJob-8.lua} +4 -3
  117. package/dist/esm/commands/retryJob-11.lua +8 -4
  118. package/dist/esm/scripts/addDelayedJob-6.js +41 -23
  119. package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
  120. package/dist/esm/scripts/addParentJob-4.js +39 -18
  121. package/dist/esm/scripts/addParentJob-4.js.map +1 -1
  122. package/dist/esm/scripts/{addPrioritizedJob-7.js → addPrioritizedJob-8.js} +49 -26
  123. package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -0
  124. package/dist/esm/scripts/{addStandardJob-7.js → addStandardJob-8.js} +47 -25
  125. package/dist/esm/scripts/addStandardJob-8.js.map +1 -0
  126. package/dist/esm/scripts/changeDelay-4.js +1 -11
  127. package/dist/esm/scripts/changeDelay-4.js.map +1 -1
  128. package/dist/esm/scripts/{changePriority-6.js → changePriority-7.js} +33 -21
  129. package/dist/esm/scripts/changePriority-7.js.map +1 -0
  130. package/dist/esm/scripts/cleanJobsInSet-2.js +20 -11
  131. package/dist/esm/scripts/cleanJobsInSet-2.js.map +1 -1
  132. package/dist/esm/scripts/drain-4.js +20 -11
  133. package/dist/esm/scripts/drain-4.js.map +1 -1
  134. package/dist/esm/scripts/getCountsPerPriority-4.js +7 -8
  135. package/dist/esm/scripts/getCountsPerPriority-4.js.map +1 -1
  136. package/dist/esm/scripts/index.d.ts +8 -7
  137. package/dist/esm/scripts/index.js +8 -7
  138. package/dist/esm/scripts/index.js.map +1 -1
  139. package/dist/esm/scripts/isMaxed-2.d.ts +5 -0
  140. package/dist/esm/scripts/isMaxed-2.js +31 -0
  141. package/dist/esm/scripts/isMaxed-2.js.map +1 -0
  142. package/dist/esm/scripts/moveJobFromActiveToWait-10.js +19 -10
  143. package/dist/esm/scripts/moveJobFromActiveToWait-10.js.map +1 -1
  144. package/dist/esm/scripts/{moveJobsToWait-7.js → moveJobsToWait-8.js} +21 -11
  145. package/dist/esm/scripts/moveJobsToWait-8.js.map +1 -0
  146. package/dist/esm/scripts/moveStalledJobsToWait-9.js +45 -24
  147. package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
  148. package/dist/esm/scripts/moveToActive-11.js +24 -14
  149. package/dist/esm/scripts/moveToActive-11.js.map +1 -1
  150. package/dist/esm/scripts/moveToDelayed-8.js +2 -12
  151. package/dist/esm/scripts/moveToDelayed-8.js.map +1 -1
  152. package/dist/esm/scripts/moveToFinished-14.js +46 -25
  153. package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
  154. package/dist/esm/scripts/moveToWaitingChildren-5.js +4 -3
  155. package/dist/esm/scripts/moveToWaitingChildren-5.js.map +1 -1
  156. package/dist/esm/scripts/obliterate-2.js +20 -11
  157. package/dist/esm/scripts/obliterate-2.js.map +1 -1
  158. package/dist/esm/scripts/{promote-8.js → promote-9.js} +31 -19
  159. package/dist/esm/scripts/promote-9.js.map +1 -0
  160. package/dist/esm/scripts/removeChildDependency-1.js +20 -11
  161. package/dist/esm/scripts/removeChildDependency-1.js.map +1 -1
  162. package/dist/esm/scripts/{removeJob-1.js → removeJob-2.js} +24 -14
  163. package/dist/esm/scripts/{removeJob-1.js.map → removeJob-2.js.map} +1 -1
  164. package/dist/esm/scripts/{reprocessJob-7.js → reprocessJob-8.js} +23 -13
  165. package/dist/esm/scripts/reprocessJob-8.js.map +1 -0
  166. package/dist/esm/scripts/retryJob-11.js +42 -14
  167. package/dist/esm/scripts/retryJob-11.js.map +1 -1
  168. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  169. package/package.json +2 -1
  170. package/dist/cjs/scripts/addPrioritizedJob-7.js.map +0 -1
  171. package/dist/cjs/scripts/addStandardJob-7.js.map +0 -1
  172. package/dist/cjs/scripts/changePriority-6.js.map +0 -1
  173. package/dist/cjs/scripts/moveJobsToWait-7.js.map +0 -1
  174. package/dist/cjs/scripts/promote-8.js.map +0 -1
  175. package/dist/cjs/scripts/reprocessJob-7.js.map +0 -1
  176. package/dist/esm/scripts/addPrioritizedJob-7.js.map +0 -1
  177. package/dist/esm/scripts/addStandardJob-7.js.map +0 -1
  178. package/dist/esm/scripts/changePriority-6.js.map +0 -1
  179. package/dist/esm/scripts/moveJobsToWait-7.js.map +0 -1
  180. package/dist/esm/scripts/promote-8.js.map +0 -1
  181. package/dist/esm/scripts/reprocessJob-7.js.map +0 -1
  182. /package/dist/esm/scripts/{addPrioritizedJob-7.d.ts → addPrioritizedJob-8.d.ts} +0 -0
  183. /package/dist/esm/scripts/{addStandardJob-7.d.ts → addStandardJob-8.d.ts} +0 -0
  184. /package/dist/esm/scripts/{changePriority-6.d.ts → changePriority-7.d.ts} +0 -0
  185. /package/dist/esm/scripts/{moveJobsToWait-7.d.ts → moveJobsToWait-8.d.ts} +0 -0
  186. /package/dist/esm/scripts/{promote-8.d.ts → promote-9.d.ts} +0 -0
  187. /package/dist/esm/scripts/{removeJob-1.d.ts → removeJob-2.d.ts} +0 -0
  188. /package/dist/esm/scripts/{reprocessJob-7.d.ts → reprocessJob-8.d.ts} +0 -0
@@ -1,10 +1,10 @@
1
1
  export * from './addDelayedJob-6';
2
2
  export * from './addLog-2';
3
3
  export * from './addParentJob-4';
4
- export * from './addPrioritizedJob-7';
5
- export * from './addStandardJob-7';
4
+ export * from './addPrioritizedJob-8';
5
+ export * from './addStandardJob-8';
6
6
  export * from './changeDelay-4';
7
- export * from './changePriority-6';
7
+ export * from './changePriority-7';
8
8
  export * from './cleanJobsInSet-2';
9
9
  export * from './drain-4';
10
10
  export * from './extendLock-2';
@@ -16,8 +16,9 @@ export * from './getState-8';
16
16
  export * from './getStateV2-8';
17
17
  export * from './isFinished-3';
18
18
  export * from './isJobInList-1';
19
+ export * from './isMaxed-2';
19
20
  export * from './moveJobFromActiveToWait-10';
20
- export * from './moveJobsToWait-7';
21
+ export * from './moveJobsToWait-8';
21
22
  export * from './moveStalledJobsToWait-9';
22
23
  export * from './moveToActive-11';
23
24
  export * from './moveToDelayed-8';
@@ -26,12 +27,12 @@ export * from './moveToWaitingChildren-5';
26
27
  export * from './obliterate-2';
27
28
  export * from './paginate-1';
28
29
  export * from './pause-7';
29
- export * from './promote-8';
30
+ export * from './promote-9';
30
31
  export * from './releaseLock-1';
31
32
  export * from './removeChildDependency-1';
32
- export * from './removeJob-1';
33
+ export * from './removeJob-2';
33
34
  export * from './removeRepeatable-2';
34
- export * from './reprocessJob-7';
35
+ export * from './reprocessJob-8';
35
36
  export * from './retryJob-11';
36
37
  export * from './saveStacktrace-1';
37
38
  export * from './updateData-1';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const isMaxed: {
2
+ name: string;
3
+ content: string;
4
+ keys: number;
5
+ };
@@ -0,0 +1,31 @@
1
+ const content = `--[[
2
+ Checks if queue is maxed.
3
+ Input:
4
+ KEYS[1] meta key
5
+ KEYS[2] active key
6
+ Output:
7
+ 1 if element found in the list.
8
+ ]]
9
+ local rcall = redis.call
10
+ -- Includes
11
+ --[[
12
+ Function to check if queue is maxed or not.
13
+ ]]
14
+ local function isQueueMaxed(queueMetaKey, activeKey)
15
+ local maxConcurrency = rcall("HGET", queueMetaKey, "concurrency")
16
+ if maxConcurrency then
17
+ local activeCount = rcall("LLEN", activeKey)
18
+ if activeCount >= tonumber(maxConcurrency) then
19
+ return true
20
+ end
21
+ end
22
+ return false
23
+ end
24
+ return isQueueMaxed(KEYS[1], KEYS[2])
25
+ `;
26
+ export const isMaxed = {
27
+ name: 'isMaxed',
28
+ content,
29
+ keys: 2,
30
+ };
31
+ //# 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;AACF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,SAAS;IACf,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -24,14 +24,14 @@ local rcall = redis.call
24
24
  --[[
25
25
  Add marker if needed when a job is available.
26
26
  ]]
27
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
28
- if not isPaused then
27
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
28
+ if not isPausedOrMaxed then
29
29
  rcall("ZADD", markerKey, 0, "0")
30
30
  end
31
31
  end
32
- local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
32
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
33
33
  rcall(pushCmd, targetKey, jobId)
34
- addBaseMarkerIfNeeded(markerKey, isPaused)
34
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
35
35
  end
36
36
  --[[
37
37
  Function to push back job considering priority in front of same prioritized jobs.
@@ -57,12 +57,21 @@ end
57
57
  Function to check for the meta.paused key to decide if we are paused or not
58
58
  (since an empty list and !EXISTS are not really the same).
59
59
  ]]
60
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
61
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
62
- return waitKey, false
63
- else
60
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
61
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
62
+ if queueAttributes[1] then
64
63
  return pausedKey, true
64
+ else
65
+ if queueAttributes[2] then
66
+ local activeCount = rcall("LLEN", activeKey)
67
+ if activeCount >= tonumber(queueAttributes[2]) then
68
+ return waitKey, true
69
+ else
70
+ return waitKey, false
71
+ end
72
+ end
65
73
  end
74
+ return waitKey, false
66
75
  end
67
76
  local jobId = ARGV[1]
68
77
  local token = ARGV[2]
@@ -73,13 +82,13 @@ if lockToken == token then
73
82
  local metaKey = KEYS[6]
74
83
  local removed = rcall("LREM", KEYS[1], 1, jobId)
75
84
  if removed > 0 then
76
- local target, isPaused = getTargetQueueList(metaKey, KEYS[2], KEYS[5])
85
+ local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[1], KEYS[2], KEYS[5])
77
86
  rcall("SREM", KEYS[3], jobId)
78
87
  local priority = tonumber(rcall("HGET", ARGV[3], "priority")) or 0
79
88
  if priority > 0 then
80
89
  pushBackJobWithPriority(KEYS[8], priority, jobId)
81
90
  else
82
- addJobInTargetList(target, KEYS[9], "RPUSH", isPaused, jobId)
91
+ addJobInTargetList(target, KEYS[9], "RPUSH", isPausedOrMaxed, jobId)
83
92
  end
84
93
  rcall("DEL", lockKey)
85
94
  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;AACF,MAAM,CAAC,MAAM,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;AACF,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,IAAI,EAAE,yBAAyB;IAC/B,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
@@ -8,7 +8,8 @@ const content = `--[[
8
8
  KEYS[4] 'wait'
9
9
  KEYS[5] 'paused'
10
10
  KEYS[6] 'meta'
11
- KEYS[7] 'marker'
11
+ KEYS[7] 'active'
12
+ KEYS[8] 'marker'
12
13
  ARGV[1] count
13
14
  ARGV[2] timestamp
14
15
  ARGV[3] prev state
@@ -23,8 +24,8 @@ local rcall = redis.call;
23
24
  --[[
24
25
  Add marker if needed when a job is available.
25
26
  ]]
26
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
27
- if not isPaused then
27
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
28
+ if not isPausedOrMaxed then
28
29
  rcall("ZADD", markerKey, 0, "0")
29
30
  end
30
31
  end
@@ -59,15 +60,24 @@ end
59
60
  Function to check for the meta.paused key to decide if we are paused or not
60
61
  (since an empty list and !EXISTS are not really the same).
61
62
  ]]
62
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
63
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
64
- return waitKey, false
65
- else
63
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
64
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
65
+ if queueAttributes[1] then
66
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
67
76
  end
77
+ return waitKey, false
68
78
  end
69
79
  local metaKey = KEYS[6]
70
- local target, paused = getTargetQueueList(metaKey, KEYS[4], KEYS[5])
80
+ local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[7], KEYS[4], KEYS[5])
71
81
  local jobs = rcall('ZRANGEBYSCORE', KEYS[3], 0, timestamp, 'LIMIT', 0, maxCount)
72
82
  if (#jobs > 0) then
73
83
  if ARGV[3] == "failed" then
@@ -91,7 +101,7 @@ if (#jobs > 0) then
91
101
  rcall("ZREM", KEYS[3], unpack(jobs, from, to))
92
102
  rcall("LPUSH", target, unpack(jobs, from, to))
93
103
  end
94
- addBaseMarkerIfNeeded(KEYS[7], paused)
104
+ addBaseMarkerIfNeeded(KEYS[8], isPausedOrMaxed)
95
105
  end
96
106
  maxCount = maxCount - #jobs
97
107
  if (maxCount <= 0) then return 1 end
@@ -100,6 +110,6 @@ return 0
100
110
  export const moveJobsToWait = {
101
111
  name: 'moveJobsToWait',
102
112
  content,
103
- keys: 7,
113
+ keys: 8,
104
114
  };
105
- //# sourceMappingURL=moveJobsToWait-7.js.map
115
+ //# 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;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -26,14 +26,14 @@ local rcall = redis.call
26
26
  --[[
27
27
  Add marker if needed when a job is available.
28
28
  ]]
29
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
30
- if not isPaused then
29
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
30
+ if not isPausedOrMaxed then
31
31
  rcall("ZADD", markerKey, 0, "0")
32
32
  end
33
33
  end
34
- local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
34
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
35
35
  rcall(pushCmd, targetKey, jobId)
36
- addBaseMarkerIfNeeded(markerKey, isPaused)
36
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
37
37
  end
38
38
  --[[
39
39
  Function to loop in batches.
@@ -55,12 +55,21 @@ end
55
55
  Function to check for the meta.paused key to decide if we are paused or not
56
56
  (since an empty list and !EXISTS are not really the same).
57
57
  ]]
58
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
59
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
60
- return waitKey, false
61
- else
58
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
59
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
60
+ if queueAttributes[1] then
62
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
63
71
  end
72
+ return waitKey, false
64
73
  end
65
74
  --[[
66
75
  Function to recursively move from waitingChildren to failed.
@@ -98,18 +107,28 @@ end
98
107
  Function to add job considering priority.
99
108
  ]]
100
109
  -- Includes
101
- local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
110
+ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
111
+ isPausedOrMaxed)
102
112
  local prioCounter = rcall("INCR", priorityCounterKey)
103
113
  local score = priority * 0x100000000 + prioCounter % 0x100000000
104
114
  rcall("ZADD", prioritizedKey, score, jobId)
105
- addBaseMarkerIfNeeded(markerKey, isPaused)
115
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
106
116
  end
107
117
  --[[
108
- Function to check for the meta.paused key to decide if we are paused or not
118
+ Function to check if queue is paused or maxed
109
119
  (since an empty list and !EXISTS are not really the same).
110
120
  ]]
111
- local function isQueuePaused(queueMetaKey)
112
- return rcall("HEXISTS", queueMetaKey, "paused") == 1
121
+ local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
122
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
123
+ if queueAttributes[1] then
124
+ return true
125
+ else
126
+ if queueAttributes[2] then
127
+ local activeCount = rcall("LLEN", activeKey)
128
+ return activeCount >= tonumber(queueAttributes[2])
129
+ end
130
+ end
131
+ return false
113
132
  end
114
133
  local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
115
134
  parentKey, parentId, timestamp)
@@ -119,6 +138,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
119
138
  rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
120
139
  local parentWaitKey = parentQueueKey .. ":wait"
121
140
  local parentPausedKey = parentQueueKey .. ":paused"
141
+ local parentActiveKey = parentQueueKey .. ":active"
122
142
  local parentMetaKey = parentQueueKey .. ":meta"
123
143
  local parentMarkerKey = parentQueueKey .. ":marker"
124
144
  local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
@@ -134,15 +154,16 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
134
154
  addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
135
155
  else
136
156
  if priority == 0 then
137
- local parentTarget, isParentPaused =
138
- getTargetQueueList(parentMetaKey, parentWaitKey,
157
+ local parentTarget, isParentPausedOrMaxed =
158
+ getTargetQueueList(parentMetaKey, parentActiveKey, parentWaitKey,
139
159
  parentPausedKey)
140
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPaused, parentId)
160
+ addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
161
+ parentId)
141
162
  else
142
- local isPaused = isQueuePaused(parentMetaKey)
163
+ local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
143
164
  addJobWithPriority(parentMarkerKey,
144
165
  parentQueueKey .. ":prioritized", priority,
145
- parentId, parentQueueKey .. ":pc", isPaused)
166
+ parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
146
167
  end
147
168
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
148
169
  "jobId", parentId, "prev", "waiting-children")
@@ -206,9 +227,9 @@ local getJobKeyPrefix = function (jobKey, jobId)
206
227
  return string.sub(jobKey, 0, #jobKey - #jobId)
207
228
  end
208
229
  local function moveParentToWait(parentPrefix, parentId, emitEvent)
209
- local parentTarget, isPaused = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
210
- parentPrefix .. "paused")
211
- addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPaused, parentId)
230
+ local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
231
+ parentPrefix .. "wait", parentPrefix .. "paused")
232
+ addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
212
233
  if emitEvent then
213
234
  local parentEventStream = parentPrefix .. "events"
214
235
  rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
@@ -418,10 +439,10 @@ if (#stalling > 0) then
418
439
  end
419
440
  table.insert(failed, jobId)
420
441
  else
421
- local target, isPaused=
422
- getTargetQueueList(metaKey, waitKey, pausedKey)
442
+ local target, isPausedOrMaxed=
443
+ getTargetQueueList(metaKey, activeKey, waitKey, pausedKey)
423
444
  -- Move the job back to the wait queue, to immediately be picked up by a waiting worker.
424
- addJobInTargetList(target, markerKey, "RPUSH", isPaused, jobId)
445
+ addJobInTargetList(target, markerKey, "RPUSH", isPausedOrMaxed, jobId)
425
446
  rcall("XADD", eventStreamKey, "*", "event",
426
447
  "waiting", "jobId", jobId, 'prev', 'active')
427
448
  -- Emit the stalled event
@@ -1 +1 @@
1
- {"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBA2bS,CAAC;AAC1B,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAgdS,CAAC;AAC1B,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -66,12 +66,21 @@ end
66
66
  Function to check for the meta.paused key to decide if we are paused or not
67
67
  (since an empty list and !EXISTS are not really the same).
68
68
  ]]
69
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
70
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
71
- return waitKey, false
72
- else
69
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
70
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
71
+ if queueAttributes[1] then
73
72
  return pausedKey, true
73
+ else
74
+ if queueAttributes[2] then
75
+ local activeCount = rcall("LLEN", activeKey)
76
+ if activeCount >= tonumber(queueAttributes[2]) then
77
+ return waitKey, true
78
+ else
79
+ return waitKey, false
80
+ end
81
+ end
74
82
  end
83
+ return waitKey, false
75
84
  end
76
85
  --[[
77
86
  Function to move job from prioritized state to active.
@@ -134,24 +143,25 @@ end
134
143
  --[[
135
144
  Add marker if needed when a job is available.
136
145
  ]]
137
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
138
- if not isPaused then
146
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
147
+ if not isPausedOrMaxed then
139
148
  rcall("ZADD", markerKey, 0, "0")
140
149
  end
141
150
  end
142
- local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
151
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
143
152
  rcall(pushCmd, targetKey, jobId)
144
- addBaseMarkerIfNeeded(markerKey, isPaused)
153
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
145
154
  end
146
155
  --[[
147
156
  Function to add job considering priority.
148
157
  ]]
149
158
  -- Includes
150
- local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
159
+ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
160
+ isPausedOrMaxed)
151
161
  local prioCounter = rcall("INCR", priorityCounterKey)
152
162
  local score = priority * 0x100000000 + prioCounter % 0x100000000
153
163
  rcall("ZADD", prioritizedKey, score, jobId)
154
- addBaseMarkerIfNeeded(markerKey, isPaused)
164
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
155
165
  end
156
166
  -- Try to get as much as 1000 jobs at once
157
167
  local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,
@@ -177,17 +187,17 @@ local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedK
177
187
  end
178
188
  end
179
189
  end
180
- local target, paused = getTargetQueueList(KEYS[9], waitKey, KEYS[8])
190
+ local target, isPausedOrMaxed = getTargetQueueList(KEYS[9], activeKey, waitKey, KEYS[8])
181
191
  -- Check if there are delayed jobs that we can move to wait.
182
192
  local markerKey = KEYS[11]
183
193
  promoteDelayedJobs(delayedKey, markerKey, target, KEYS[3], eventStreamKey, ARGV[1],
184
- ARGV[2], KEYS[10], paused)
194
+ ARGV[2], KEYS[10], isPausedOrMaxed)
185
195
  local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
186
196
  local expireTime = getRateLimitTTL(maxJobs, rateLimiterKey)
187
197
  -- Check if we are rate limited first.
188
198
  if expireTime > 0 then return {0, 0, expireTime, 0} end
189
- -- paused queue
190
- if paused then return {0, 0, 0, 0} end
199
+ -- paused or maxed queue
200
+ if isPausedOrMaxed then return {0, 0, 0, 0} end
191
201
  -- no job ID, try non-blocking move from wait to active
192
202
  local jobId = rcall("RPOPLPUSH", waitKey, activeKey)
193
203
  -- Markers in waitlist DEPRECATED in v5: Will be completely removed in v6.
@@ -1 +1 @@
1
- {"version":3,"file":"moveToActive-11.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-11.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmNf,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
1
+ {"version":3,"file":"moveToActive-11.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-11.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Nf,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
@@ -83,13 +83,6 @@ local function getOrSetMaxEvents(metaKey)
83
83
  end
84
84
  return maxEvents
85
85
  end
86
- --[[
87
- Function to check for the meta.paused key to decide if we are paused or not
88
- (since an empty list and !EXISTS are not really the same).
89
- ]]
90
- local function isQueuePaused(queueMetaKey)
91
- return rcall("HEXISTS", queueMetaKey, "paused") == 1
92
- end
93
86
  local function removeLock(jobKey, stalledKey, token, jobId)
94
87
  if token ~= "0" then
95
88
  local lockKey = jobKey .. ':lock'
@@ -132,11 +125,8 @@ if rcall("EXISTS", jobKey) == 1 then
132
125
  rcall("XADD", KEYS[6], "MAXLEN", "~", maxEvents, "*", "event", "delayed",
133
126
  "jobId", jobId, "delay", delayedTimestamp)
134
127
  -- Check if we need to push a marker job to wake up sleeping workers.
135
- local isPaused = isQueuePaused(metaKey)
136
- if not isPaused then
137
- local markerKey = KEYS[1]
138
- addDelayMarkerIfNeeded(markerKey, delayedKey)
139
- end
128
+ local markerKey = KEYS[1]
129
+ addDelayMarkerIfNeeded(markerKey, delayedKey)
140
130
  return 0
141
131
  else
142
132
  return -1
@@ -1 +1 @@
1
- {"version":3,"file":"moveToDelayed-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToDelayed-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+If,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"moveToDelayed-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToDelayed-8.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqIf,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -132,12 +132,21 @@ end
132
132
  Function to check for the meta.paused key to decide if we are paused or not
133
133
  (since an empty list and !EXISTS are not really the same).
134
134
  ]]
135
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
136
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
137
- return waitKey, false
138
- else
135
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
136
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
137
+ if queueAttributes[1] then
139
138
  return pausedKey, true
139
+ else
140
+ if queueAttributes[2] then
141
+ local activeCount = rcall("LLEN", activeKey)
142
+ if activeCount >= tonumber(queueAttributes[2]) then
143
+ return waitKey, true
144
+ else
145
+ return waitKey, false
146
+ end
147
+ end
140
148
  end
149
+ return waitKey, false
141
150
  end
142
151
  --[[
143
152
  Function to move job from prioritized state to active.
@@ -178,31 +187,41 @@ end
178
187
  --[[
179
188
  Add marker if needed when a job is available.
180
189
  ]]
181
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
182
- if not isPaused then
190
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
191
+ if not isPausedOrMaxed then
183
192
  rcall("ZADD", markerKey, 0, "0")
184
193
  end
185
194
  end
186
- local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
195
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
187
196
  rcall(pushCmd, targetKey, jobId)
188
- addBaseMarkerIfNeeded(markerKey, isPaused)
197
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
189
198
  end
190
199
  --[[
191
200
  Function to add job considering priority.
192
201
  ]]
193
202
  -- Includes
194
- local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
203
+ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
204
+ isPausedOrMaxed)
195
205
  local prioCounter = rcall("INCR", priorityCounterKey)
196
206
  local score = priority * 0x100000000 + prioCounter % 0x100000000
197
207
  rcall("ZADD", prioritizedKey, score, jobId)
198
- addBaseMarkerIfNeeded(markerKey, isPaused)
208
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
199
209
  end
200
210
  --[[
201
- Function to check for the meta.paused key to decide if we are paused or not
211
+ Function to check if queue is paused or maxed
202
212
  (since an empty list and !EXISTS are not really the same).
203
213
  ]]
204
- local function isQueuePaused(queueMetaKey)
205
- return rcall("HEXISTS", queueMetaKey, "paused") == 1
214
+ local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
215
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
216
+ if queueAttributes[1] then
217
+ return true
218
+ else
219
+ if queueAttributes[2] then
220
+ local activeCount = rcall("LLEN", activeKey)
221
+ return activeCount >= tonumber(queueAttributes[2])
222
+ end
223
+ end
224
+ return false
206
225
  end
207
226
  local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
208
227
  parentKey, parentId, timestamp)
@@ -212,6 +231,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
212
231
  rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
213
232
  local parentWaitKey = parentQueueKey .. ":wait"
214
233
  local parentPausedKey = parentQueueKey .. ":paused"
234
+ local parentActiveKey = parentQueueKey .. ":active"
215
235
  local parentMetaKey = parentQueueKey .. ":meta"
216
236
  local parentMarkerKey = parentQueueKey .. ":marker"
217
237
  local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
@@ -227,15 +247,16 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
227
247
  addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
228
248
  else
229
249
  if priority == 0 then
230
- local parentTarget, isParentPaused =
231
- getTargetQueueList(parentMetaKey, parentWaitKey,
250
+ local parentTarget, isParentPausedOrMaxed =
251
+ getTargetQueueList(parentMetaKey, parentActiveKey, parentWaitKey,
232
252
  parentPausedKey)
233
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPaused, parentId)
253
+ addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
254
+ parentId)
234
255
  else
235
- local isPaused = isQueuePaused(parentMetaKey)
256
+ local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
236
257
  addJobWithPriority(parentMarkerKey,
237
258
  parentQueueKey .. ":prioritized", priority,
238
- parentId, parentQueueKey .. ":pc", isPaused)
259
+ parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
239
260
  end
240
261
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
241
262
  "jobId", parentId, "prev", "waiting-children")
@@ -369,9 +390,9 @@ local getJobKeyPrefix = function (jobKey, jobId)
369
390
  return string.sub(jobKey, 0, #jobKey - #jobId)
370
391
  end
371
392
  local function moveParentToWait(parentPrefix, parentId, emitEvent)
372
- local parentTarget, isPaused = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "wait",
373
- parentPrefix .. "paused")
374
- addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPaused, parentId)
393
+ local parentTarget, isPausedOrMaxed = getTargetQueueList(parentPrefix .. "meta", parentPrefix .. "active",
394
+ parentPrefix .. "wait", parentPrefix .. "paused")
395
+ addJobInTargetList(parentTarget, parentPrefix .. "marker", "RPUSH", isPausedOrMaxed, parentId)
375
396
  if emitEvent then
376
397
  local parentEventStream = parentPrefix .. "events"
377
398
  rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
@@ -618,16 +639,16 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
618
639
  -- Try to get next job to avoid an extra roundtrip if the queue is not closing,
619
640
  -- and not rate limited.
620
641
  if (ARGV[6] == "1") then
621
- local target, paused = getTargetQueueList(metaKey, KEYS[1], KEYS[8])
642
+ local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[2], KEYS[1], KEYS[8])
622
643
  -- Check if there are delayed jobs that can be promoted
623
644
  promoteDelayedJobs(KEYS[7], KEYS[14], target, KEYS[3], eventStreamKey, ARGV[7],
624
- timestamp, KEYS[10], paused)
645
+ timestamp, KEYS[10], isPausedOrMaxed)
625
646
  local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
626
647
  -- Check if we are rate limited first.
627
648
  local expireTime = getRateLimitTTL(maxJobs, KEYS[6])
628
649
  if expireTime > 0 then return {0, 0, expireTime, 0} end
629
- -- paused queue
630
- if paused then return {0, 0, 0, 0} end
650
+ -- paused or maxed queue
651
+ if isPausedOrMaxed then return {0, 0, 0, 0} end
631
652
  jobId = rcall("RPOPLPUSH", KEYS[1], KEYS[2])
632
653
  if jobId then
633
654
  -- Markers in waitlist DEPRECATED in v5: Remove in v6.
@@ -1 +1 @@
1
- {"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuqBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
1
+ {"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4rBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}