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
@@ -4,6 +4,7 @@
4
4
 
5
5
  Input:
6
6
  KEYS[1] queue prefix
7
+ KEYS[2] meta key
7
8
 
8
9
  ARGV[1] jobId
9
10
  ARGV[2] remove children
@@ -66,7 +67,7 @@ local function removeJob( prefix, jobId, parentKey, removeChildren)
66
67
  local prev = removeJobFromAnyState(prefix, jobId)
67
68
 
68
69
  if removeJobKeys(jobKey) > 0 then
69
- local maxEvents = getOrSetMaxEvents(prefix .. "meta")
70
+ local maxEvents = getOrSetMaxEvents(KEYS[2])
70
71
  rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",
71
72
  "jobId", jobId, "prev", prev)
72
73
  end
@@ -5,9 +5,10 @@
5
5
  KEYS[1] repeat jobs key
6
6
  KEYS[2] delayed jobs key
7
7
 
8
- ARGV[1] repeat job id
9
- ARGV[2] repeat job key
10
- ARGV[3] queue key
8
+ ARGV[1] old repeat job id
9
+ ARGV[2] options concat
10
+ ARGV[3] repeat job key
11
+ ARGV[4] prefix key
11
12
 
12
13
  Output:
13
14
  0 - OK
@@ -19,12 +20,16 @@
19
20
  local rcall = redis.call
20
21
  local millis = rcall("ZSCORE", KEYS[1], ARGV[2])
21
22
 
22
- if(millis) then
23
+ -- Includes
24
+ --- @include "includes/removeJobKeys"
25
+
26
+ -- legacy removal TODO: remove in next breaking change
27
+ if millis then
23
28
  -- Delete next programmed job.
24
29
  local repeatJobId = ARGV[1] .. millis
25
30
  if(rcall("ZREM", KEYS[2], repeatJobId) == 1) then
26
- rcall("DEL", ARGV[3] .. repeatJobId)
27
- rcall("XADD", ARGV[3] .. "events", "*", "event", "removed", "jobId", repeatJobId, "prev", "delayed");
31
+ removeJobKeys(ARGV[4] .. repeatJobId)
32
+ rcall("XADD", ARGV[4] .. "events", "*", "event", "removed", "jobId", repeatJobId, "prev", "delayed");
28
33
  end
29
34
  end
30
35
 
@@ -32,4 +37,20 @@ if(rcall("ZREM", KEYS[1], ARGV[2]) == 1) then
32
37
  return 0
33
38
  end
34
39
 
40
+ -- new removal
41
+ millis = rcall("ZSCORE", KEYS[1], ARGV[3])
42
+
43
+ if millis then
44
+ -- Delete next programmed job.
45
+ local repeatJobId = "repeat:" .. ARGV[3] .. ":" .. millis
46
+ if(rcall("ZREM", KEYS[2], repeatJobId) == 1) then
47
+ removeJobKeys(ARGV[4] .. repeatJobId)
48
+ rcall("XADD", ARGV[4] .. "events", "*", "event", "removed", "jobId", repeatJobId, "prev", "delayed");
49
+ end
50
+ end
51
+
52
+ if(rcall("ZREM", KEYS[1], ARGV[3]) == 1) then
53
+ return 0
54
+ end
55
+
35
56
  return 1
@@ -8,7 +8,8 @@
8
8
  KEYS[4] wait key
9
9
  KEYS[5] meta
10
10
  KEYS[6] paused key
11
- KEYS[7] marker key
11
+ KEYS[7] active key
12
+ KEYS[8] marker key
12
13
 
13
14
  ARGV[1] job.id
14
15
  ARGV[2] (job.opts.lifo ? 'R' : 'L') + 'PUSH'
@@ -32,8 +33,8 @@ if rcall("EXISTS", KEYS[1]) == 1 then
32
33
  if (rcall("ZREM", KEYS[3], jobId) == 1) then
33
34
  rcall("HDEL", KEYS[1], "finishedOn", "processedOn", ARGV[3])
34
35
 
35
- local target, isPaused = getTargetQueueList(KEYS[5], KEYS[4], KEYS[6])
36
- addJobInTargetList(target, KEYS[7], ARGV[2], isPaused, jobId)
36
+ local target, isPausedOrMaxed = getTargetQueueList(KEYS[5], KEYS[7], KEYS[4], KEYS[6])
37
+ addJobInTargetList(target, KEYS[8], ARGV[2], isPausedOrMaxed, jobId)
37
38
 
38
39
  local maxEvents = getOrSetMaxEvents(KEYS[5])
39
40
  -- Emit waiting event
@@ -38,13 +38,14 @@ local rcall = redis.call
38
38
  --- @include "includes/getTargetQueueList"
39
39
  --- @include "includes/promoteDelayedJobs"
40
40
  --- @include "includes/removeLock"
41
+ --- @include "includes/isQueuePausedOrMaxed"
41
42
 
42
- local target, paused = getTargetQueueList(KEYS[5], KEYS[2], KEYS[3])
43
+ local target, isPausedOrMaxed = getTargetQueueList(KEYS[5], KEYS[1], KEYS[2], KEYS[3])
43
44
  local markerKey = KEYS[10]
44
45
 
45
46
  -- Check if there are delayed jobs that we can move to wait.
46
47
  -- test example: when there are delayed jobs between retries
47
- promoteDelayedJobs(KEYS[7], markerKey, target, KEYS[8], KEYS[6], ARGV[1], ARGV[2], KEYS[9], paused)
48
+ promoteDelayedJobs(KEYS[7], markerKey, target, KEYS[8], KEYS[6], ARGV[1], ARGV[2], KEYS[9], isPausedOrMaxed)
48
49
 
49
50
  if rcall("EXISTS", KEYS[4]) == 1 then
50
51
  local errorCode = removeLock(KEYS[4], KEYS[11], ARGV[5], ARGV[4])
@@ -57,11 +58,14 @@ if rcall("EXISTS", KEYS[4]) == 1 then
57
58
 
58
59
  local priority = tonumber(rcall("HGET", KEYS[4], "priority")) or 0
59
60
 
61
+ --need to re-evaluate after removing job from active
62
+ isPausedOrMaxed = isQueuePausedOrMaxed(KEYS[5], KEYS[1])
63
+
60
64
  -- Standard or priority add
61
65
  if priority == 0 then
62
- addJobInTargetList(target, KEYS[10], ARGV[3], paused, ARGV[4])
66
+ addJobInTargetList(target, markerKey, ARGV[3], isPausedOrMaxed, ARGV[4])
63
67
  else
64
- addJobWithPriority(markerKey, KEYS[8], priority, ARGV[4], KEYS[9], paused)
68
+ addJobWithPriority(markerKey, KEYS[8], priority, ARGV[4], KEYS[9], isPausedOrMaxed)
65
69
  end
66
70
 
67
71
  rcall("HINCRBY", KEYS[4], "atm", 1)
@@ -20,6 +20,7 @@ tslib_1.__exportStar(require("./rate-limiter-options"), exports);
20
20
  tslib_1.__exportStar(require("./redis-options"), exports);
21
21
  tslib_1.__exportStar(require("./redis-streams"), exports);
22
22
  tslib_1.__exportStar(require("./repeatable-job"), exports);
23
+ tslib_1.__exportStar(require("./repeatable-options"), exports);
23
24
  tslib_1.__exportStar(require("./repeat-options"), exports);
24
25
  tslib_1.__exportStar(require("./sandboxed-job-processor"), exports);
25
26
  tslib_1.__exportStar(require("./sandboxed-job"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,4DAAkC;AAClC,6DAAmC;AACnC,0DAAgC;AAChC,uDAA6B;AAC7B,qDAA2B;AAC3B,2DAAiC;AACjC,qDAA2B;AAC3B,sDAA4B;AAC5B,4DAAkC;AAClC,oDAA0B;AAC1B,wDAA8B;AAC9B,2DAAiC;AACjC,mDAAyB;AACzB,0DAAgC;AAChC,iEAAuC;AACvC,0DAAgC;AAChC,0DAAgC;AAChC,2DAAiC;AACjC,2DAAiC;AACjC,oEAA0C;AAC1C,0DAAgC;AAChC,2DAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,4DAAkC;AAClC,6DAAmC;AACnC,0DAAgC;AAChC,uDAA6B;AAC7B,qDAA2B;AAC3B,2DAAiC;AACjC,qDAA2B;AAC3B,sDAA4B;AAC5B,4DAAkC;AAClC,oDAA0B;AAC1B,wDAA8B;AAC9B,2DAAiC;AACjC,mDAAyB;AACzB,0DAAgC;AAChC,iEAAuC;AACvC,0DAAgC;AAChC,0DAAgC;AAChC,2DAAiC;AACjC,+DAAqC;AACrC,2DAAiC;AACjC,oEAA0C;AAC1C,0DAAgC;AAChC,2DAAiC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=repeatable-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repeatable-options.js","sourceRoot":"","sources":["../../../src/interfaces/repeatable-options.ts"],"names":[],"mappings":""}
@@ -131,42 +131,61 @@ end
131
131
  --[[
132
132
  Add marker if needed when a job is available.
133
133
  ]]
134
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
135
- if not isPaused then
134
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
135
+ if not isPausedOrMaxed then
136
136
  rcall("ZADD", markerKey, 0, "0")
137
137
  end
138
138
  end
139
- local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
139
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
140
140
  rcall(pushCmd, targetKey, jobId)
141
- addBaseMarkerIfNeeded(markerKey, isPaused)
141
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
142
142
  end
143
143
  --[[
144
144
  Function to add job considering priority.
145
145
  ]]
146
146
  -- Includes
147
- local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
147
+ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
148
+ isPausedOrMaxed)
148
149
  local prioCounter = rcall("INCR", priorityCounterKey)
149
150
  local score = priority * 0x100000000 + prioCounter % 0x100000000
150
151
  rcall("ZADD", prioritizedKey, score, jobId)
151
- addBaseMarkerIfNeeded(markerKey, isPaused)
152
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
152
153
  end
153
154
  --[[
154
- Function to check for the meta.paused key to decide if we are paused or not
155
+ Function to check if queue is paused or maxed
155
156
  (since an empty list and !EXISTS are not really the same).
156
157
  ]]
157
- local function isQueuePaused(queueMetaKey)
158
- return rcall("HEXISTS", queueMetaKey, "paused") == 1
158
+ local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
159
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
160
+ if queueAttributes[1] then
161
+ return true
162
+ else
163
+ if queueAttributes[2] then
164
+ local activeCount = rcall("LLEN", activeKey)
165
+ return activeCount >= tonumber(queueAttributes[2])
166
+ end
167
+ end
168
+ return false
159
169
  end
160
170
  --[[
161
171
  Function to check for the meta.paused key to decide if we are paused or not
162
172
  (since an empty list and !EXISTS are not really the same).
163
173
  ]]
164
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
165
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
166
- return waitKey, false
167
- else
174
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
175
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
176
+ if queueAttributes[1] then
168
177
  return pausedKey, true
178
+ else
179
+ if queueAttributes[2] then
180
+ local activeCount = rcall("LLEN", activeKey)
181
+ if activeCount >= tonumber(queueAttributes[2]) then
182
+ return waitKey, true
183
+ else
184
+ return waitKey, false
185
+ end
186
+ end
169
187
  end
188
+ return waitKey, false
170
189
  end
171
190
  local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
172
191
  parentKey, parentId, timestamp)
@@ -176,6 +195,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
176
195
  rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
177
196
  local parentWaitKey = parentQueueKey .. ":wait"
178
197
  local parentPausedKey = parentQueueKey .. ":paused"
198
+ local parentActiveKey = parentQueueKey .. ":active"
179
199
  local parentMetaKey = parentQueueKey .. ":meta"
180
200
  local parentMarkerKey = parentQueueKey .. ":marker"
181
201
  local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
@@ -191,15 +211,16 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
191
211
  addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
192
212
  else
193
213
  if priority == 0 then
194
- local parentTarget, isParentPaused =
195
- getTargetQueueList(parentMetaKey, parentWaitKey,
214
+ local parentTarget, isParentPausedOrMaxed =
215
+ getTargetQueueList(parentMetaKey, parentActiveKey, parentWaitKey,
196
216
  parentPausedKey)
197
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPaused, parentId)
217
+ addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
218
+ parentId)
198
219
  else
199
- local isPaused = isQueuePaused(parentMetaKey)
220
+ local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
200
221
  addJobWithPriority(parentMarkerKey,
201
222
  parentQueueKey .. ":prioritized", priority,
202
- parentId, parentQueueKey .. ":pc", isPaused)
223
+ parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
203
224
  end
204
225
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
205
226
  "jobId", parentId, "prev", "waiting-children")
@@ -1 +1 @@
1
- {"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmTf,CAAC;AACW,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwUf,CAAC;AACW,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -103,42 +103,61 @@ end
103
103
  --[[
104
104
  Add marker if needed when a job is available.
105
105
  ]]
106
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
107
- if not isPaused then
106
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
107
+ if not isPausedOrMaxed then
108
108
  rcall("ZADD", markerKey, 0, "0")
109
109
  end
110
110
  end
111
- local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
111
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
112
112
  rcall(pushCmd, targetKey, jobId)
113
- addBaseMarkerIfNeeded(markerKey, isPaused)
113
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
114
114
  end
115
115
  --[[
116
116
  Function to add job considering priority.
117
117
  ]]
118
118
  -- Includes
119
- local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
119
+ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
120
+ isPausedOrMaxed)
120
121
  local prioCounter = rcall("INCR", priorityCounterKey)
121
122
  local score = priority * 0x100000000 + prioCounter % 0x100000000
122
123
  rcall("ZADD", prioritizedKey, score, jobId)
123
- addBaseMarkerIfNeeded(markerKey, isPaused)
124
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
124
125
  end
125
126
  --[[
126
- Function to check for the meta.paused key to decide if we are paused or not
127
+ Function to check if queue is paused or maxed
127
128
  (since an empty list and !EXISTS are not really the same).
128
129
  ]]
129
- local function isQueuePaused(queueMetaKey)
130
- return rcall("HEXISTS", queueMetaKey, "paused") == 1
130
+ local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
131
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
132
+ if queueAttributes[1] then
133
+ return true
134
+ else
135
+ if queueAttributes[2] then
136
+ local activeCount = rcall("LLEN", activeKey)
137
+ return activeCount >= tonumber(queueAttributes[2])
138
+ end
139
+ end
140
+ return false
131
141
  end
132
142
  --[[
133
143
  Function to check for the meta.paused key to decide if we are paused or not
134
144
  (since an empty list and !EXISTS are not really the same).
135
145
  ]]
136
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
137
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
138
- return waitKey, false
139
- else
146
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
147
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
148
+ if queueAttributes[1] then
140
149
  return pausedKey, true
150
+ else
151
+ if queueAttributes[2] then
152
+ local activeCount = rcall("LLEN", activeKey)
153
+ if activeCount >= tonumber(queueAttributes[2]) then
154
+ return waitKey, true
155
+ else
156
+ return waitKey, false
157
+ end
158
+ end
141
159
  end
160
+ return waitKey, false
142
161
  end
143
162
  local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
144
163
  parentKey, parentId, timestamp)
@@ -148,6 +167,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
148
167
  rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
149
168
  local parentWaitKey = parentQueueKey .. ":wait"
150
169
  local parentPausedKey = parentQueueKey .. ":paused"
170
+ local parentActiveKey = parentQueueKey .. ":active"
151
171
  local parentMetaKey = parentQueueKey .. ":meta"
152
172
  local parentMarkerKey = parentQueueKey .. ":marker"
153
173
  local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
@@ -163,15 +183,16 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
163
183
  addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
164
184
  else
165
185
  if priority == 0 then
166
- local parentTarget, isParentPaused =
167
- getTargetQueueList(parentMetaKey, parentWaitKey,
186
+ local parentTarget, isParentPausedOrMaxed =
187
+ getTargetQueueList(parentMetaKey, parentActiveKey, parentWaitKey,
168
188
  parentPausedKey)
169
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPaused, parentId)
189
+ addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
190
+ parentId)
170
191
  else
171
- local isPaused = isQueuePaused(parentMetaKey)
192
+ local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
172
193
  addJobWithPriority(parentMarkerKey,
173
194
  parentQueueKey .. ":prioritized", priority,
174
- parentId, parentQueueKey .. ":pc", isPaused)
195
+ parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
175
196
  end
176
197
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
177
198
  "jobId", parentId, "prev", "waiting-children")
@@ -1 +1 @@
1
- {"version":3,"file":"addParentJob-4.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkRf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"addParentJob-4.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuSf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -12,8 +12,9 @@ const content = `--[[
12
12
  KEYS[3] 'id'
13
13
  KEYS[4] 'prioritized'
14
14
  KEYS[5] 'completed'
15
- KEYS[6] events stream key
16
- KEYS[7] 'pc' priority counter
15
+ KEYS[6] 'active'
16
+ KEYS[7] events stream key
17
+ KEYS[8] 'pc' priority counter
17
18
  ARGV[1] msgpacked arguments array
18
19
  [1] key prefix,
19
20
  [2] custom id (will not generate one automatically)
@@ -34,8 +35,9 @@ local metaKey = KEYS[2]
34
35
  local idKey = KEYS[3]
35
36
  local priorityKey = KEYS[4]
36
37
  local completedKey = KEYS[5]
37
- local eventsKey = KEYS[6]
38
- local priorityCounterKey = KEYS[7]
38
+ local activeKey = KEYS[6]
39
+ local eventsKey = KEYS[7]
40
+ local priorityCounterKey = KEYS[8]
39
41
  local jobId
40
42
  local jobIdKey
41
43
  local rcall = redis.call
@@ -54,16 +56,17 @@ local parentData
54
56
  --[[
55
57
  Add marker if needed when a job is available.
56
58
  ]]
57
- local function addBaseMarkerIfNeeded(markerKey, isPaused)
58
- if not isPaused then
59
+ local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
60
+ if not isPausedOrMaxed then
59
61
  rcall("ZADD", markerKey, 0, "0")
60
62
  end
61
63
  end
62
- local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
64
+ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
65
+ isPausedOrMaxed)
63
66
  local prioCounter = rcall("INCR", priorityCounterKey)
64
67
  local score = priority * 0x100000000 + prioCounter % 0x100000000
65
68
  rcall("ZADD", prioritizedKey, score, jobId)
66
- addBaseMarkerIfNeeded(markerKey, isPaused)
69
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
67
70
  end
68
71
  --[[
69
72
  Function to store a job
@@ -148,27 +151,45 @@ end
148
151
  Function to add job in target list and add marker if needed.
149
152
  ]]
150
153
  -- Includes
151
- local function addJobInTargetList(targetKey, markerKey, pushCmd, isPaused, jobId)
154
+ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId)
152
155
  rcall(pushCmd, targetKey, jobId)
153
- addBaseMarkerIfNeeded(markerKey, isPaused)
156
+ addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
154
157
  end
155
158
  --[[
156
- Function to check for the meta.paused key to decide if we are paused or not
159
+ Function to check if queue is paused or maxed
157
160
  (since an empty list and !EXISTS are not really the same).
158
161
  ]]
159
- local function isQueuePaused(queueMetaKey)
160
- return rcall("HEXISTS", queueMetaKey, "paused") == 1
162
+ local function isQueuePausedOrMaxed(queueMetaKey, activeKey)
163
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
164
+ if queueAttributes[1] then
165
+ return true
166
+ else
167
+ if queueAttributes[2] then
168
+ local activeCount = rcall("LLEN", activeKey)
169
+ return activeCount >= tonumber(queueAttributes[2])
170
+ end
171
+ end
172
+ return false
161
173
  end
162
174
  --[[
163
175
  Function to check for the meta.paused key to decide if we are paused or not
164
176
  (since an empty list and !EXISTS are not really the same).
165
177
  ]]
166
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
167
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
168
- return waitKey, false
169
- else
178
+ local function getTargetQueueList(queueMetaKey, activeKey, waitKey, pausedKey)
179
+ local queueAttributes = rcall("HMGET", queueMetaKey, "paused", "concurrency")
180
+ if queueAttributes[1] then
170
181
  return pausedKey, true
182
+ else
183
+ if queueAttributes[2] then
184
+ local activeCount = rcall("LLEN", activeKey)
185
+ if activeCount >= tonumber(queueAttributes[2]) then
186
+ return waitKey, true
187
+ else
188
+ return waitKey, false
189
+ end
190
+ end
171
191
  end
192
+ return waitKey, false
172
193
  end
173
194
  local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
174
195
  parentKey, parentId, timestamp)
@@ -178,6 +199,7 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
178
199
  rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
179
200
  local parentWaitKey = parentQueueKey .. ":wait"
180
201
  local parentPausedKey = parentQueueKey .. ":paused"
202
+ local parentActiveKey = parentQueueKey .. ":active"
181
203
  local parentMetaKey = parentQueueKey .. ":meta"
182
204
  local parentMarkerKey = parentQueueKey .. ":marker"
183
205
  local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
@@ -193,15 +215,16 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
193
215
  addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
194
216
  else
195
217
  if priority == 0 then
196
- local parentTarget, isParentPaused =
197
- getTargetQueueList(parentMetaKey, parentWaitKey,
218
+ local parentTarget, isParentPausedOrMaxed =
219
+ getTargetQueueList(parentMetaKey, parentActiveKey, parentWaitKey,
198
220
  parentPausedKey)
199
- addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPaused, parentId)
221
+ addJobInTargetList(parentTarget, parentMarkerKey, "RPUSH", isParentPausedOrMaxed,
222
+ parentId)
200
223
  else
201
- local isPaused = isQueuePaused(parentMetaKey)
224
+ local isPausedOrMaxed = isQueuePausedOrMaxed(parentMetaKey, parentActiveKey)
202
225
  addJobWithPriority(parentMarkerKey,
203
226
  parentQueueKey .. ":prioritized", priority,
204
- parentId, parentQueueKey .. ":pc", isPaused)
227
+ parentId, parentQueueKey .. ":pc", isPausedOrMaxed)
205
228
  end
206
229
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
207
230
  "jobId", parentId, "prev", "waiting-children")
@@ -273,8 +296,8 @@ local delay, priority = storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2],
273
296
  opts, timestamp, parentKey, parentData,
274
297
  repeatJobKey)
275
298
  -- Add the job to the prioritized set
276
- local isPause = isQueuePaused(metaKey)
277
- addJobWithPriority( KEYS[1], priorityKey, priority, jobId, priorityCounterKey, isPause)
299
+ local isPausedOrMaxed = isQueuePausedOrMaxed(metaKey, activeKey)
300
+ addJobWithPriority( KEYS[1], priorityKey, priority, jobId, priorityCounterKey, isPausedOrMaxed)
278
301
  -- Emit waiting event
279
302
  rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",
280
303
  "jobId", jobId)
@@ -287,6 +310,6 @@ return jobId .. "" -- convert to string
287
310
  exports.addPrioritizedJob = {
288
311
  name: 'addPrioritizedJob',
289
312
  content,
290
- keys: 7,
313
+ keys: 8,
291
314
  };
292
- //# sourceMappingURL=addPrioritizedJob-7.js.map
315
+ //# sourceMappingURL=addPrioritizedJob-8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addPrioritizedJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiTf,CAAC;AACW,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,mBAAmB;IACzB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addRepeatableJob = void 0;
4
+ const content = `--[[
5
+ Adds a repeatable job
6
+ Input:
7
+ KEYS[1] 'repeat' key
8
+ KEYS[2] custom key
9
+ ARGV[1] next milliseconds
10
+ ARGV[2] msgpacked options
11
+ [1] name
12
+ [2] tz?
13
+ [3] patten?
14
+ [4] endDate?
15
+ [5] every?
16
+ ARGV[3] legacy custom key TODO: remove this logic in next breaking change
17
+ ARGV[4] skipCheckExists
18
+ Output:
19
+ repeatableKey - OK
20
+ ]]
21
+ local rcall = redis.call
22
+ local repeatKey = KEYS[1]
23
+ local customKey = KEYS[2]
24
+ local legacyCustomKey = ARGV[3]
25
+ local nextMilli = ARGV[1]
26
+ local function storeRepeatableJob(repeatKey, customKey, nextMilli, rawOpts)
27
+ rcall("ZADD", repeatKey, nextMilli, customKey)
28
+ local opts = cmsgpack.unpack(rawOpts)
29
+ local optionalValues = {}
30
+ if opts['tz'] then
31
+ table.insert(optionalValues, "tz")
32
+ table.insert(optionalValues, opts['tz'])
33
+ end
34
+ if opts['pattern'] then
35
+ table.insert(optionalValues, "pattern")
36
+ table.insert(optionalValues, opts['pattern'])
37
+ end
38
+ if opts['endDate'] then
39
+ table.insert(optionalValues, "endDate")
40
+ table.insert(optionalValues, opts['endDate'])
41
+ end
42
+ if opts['every'] then
43
+ table.insert(optionalValues, "every")
44
+ table.insert(optionalValues, opts['every'])
45
+ end
46
+ rcall("HMSET", repeatKey .. ":" .. customKey, "name", opts['name'],
47
+ unpack(optionalValues))
48
+ return customKey
49
+ end
50
+ if ARGV[4] == '0' then
51
+ if rcall("ZSCORE", repeatKey, legacyCustomKey) ~= false then
52
+ rcall("ZADD", repeatKey, nextMilli, legacyCustomKey)
53
+ return legacyCustomKey
54
+ elseif rcall("ZSCORE", repeatKey, customKey) ~= false then
55
+ return storeRepeatableJob(repeatKey, customKey, nextMilli, ARGV[2])
56
+ end
57
+ else
58
+ return storeRepeatableJob(repeatKey, customKey, nextMilli, ARGV[2])
59
+ end
60
+ return ''`;
61
+ exports.addRepeatableJob = {
62
+ name: 'addRepeatableJob',
63
+ content,
64
+ keys: 2,
65
+ };
66
+ //# sourceMappingURL=addRepeatableJob-2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addRepeatableJob-2.js","sourceRoot":"","sources":["../../../src/scripts/addRepeatableJob-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAwDN,CAAC;AACE,QAAA,gBAAgB,GAAG;IAC9B,IAAI,EAAE,kBAAkB;IACxB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}