bullmq 4.17.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/dist/cjs/classes/flow-producer.js +3 -10
  2. package/dist/cjs/classes/flow-producer.js.map +1 -1
  3. package/dist/cjs/classes/job.js +21 -11
  4. package/dist/cjs/classes/job.js.map +1 -1
  5. package/dist/cjs/classes/queue-base.js +2 -9
  6. package/dist/cjs/classes/queue-base.js.map +1 -1
  7. package/dist/cjs/classes/queue-events.js +3 -1
  8. package/dist/cjs/classes/queue-events.js.map +1 -1
  9. package/dist/cjs/classes/queue-keys.js +1 -0
  10. package/dist/cjs/classes/queue-keys.js.map +1 -1
  11. package/dist/cjs/classes/redis-connection.js +9 -7
  12. package/dist/cjs/classes/redis-connection.js.map +1 -1
  13. package/dist/cjs/classes/scripts.js +34 -34
  14. package/dist/cjs/classes/scripts.js.map +1 -1
  15. package/dist/cjs/classes/worker.js +27 -32
  16. package/dist/cjs/classes/worker.js.map +1 -1
  17. package/dist/cjs/commands/{addDelayedJob-7.lua → addDelayedJob-6.lua} +18 -22
  18. package/dist/cjs/commands/addParentJob-4.lua +0 -2
  19. package/dist/{esm/commands/addPrioritizedJob-8.lua → cjs/commands/addPrioritizedJob-7.lua} +18 -24
  20. package/dist/cjs/commands/{addStandardJob-6.lua → addStandardJob-7.lua} +6 -2
  21. package/dist/cjs/commands/changePriority-6.lua +57 -0
  22. package/dist/cjs/commands/getCounts-1.lua +1 -0
  23. package/dist/cjs/commands/getRanges-1.lua +1 -0
  24. package/dist/cjs/commands/includes/addDelayMarkerIfNeeded.lua +5 -19
  25. package/dist/cjs/commands/includes/addJobWithPriority.lua +3 -7
  26. package/dist/cjs/commands/includes/checkStalledJobs.lua +1 -1
  27. package/dist/cjs/commands/includes/isQueuePaused.lua +7 -0
  28. package/dist/cjs/commands/includes/moveParentToWaitIfNeeded.lua +39 -30
  29. package/dist/cjs/commands/includes/prepareJobForProcessing.lua +1 -1
  30. package/dist/cjs/commands/includes/promoteDelayedJobs.lua +7 -4
  31. package/dist/{esm/commands/moveToActive-10.lua → cjs/commands/moveToActive-11.lua} +18 -29
  32. package/dist/cjs/commands/moveToDelayed-7.lua +77 -0
  33. package/dist/cjs/commands/{moveToFinished-13.lua → moveToFinished-14.lua} +29 -22
  34. package/dist/cjs/commands/moveToWaitingChildren-4.lua +7 -4
  35. package/dist/cjs/commands/pause-7.lua +41 -0
  36. package/dist/cjs/commands/promote-8.lua +60 -0
  37. package/dist/cjs/commands/{retryJob-9.lua → retryJob-10.lua} +16 -11
  38. package/dist/cjs/scripts/{addDelayedJob-7.js → addDelayedJob-6.js} +77 -88
  39. package/dist/cjs/scripts/{moveToActive-10.js.map → addDelayedJob-6.js.map} +1 -1
  40. package/dist/cjs/scripts/addParentJob-4.js +51 -61
  41. package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
  42. package/dist/cjs/scripts/{addPrioritizedJob-8.js → addPrioritizedJob-7.js} +80 -93
  43. package/dist/cjs/scripts/addPrioritizedJob-7.js.map +1 -0
  44. package/dist/cjs/scripts/{addStandardJob-6.js → addStandardJob-7.js} +58 -63
  45. package/dist/cjs/scripts/addStandardJob-7.js.map +1 -0
  46. package/dist/cjs/scripts/changePriority-6.js +85 -0
  47. package/dist/cjs/scripts/changePriority-6.js.map +1 -0
  48. package/dist/cjs/scripts/getCounts-1.js +1 -0
  49. package/dist/cjs/scripts/getCounts-1.js.map +1 -1
  50. package/dist/cjs/scripts/getRanges-1.js +1 -0
  51. package/dist/cjs/scripts/getRanges-1.js.map +1 -1
  52. package/dist/cjs/scripts/index.js +10 -10
  53. package/dist/cjs/scripts/index.js.map +1 -1
  54. package/dist/cjs/scripts/moveStalledJobsToWait-8.js +1 -0
  55. package/dist/cjs/scripts/moveStalledJobsToWait-8.js.map +1 -1
  56. package/dist/cjs/scripts/{moveToActive-10.js → moveToActive-11.js} +30 -48
  57. package/dist/cjs/scripts/moveToActive-11.js.map +1 -0
  58. package/dist/cjs/scripts/moveToDelayed-7.js +103 -0
  59. package/dist/cjs/scripts/moveToDelayed-7.js.map +1 -0
  60. package/dist/cjs/scripts/{moveToFinished-13.js → moveToFinished-14.js} +89 -88
  61. package/dist/cjs/scripts/{moveToFinished-13.js.map → moveToFinished-14.js.map} +1 -1
  62. package/dist/cjs/scripts/moveToWaitingChildren-4.js +6 -3
  63. package/dist/cjs/scripts/moveToWaitingChildren-4.js.map +1 -1
  64. package/dist/cjs/scripts/pause-7.js +67 -0
  65. package/dist/cjs/scripts/pause-7.js.map +1 -0
  66. package/dist/cjs/scripts/promote-8.js +79 -0
  67. package/dist/cjs/scripts/promote-8.js.map +1 -0
  68. package/dist/cjs/scripts/{retryJob-9.js → retryJob-10.js} +26 -32
  69. package/dist/cjs/scripts/retryJob-10.js.map +1 -0
  70. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  71. package/dist/esm/classes/flow-producer.js +3 -10
  72. package/dist/esm/classes/flow-producer.js.map +1 -1
  73. package/dist/esm/classes/job.d.ts +5 -0
  74. package/dist/esm/classes/job.js +21 -11
  75. package/dist/esm/classes/job.js.map +1 -1
  76. package/dist/esm/classes/queue-base.js +2 -9
  77. package/dist/esm/classes/queue-base.js.map +1 -1
  78. package/dist/esm/classes/queue-events.js +3 -1
  79. package/dist/esm/classes/queue-events.js.map +1 -1
  80. package/dist/esm/classes/queue-keys.js +1 -0
  81. package/dist/esm/classes/queue-keys.js.map +1 -1
  82. package/dist/esm/classes/redis-connection.js +9 -7
  83. package/dist/esm/classes/redis-connection.js.map +1 -1
  84. package/dist/esm/classes/scripts.d.ts +4 -4
  85. package/dist/esm/classes/scripts.js +34 -34
  86. package/dist/esm/classes/scripts.js.map +1 -1
  87. package/dist/esm/classes/worker.d.ts +1 -1
  88. package/dist/esm/classes/worker.js +27 -32
  89. package/dist/esm/classes/worker.js.map +1 -1
  90. package/dist/esm/commands/{addDelayedJob-7.lua → addDelayedJob-6.lua} +18 -22
  91. package/dist/esm/commands/addParentJob-4.lua +0 -2
  92. package/dist/{cjs/commands/addPrioritizedJob-8.lua → esm/commands/addPrioritizedJob-7.lua} +18 -24
  93. package/dist/esm/commands/{addStandardJob-6.lua → addStandardJob-7.lua} +6 -2
  94. package/dist/esm/commands/changePriority-6.lua +57 -0
  95. package/dist/esm/commands/getCounts-1.lua +1 -0
  96. package/dist/esm/commands/getRanges-1.lua +1 -0
  97. package/dist/esm/commands/includes/addDelayMarkerIfNeeded.lua +5 -19
  98. package/dist/esm/commands/includes/addJobWithPriority.lua +3 -7
  99. package/dist/esm/commands/includes/checkStalledJobs.lua +1 -1
  100. package/dist/esm/commands/includes/isQueuePaused.lua +7 -0
  101. package/dist/esm/commands/includes/moveParentToWaitIfNeeded.lua +39 -30
  102. package/dist/esm/commands/includes/prepareJobForProcessing.lua +1 -1
  103. package/dist/esm/commands/includes/promoteDelayedJobs.lua +7 -4
  104. package/dist/{cjs/commands/moveToActive-10.lua → esm/commands/moveToActive-11.lua} +18 -29
  105. package/dist/esm/commands/moveToDelayed-7.lua +77 -0
  106. package/dist/esm/commands/{moveToFinished-13.lua → moveToFinished-14.lua} +29 -22
  107. package/dist/esm/commands/moveToWaitingChildren-4.lua +7 -4
  108. package/dist/esm/commands/pause-7.lua +41 -0
  109. package/dist/esm/commands/promote-8.lua +60 -0
  110. package/dist/esm/commands/{retryJob-9.lua → retryJob-10.lua} +16 -11
  111. package/dist/esm/interfaces/job-json.d.ts +4 -1
  112. package/dist/esm/interfaces/minimal-job.d.ts +3 -0
  113. package/dist/esm/interfaces/queue-options.d.ts +1 -1
  114. package/dist/esm/scripts/{addDelayedJob-7.js → addDelayedJob-6.js} +77 -88
  115. package/dist/esm/scripts/{moveToActive-10.js.map → addDelayedJob-6.js.map} +1 -1
  116. package/dist/esm/scripts/addParentJob-4.js +51 -61
  117. package/dist/esm/scripts/addParentJob-4.js.map +1 -1
  118. package/dist/esm/scripts/{addPrioritizedJob-8.js → addPrioritizedJob-7.js} +80 -93
  119. package/dist/esm/scripts/addPrioritizedJob-7.js.map +1 -0
  120. package/dist/esm/scripts/{addStandardJob-6.js → addStandardJob-7.js} +58 -63
  121. package/dist/esm/scripts/addStandardJob-7.js.map +1 -0
  122. package/dist/esm/scripts/changePriority-6.js +82 -0
  123. package/dist/esm/scripts/changePriority-6.js.map +1 -0
  124. package/dist/esm/scripts/getCounts-1.js +1 -0
  125. package/dist/esm/scripts/getCounts-1.js.map +1 -1
  126. package/dist/esm/scripts/getRanges-1.js +1 -0
  127. package/dist/esm/scripts/getRanges-1.js.map +1 -1
  128. package/dist/esm/scripts/index.d.ts +10 -10
  129. package/dist/esm/scripts/index.js +10 -10
  130. package/dist/esm/scripts/index.js.map +1 -1
  131. package/dist/esm/scripts/moveStalledJobsToWait-8.js +1 -0
  132. package/dist/esm/scripts/moveStalledJobsToWait-8.js.map +1 -1
  133. package/dist/esm/scripts/{moveToActive-10.js → moveToActive-11.js} +30 -48
  134. package/dist/esm/scripts/moveToActive-11.js.map +1 -0
  135. package/dist/esm/scripts/moveToDelayed-7.js +100 -0
  136. package/dist/esm/scripts/moveToDelayed-7.js.map +1 -0
  137. package/dist/esm/scripts/{moveToFinished-13.js → moveToFinished-14.js} +89 -88
  138. package/dist/esm/scripts/{moveToFinished-13.js.map → moveToFinished-14.js.map} +1 -1
  139. package/dist/esm/scripts/moveToWaitingChildren-4.js +6 -3
  140. package/dist/esm/scripts/moveToWaitingChildren-4.js.map +1 -1
  141. package/dist/esm/scripts/pause-7.js +64 -0
  142. package/dist/esm/scripts/pause-7.js.map +1 -0
  143. package/dist/esm/scripts/promote-8.js +76 -0
  144. package/dist/esm/scripts/promote-8.js.map +1 -0
  145. package/dist/esm/scripts/{retryJob-9.js → retryJob-10.js} +26 -32
  146. package/dist/esm/scripts/retryJob-10.js.map +1 -0
  147. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  148. package/package.json +1 -1
  149. package/dist/cjs/commands/changePriority-5.lua +0 -52
  150. package/dist/cjs/commands/includes/addPriorityMarkerIfNeeded.lua +0 -12
  151. package/dist/cjs/commands/moveToDelayed-8.lua +0 -72
  152. package/dist/cjs/commands/pause-5.lua +0 -36
  153. package/dist/cjs/commands/promote-7.lua +0 -57
  154. package/dist/cjs/scripts/addDelayedJob-7.js.map +0 -1
  155. package/dist/cjs/scripts/addPrioritizedJob-8.js.map +0 -1
  156. package/dist/cjs/scripts/addStandardJob-6.js.map +0 -1
  157. package/dist/cjs/scripts/changePriority-5.js +0 -87
  158. package/dist/cjs/scripts/changePriority-5.js.map +0 -1
  159. package/dist/cjs/scripts/moveToDelayed-8.js +0 -168
  160. package/dist/cjs/scripts/moveToDelayed-8.js.map +0 -1
  161. package/dist/cjs/scripts/pause-5.js +0 -48
  162. package/dist/cjs/scripts/pause-5.js.map +0 -1
  163. package/dist/cjs/scripts/promote-7.js +0 -87
  164. package/dist/cjs/scripts/promote-7.js.map +0 -1
  165. package/dist/cjs/scripts/retryJob-9.js.map +0 -1
  166. package/dist/esm/commands/changePriority-5.lua +0 -52
  167. package/dist/esm/commands/includes/addPriorityMarkerIfNeeded.lua +0 -12
  168. package/dist/esm/commands/moveToDelayed-8.lua +0 -72
  169. package/dist/esm/commands/pause-5.lua +0 -36
  170. package/dist/esm/commands/promote-7.lua +0 -57
  171. package/dist/esm/scripts/addDelayedJob-7.js.map +0 -1
  172. package/dist/esm/scripts/addPrioritizedJob-8.js.map +0 -1
  173. package/dist/esm/scripts/addStandardJob-6.js.map +0 -1
  174. package/dist/esm/scripts/changePriority-5.js +0 -84
  175. package/dist/esm/scripts/changePriority-5.js.map +0 -1
  176. package/dist/esm/scripts/moveToDelayed-8.js +0 -165
  177. package/dist/esm/scripts/moveToDelayed-8.js.map +0 -1
  178. package/dist/esm/scripts/pause-5.js +0 -45
  179. package/dist/esm/scripts/pause-5.js.map +0 -1
  180. package/dist/esm/scripts/promote-7.js +0 -84
  181. package/dist/esm/scripts/promote-7.js.map +0 -1
  182. package/dist/esm/scripts/retryJob-9.js.map +0 -1
  183. /package/dist/esm/scripts/{addDelayedJob-7.d.ts → addDelayedJob-6.d.ts} +0 -0
  184. /package/dist/esm/scripts/{addPrioritizedJob-8.d.ts → addPrioritizedJob-7.d.ts} +0 -0
  185. /package/dist/esm/scripts/{addStandardJob-6.d.ts → addStandardJob-7.d.ts} +0 -0
  186. /package/dist/esm/scripts/{changePriority-5.d.ts → changePriority-6.d.ts} +0 -0
  187. /package/dist/esm/scripts/{moveToActive-10.d.ts → moveToActive-11.d.ts} +0 -0
  188. /package/dist/esm/scripts/{moveToDelayed-8.d.ts → moveToDelayed-7.d.ts} +0 -0
  189. /package/dist/esm/scripts/{moveToFinished-13.d.ts → moveToFinished-14.d.ts} +0 -0
  190. /package/dist/esm/scripts/{pause-5.d.ts → pause-7.d.ts} +0 -0
  191. /package/dist/esm/scripts/{promote-7.d.ts → promote-8.d.ts} +0 -0
  192. /package/dist/esm/scripts/{retryJob-9.d.ts → retryJob-10.d.ts} +0 -0
@@ -6,13 +6,12 @@ const content = `--[[
6
6
  - adds to delayed zset.
7
7
  - Emits a global event 'delayed' if the job is delayed.
8
8
  Input:
9
- KEYS[1] 'wait',
10
- KEYS[2] 'paused'
11
- KEYS[3] 'meta'
12
- KEYS[4] 'id'
13
- KEYS[5] 'delayed'
14
- KEYS[6] 'completed'
15
- KEYS[7] events stream key
9
+ KEYS[1] 'marker',
10
+ KEYS[2] 'meta'
11
+ KEYS[3] 'id'
12
+ KEYS[4] 'delayed'
13
+ KEYS[5] 'completed'
14
+ KEYS[6] events stream key
16
15
  ARGV[1] msgpacked arguments array
17
16
  [1] key prefix,
18
17
  [2] custom id (use custom instead of one generated automatically)
@@ -29,13 +28,11 @@ const content = `--[[
29
28
  jobId - OK
30
29
  -5 - Missing parent key
31
30
  ]]
32
- local waitKey = KEYS[1]
33
- local pausedKey = KEYS[2]
34
- local metaKey = KEYS[3]
35
- local idKey = KEYS[4]
36
- local delayedKey = KEYS[5]
37
- local completedKey = KEYS[6]
38
- local eventsKey = KEYS[7]
31
+ local metaKey = KEYS[2]
32
+ local idKey = KEYS[3]
33
+ local delayedKey = KEYS[4]
34
+ local completedKey = KEYS[5]
35
+ local eventsKey = KEYS[6]
39
36
  local jobId
40
37
  local jobIdKey
41
38
  local rcall = redis.call
@@ -74,7 +71,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
74
71
  end
75
72
  --[[
76
73
  Add delay marker if needed.
77
- ]]
74
+ ]]
78
75
  -- Includes
79
76
  --[[
80
77
  Function to return the next delayed job timestamp.
@@ -89,36 +86,20 @@ local function getNextDelayedTimestamp(delayedKey)
89
86
  return nextTimestamp
90
87
  end
91
88
  end
92
- local function addDelayMarkerIfNeeded(targetKey, delayedKey)
93
- local waitLen = rcall("LLEN", targetKey)
94
- if waitLen <= 1 then
89
+ local function addDelayMarkerIfNeeded(markerKey, delayedKey)
95
90
  local nextTimestamp = getNextDelayedTimestamp(delayedKey)
96
91
  if nextTimestamp ~= nil then
97
- -- Check if there is already a marker with older timestamp
98
- -- if there is, we need to replace it.
99
- if waitLen == 1 then
100
- local marker = rcall("LINDEX", targetKey, 0)
101
- local oldTimestamp = tonumber(marker:sub(3))
102
- if oldTimestamp and oldTimestamp > nextTimestamp then
103
- rcall("LSET", targetKey, 0, "0:" .. nextTimestamp)
104
- end
105
- else
106
- -- if there is no marker, then we need to add one
107
- rcall("LPUSH", targetKey, "0:" .. nextTimestamp)
108
- end
92
+ -- Replace the score of the marker with the newest known
93
+ -- next timestamp.
94
+ rcall("ZADD", markerKey, nextTimestamp, "0")
109
95
  end
110
- end
111
96
  end
112
97
  --[[
113
98
  Function to check for the meta.paused key to decide if we are paused or not
114
99
  (since an empty list and !EXISTS are not really the same).
115
100
  ]]
116
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
117
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
118
- return waitKey, false
119
- else
120
- return pausedKey, true
121
- end
101
+ local function isQueuePaused(queueMetaKey)
102
+ return rcall("HEXISTS", queueMetaKey, "paused") == 1
122
103
  end
123
104
  --[[
124
105
  Validate and move or add dependencies to parent.
@@ -131,56 +112,64 @@ end
131
112
  --[[
132
113
  Function to add job considering priority.
133
114
  ]]
134
- -- Includes
135
- --[[
136
- Function priority marker to wait if needed
137
- in order to wake up our workers and to respect priority
138
- order as much as possible
139
- ]]
140
- local function addPriorityMarkerIfNeeded(waitKey)
141
- local waitLen = rcall("LLEN", waitKey)
142
- if waitLen == 0 then
143
- rcall("LPUSH", waitKey, "0:0")
144
- end
145
- end
146
- local function addJobWithPriority(waitKey, prioritizedKey, priority, paused, jobId, priorityCounterKey)
115
+ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
147
116
  local prioCounter = rcall("INCR", priorityCounterKey)
148
117
  local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
149
118
  rcall("ZADD", prioritizedKey, score, jobId)
150
- if not paused then
151
- addPriorityMarkerIfNeeded(waitKey)
119
+ if not isPaused then
120
+ rcall("ZADD", markerKey, 0, "0")
152
121
  end
153
122
  end
154
- local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
155
- local isParentActive = rcall("ZSCORE", parentQueueKey .. ":waiting-children", parentId)
156
- if rcall("SCARD", parentDependenciesKey) == 0 and isParentActive then
157
- rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
158
- local parentWaitKey = parentQueueKey .. ":wait"
159
- local parentTarget, paused = getTargetQueueList(parentQueueKey .. ":meta", parentWaitKey,
160
- parentQueueKey .. ":paused")
161
- local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
162
- local priority = tonumber(jobAttributes[1]) or 0
163
- local delay = tonumber(jobAttributes[2]) or 0
164
- if delay > 0 then
165
- local delayedTimestamp = tonumber(timestamp) + delay
166
- local score = delayedTimestamp * 0x1000
167
- local parentDelayedKey = parentQueueKey .. ":delayed"
168
- rcall("ZADD", parentDelayedKey, score, parentId)
169
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId,
170
- "delay", delayedTimestamp)
171
- addDelayMarkerIfNeeded(parentTarget, parentDelayedKey)
172
- else
173
- if priority == 0 then
174
- rcall("RPUSH", parentTarget, parentId)
175
- else
176
- addJobWithPriority(parentWaitKey, parentQueueKey .. ":prioritized", priority, paused,
177
- parentId, parentQueueKey .. ":pc")
178
- end
179
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId,
180
- "prev", "waiting-children")
181
- end
123
+ --[[
124
+ Function to check for the meta.paused key to decide if we are paused or not
125
+ (since an empty list and !EXISTS are not really the same).
126
+ ]]
127
+ local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
128
+ if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
129
+ return waitKey, false
130
+ else
131
+ return pausedKey, true
182
132
  end
183
133
  end
134
+ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
135
+ parentKey, parentId, timestamp)
136
+ local isParentActive = rcall("ZSCORE",
137
+ parentQueueKey .. ":waiting-children", parentId)
138
+ if rcall("SCARD", parentDependenciesKey) == 0 and isParentActive then
139
+ rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
140
+ local parentWaitKey = parentQueueKey .. ":wait"
141
+ local parentPausedKey = parentQueueKey .. ":paused"
142
+ local parentMetaKey = parentQueueKey .. ":meta"
143
+ local parentMarkerKey = parentQueueKey .. ":marker"
144
+ local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
145
+ local priority = tonumber(jobAttributes[1]) or 0
146
+ local delay = tonumber(jobAttributes[2]) or 0
147
+ if delay > 0 then
148
+ local delayedTimestamp = tonumber(timestamp) + delay
149
+ local score = delayedTimestamp * 0x1000
150
+ local parentDelayedKey = parentQueueKey .. ":delayed"
151
+ rcall("ZADD", parentDelayedKey, score, parentId)
152
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed",
153
+ "jobId", parentId, "delay", delayedTimestamp)
154
+ addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
155
+ else
156
+ if priority == 0 then
157
+ local parentTarget, _paused =
158
+ getTargetQueueList(parentMetaKey, parentWaitKey,
159
+ parentPausedKey)
160
+ rcall("RPUSH", parentTarget, parentId)
161
+ rcall("ZADD", parentMarkerKey, 0, "0")
162
+ else
163
+ local isPaused = isQueuePaused(parentMetaKey)
164
+ addJobWithPriority(parentMarkerKey,
165
+ parentQueueKey .. ":prioritized", priority,
166
+ parentId, parentQueueKey .. ":pc", isPaused)
167
+ end
168
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
169
+ "jobId", parentId, "prev", "waiting-children")
170
+ end
171
+ end
172
+ end
184
173
  local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
185
174
  parentId, jobIdKey, returnvalue, timestamp )
186
175
  local processedSet = parentKey .. ":processed"
@@ -252,13 +241,13 @@ local score = delayedTimestamp * 0x1000 + bit.band(jobCounter, 0xfff)
252
241
  rcall("ZADD", delayedKey, score, jobId)
253
242
  rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "delayed",
254
243
  "jobId", jobId, "delay", delayedTimestamp)
255
- -- If wait list is empty, and this delayed job is the next one to be processed,
256
- -- then we need to signal the workers by adding a dummy job (jobId 0:delay) to the wait list.
257
- local target = getTargetQueueList(metaKey, KEYS[1], KEYS[2])
258
- addDelayMarkerIfNeeded(target, delayedKey)
244
+ -- mark that a delayed job is available
245
+ local isPaused = isQueuePaused(metaKey)
246
+ if not isPaused then
247
+ local markerKey = KEYS[1]
248
+ addDelayMarkerIfNeeded(markerKey, delayedKey)
249
+ end
259
250
  -- Check if this job is a child of another job, if so add it to the parents dependencies
260
- -- TODO: Should not be possible to add a child job to a parent that is not in the "waiting-children" status.
261
- -- fail in this case.
262
251
  if parentDependenciesKey ~= nil then
263
252
  rcall("SADD", parentDependenciesKey, jobIdKey)
264
253
  end
@@ -267,6 +256,6 @@ return jobId .. "" -- convert to string
267
256
  export const addDelayedJob = {
268
257
  name: 'addDelayedJob',
269
258
  content,
270
- keys: 7,
259
+ keys: 6,
271
260
  };
272
- //# sourceMappingURL=addDelayedJob-7.js.map
261
+ //# sourceMappingURL=addDelayedJob-6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"moveToActive-10.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-10.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmPf,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
1
+ {"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Pf,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -74,7 +74,7 @@ end
74
74
  -- Includes
75
75
  --[[
76
76
  Add delay marker if needed.
77
- ]]
77
+ ]]
78
78
  -- Includes
79
79
  --[[
80
80
  Function to return the next delayed job timestamp.
@@ -89,47 +89,30 @@ local function getNextDelayedTimestamp(delayedKey)
89
89
  return nextTimestamp
90
90
  end
91
91
  end
92
- local function addDelayMarkerIfNeeded(targetKey, delayedKey)
93
- local waitLen = rcall("LLEN", targetKey)
94
- if waitLen <= 1 then
92
+ local function addDelayMarkerIfNeeded(markerKey, delayedKey)
95
93
  local nextTimestamp = getNextDelayedTimestamp(delayedKey)
96
94
  if nextTimestamp ~= nil then
97
- -- Check if there is already a marker with older timestamp
98
- -- if there is, we need to replace it.
99
- if waitLen == 1 then
100
- local marker = rcall("LINDEX", targetKey, 0)
101
- local oldTimestamp = tonumber(marker:sub(3))
102
- if oldTimestamp and oldTimestamp > nextTimestamp then
103
- rcall("LSET", targetKey, 0, "0:" .. nextTimestamp)
104
- end
105
- else
106
- -- if there is no marker, then we need to add one
107
- rcall("LPUSH", targetKey, "0:" .. nextTimestamp)
108
- end
95
+ -- Replace the score of the marker with the newest known
96
+ -- next timestamp.
97
+ rcall("ZADD", markerKey, nextTimestamp, "0")
109
98
  end
110
- end
111
99
  end
112
100
  --[[
113
- Function to add job considering priority.
101
+ Function to check for the meta.paused key to decide if we are paused or not
102
+ (since an empty list and !EXISTS are not really the same).
114
103
  ]]
115
- -- Includes
104
+ local function isQueuePaused(queueMetaKey)
105
+ return rcall("HEXISTS", queueMetaKey, "paused") == 1
106
+ end
116
107
  --[[
117
- Function priority marker to wait if needed
118
- in order to wake up our workers and to respect priority
119
- order as much as possible
108
+ Function to add job considering priority.
120
109
  ]]
121
- local function addPriorityMarkerIfNeeded(waitKey)
122
- local waitLen = rcall("LLEN", waitKey)
123
- if waitLen == 0 then
124
- rcall("LPUSH", waitKey, "0:0")
125
- end
126
- end
127
- local function addJobWithPriority(waitKey, prioritizedKey, priority, paused, jobId, priorityCounterKey)
110
+ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
128
111
  local prioCounter = rcall("INCR", priorityCounterKey)
129
112
  local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
130
113
  rcall("ZADD", prioritizedKey, score, jobId)
131
- if not paused then
132
- addPriorityMarkerIfNeeded(waitKey)
114
+ if not isPaused then
115
+ rcall("ZADD", markerKey, 0, "0")
133
116
  end
134
117
  end
135
118
  --[[
@@ -143,35 +126,44 @@ local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
143
126
  return pausedKey, true
144
127
  end
145
128
  end
146
- local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
147
- local isParentActive = rcall("ZSCORE", parentQueueKey .. ":waiting-children", parentId)
148
- if rcall("SCARD", parentDependenciesKey) == 0 and isParentActive then
149
- rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
150
- local parentWaitKey = parentQueueKey .. ":wait"
151
- local parentTarget, paused = getTargetQueueList(parentQueueKey .. ":meta", parentWaitKey,
152
- parentQueueKey .. ":paused")
153
- local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
154
- local priority = tonumber(jobAttributes[1]) or 0
155
- local delay = tonumber(jobAttributes[2]) or 0
156
- if delay > 0 then
157
- local delayedTimestamp = tonumber(timestamp) + delay
158
- local score = delayedTimestamp * 0x1000
159
- local parentDelayedKey = parentQueueKey .. ":delayed"
160
- rcall("ZADD", parentDelayedKey, score, parentId)
161
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId,
162
- "delay", delayedTimestamp)
163
- addDelayMarkerIfNeeded(parentTarget, parentDelayedKey)
164
- else
165
- if priority == 0 then
166
- rcall("RPUSH", parentTarget, parentId)
167
- else
168
- addJobWithPriority(parentWaitKey, parentQueueKey .. ":prioritized", priority, paused,
169
- parentId, parentQueueKey .. ":pc")
170
- end
171
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId,
172
- "prev", "waiting-children")
129
+ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
130
+ parentKey, parentId, timestamp)
131
+ local isParentActive = rcall("ZSCORE",
132
+ parentQueueKey .. ":waiting-children", parentId)
133
+ if rcall("SCARD", parentDependenciesKey) == 0 and isParentActive then
134
+ rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
135
+ local parentWaitKey = parentQueueKey .. ":wait"
136
+ local parentPausedKey = parentQueueKey .. ":paused"
137
+ local parentMetaKey = parentQueueKey .. ":meta"
138
+ local parentMarkerKey = parentQueueKey .. ":marker"
139
+ local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
140
+ local priority = tonumber(jobAttributes[1]) or 0
141
+ local delay = tonumber(jobAttributes[2]) or 0
142
+ if delay > 0 then
143
+ local delayedTimestamp = tonumber(timestamp) + delay
144
+ local score = delayedTimestamp * 0x1000
145
+ local parentDelayedKey = parentQueueKey .. ":delayed"
146
+ rcall("ZADD", parentDelayedKey, score, parentId)
147
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed",
148
+ "jobId", parentId, "delay", delayedTimestamp)
149
+ addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
150
+ else
151
+ if priority == 0 then
152
+ local parentTarget, _paused =
153
+ getTargetQueueList(parentMetaKey, parentWaitKey,
154
+ parentPausedKey)
155
+ rcall("RPUSH", parentTarget, parentId)
156
+ rcall("ZADD", parentMarkerKey, 0, "0")
157
+ else
158
+ local isPaused = isQueuePaused(parentMetaKey)
159
+ addJobWithPriority(parentMarkerKey,
160
+ parentQueueKey .. ":prioritized", priority,
161
+ parentId, parentQueueKey .. ":pc", isPaused)
162
+ end
163
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
164
+ "jobId", parentId, "prev", "waiting-children")
165
+ end
173
166
  end
174
- end
175
167
  end
176
168
  local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
177
169
  parentId, jobIdKey, returnvalue, timestamp )
@@ -241,8 +233,6 @@ rcall("ZADD", waitChildrenKey, timestamp, jobId)
241
233
  rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
242
234
  "waiting-children", "jobId", jobId)
243
235
  -- Check if this job is a child of another job, if so add it to the parents dependencies
244
- -- TODO: Should not be possible to add a child job to a parent that is not in the "waiting-children" status.
245
- -- fail in this case.
246
236
  if parentDependenciesKey ~= nil then
247
237
  rcall("SADD", parentDependenciesKey, jobIdKey)
248
238
  end
@@ -1 +1 @@
1
- {"version":3,"file":"addParentJob-4.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-4.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyPf,CAAC;AACF,MAAM,CAAC,MAAM,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Of,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -4,14 +4,13 @@ const content = `--[[
4
4
  - Creates a new job key with the job data.
5
5
  - Adds the job to the "added" list so that workers gets notified.
6
6
  Input:
7
- KEYS[1] 'wait',
8
- KEYS[2] 'paused'
9
- KEYS[3] 'meta'
10
- KEYS[4] 'id'
11
- KEYS[5] 'prioritized'
12
- KEYS[6] 'completed'
13
- KEYS[7] events stream key
14
- KEYS[8] 'pc' priority counter
7
+ KEYS[1] 'marker',
8
+ KEYS[2] 'meta'
9
+ KEYS[3] 'id'
10
+ KEYS[4] 'prioritized'
11
+ KEYS[5] 'completed'
12
+ KEYS[6] events stream key
13
+ KEYS[7] 'pc' priority counter
15
14
  ARGV[1] msgpacked arguments array
16
15
  [1] key prefix,
17
16
  [2] custom id (will not generate one automatically)
@@ -27,15 +26,13 @@ const content = `--[[
27
26
  Output:
28
27
  jobId - OK
29
28
  -5 - Missing parent key
30
- ]]
31
- local waitKey = KEYS[1]
32
- local pausedKey = KEYS[2]
33
- local metaKey = KEYS[3]
34
- local idKey = KEYS[4]
35
- local priorityKey = KEYS[5]
36
- local completedKey = KEYS[6]
37
- local eventsKey = KEYS[7]
38
- local priorityCounterKey = KEYS[8]
29
+ ]]
30
+ local metaKey = KEYS[2]
31
+ local idKey = KEYS[3]
32
+ local priorityKey = KEYS[4]
33
+ local completedKey = KEYS[5]
34
+ local eventsKey = KEYS[6]
35
+ local priorityCounterKey = KEYS[7]
39
36
  local jobId
40
37
  local jobIdKey
41
38
  local rcall = redis.call
@@ -73,37 +70,21 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
73
70
  return delay, priority
74
71
  end
75
72
  --[[
76
- Function to add job considering priority.
73
+ Function to check for the meta.paused key to decide if we are paused or not
74
+ (since an empty list and !EXISTS are not really the same).
77
75
  ]]
78
- -- Includes
76
+ local function isQueuePaused(queueMetaKey)
77
+ return rcall("HEXISTS", queueMetaKey, "paused") == 1
78
+ end
79
79
  --[[
80
- Function priority marker to wait if needed
81
- in order to wake up our workers and to respect priority
82
- order as much as possible
80
+ Function to add job considering priority.
83
81
  ]]
84
- local function addPriorityMarkerIfNeeded(waitKey)
85
- local waitLen = rcall("LLEN", waitKey)
86
- if waitLen == 0 then
87
- rcall("LPUSH", waitKey, "0:0")
88
- end
89
- end
90
- local function addJobWithPriority(waitKey, prioritizedKey, priority, paused, jobId, priorityCounterKey)
82
+ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey, isPaused)
91
83
  local prioCounter = rcall("INCR", priorityCounterKey)
92
84
  local score = priority * 0x100000000 + bit.band(prioCounter, 0xffffffffffff)
93
85
  rcall("ZADD", prioritizedKey, score, jobId)
94
- if not paused then
95
- addPriorityMarkerIfNeeded(waitKey)
96
- end
97
- end
98
- --[[
99
- Function to check for the meta.paused key to decide if we are paused or not
100
- (since an empty list and !EXISTS are not really the same).
101
- ]]
102
- local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
103
- if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
104
- return waitKey, false
105
- else
106
- return pausedKey, true
86
+ if not isPaused then
87
+ rcall("ZADD", markerKey, 0, "0")
107
88
  end
108
89
  end
109
90
  --[[
@@ -116,7 +97,7 @@ end
116
97
  -- Includes
117
98
  --[[
118
99
  Add delay marker if needed.
119
- ]]
100
+ ]]
120
101
  -- Includes
121
102
  --[[
122
103
  Function to return the next delayed job timestamp.
@@ -131,55 +112,63 @@ local function getNextDelayedTimestamp(delayedKey)
131
112
  return nextTimestamp
132
113
  end
133
114
  end
134
- local function addDelayMarkerIfNeeded(targetKey, delayedKey)
135
- local waitLen = rcall("LLEN", targetKey)
136
- if waitLen <= 1 then
115
+ local function addDelayMarkerIfNeeded(markerKey, delayedKey)
137
116
  local nextTimestamp = getNextDelayedTimestamp(delayedKey)
138
117
  if nextTimestamp ~= nil then
139
- -- Check if there is already a marker with older timestamp
140
- -- if there is, we need to replace it.
141
- if waitLen == 1 then
142
- local marker = rcall("LINDEX", targetKey, 0)
143
- local oldTimestamp = tonumber(marker:sub(3))
144
- if oldTimestamp and oldTimestamp > nextTimestamp then
145
- rcall("LSET", targetKey, 0, "0:" .. nextTimestamp)
146
- end
147
- else
148
- -- if there is no marker, then we need to add one
149
- rcall("LPUSH", targetKey, "0:" .. nextTimestamp)
150
- end
118
+ -- Replace the score of the marker with the newest known
119
+ -- next timestamp.
120
+ rcall("ZADD", markerKey, nextTimestamp, "0")
151
121
  end
122
+ end
123
+ --[[
124
+ Function to check for the meta.paused key to decide if we are paused or not
125
+ (since an empty list and !EXISTS are not really the same).
126
+ ]]
127
+ local function getTargetQueueList(queueMetaKey, waitKey, pausedKey)
128
+ if rcall("HEXISTS", queueMetaKey, "paused") ~= 1 then
129
+ return waitKey, false
130
+ else
131
+ return pausedKey, true
152
132
  end
153
133
  end
154
- local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey, parentKey, parentId, timestamp)
155
- local isParentActive = rcall("ZSCORE", parentQueueKey .. ":waiting-children", parentId)
156
- if rcall("SCARD", parentDependenciesKey) == 0 and isParentActive then
157
- rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
158
- local parentWaitKey = parentQueueKey .. ":wait"
159
- local parentTarget, paused = getTargetQueueList(parentQueueKey .. ":meta", parentWaitKey,
160
- parentQueueKey .. ":paused")
161
- local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
162
- local priority = tonumber(jobAttributes[1]) or 0
163
- local delay = tonumber(jobAttributes[2]) or 0
164
- if delay > 0 then
165
- local delayedTimestamp = tonumber(timestamp) + delay
166
- local score = delayedTimestamp * 0x1000
167
- local parentDelayedKey = parentQueueKey .. ":delayed"
168
- rcall("ZADD", parentDelayedKey, score, parentId)
169
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed", "jobId", parentId,
170
- "delay", delayedTimestamp)
171
- addDelayMarkerIfNeeded(parentTarget, parentDelayedKey)
172
- else
173
- if priority == 0 then
174
- rcall("RPUSH", parentTarget, parentId)
175
- else
176
- addJobWithPriority(parentWaitKey, parentQueueKey .. ":prioritized", priority, paused,
177
- parentId, parentQueueKey .. ":pc")
178
- end
179
- rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting", "jobId", parentId,
180
- "prev", "waiting-children")
134
+ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
135
+ parentKey, parentId, timestamp)
136
+ local isParentActive = rcall("ZSCORE",
137
+ parentQueueKey .. ":waiting-children", parentId)
138
+ if rcall("SCARD", parentDependenciesKey) == 0 and isParentActive then
139
+ rcall("ZREM", parentQueueKey .. ":waiting-children", parentId)
140
+ local parentWaitKey = parentQueueKey .. ":wait"
141
+ local parentPausedKey = parentQueueKey .. ":paused"
142
+ local parentMetaKey = parentQueueKey .. ":meta"
143
+ local parentMarkerKey = parentQueueKey .. ":marker"
144
+ local jobAttributes = rcall("HMGET", parentKey, "priority", "delay")
145
+ local priority = tonumber(jobAttributes[1]) or 0
146
+ local delay = tonumber(jobAttributes[2]) or 0
147
+ if delay > 0 then
148
+ local delayedTimestamp = tonumber(timestamp) + delay
149
+ local score = delayedTimestamp * 0x1000
150
+ local parentDelayedKey = parentQueueKey .. ":delayed"
151
+ rcall("ZADD", parentDelayedKey, score, parentId)
152
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "delayed",
153
+ "jobId", parentId, "delay", delayedTimestamp)
154
+ addDelayMarkerIfNeeded(parentMarkerKey, parentDelayedKey)
155
+ else
156
+ if priority == 0 then
157
+ local parentTarget, _paused =
158
+ getTargetQueueList(parentMetaKey, parentWaitKey,
159
+ parentPausedKey)
160
+ rcall("RPUSH", parentTarget, parentId)
161
+ rcall("ZADD", parentMarkerKey, 0, "0")
162
+ else
163
+ local isPaused = isQueuePaused(parentMetaKey)
164
+ addJobWithPriority(parentMarkerKey,
165
+ parentQueueKey .. ":prioritized", priority,
166
+ parentId, parentQueueKey .. ":pc", isPaused)
167
+ end
168
+ rcall("XADD", parentQueueKey .. ":events", "*", "event", "waiting",
169
+ "jobId", parentId, "prev", "waiting-children")
170
+ end
181
171
  end
182
- end
183
172
  end
184
173
  local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDependenciesKey,
185
174
  parentId, jobIdKey, returnvalue, timestamp )
@@ -245,15 +234,13 @@ end
245
234
  local delay, priority = storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2],
246
235
  opts, timestamp, parentKey, parentData,
247
236
  repeatJobKey)
248
- local target, paused = getTargetQueueList(metaKey, waitKey, pausedKey)
249
- addJobWithPriority(waitKey, priorityKey, priority, paused, jobId,
250
- priorityCounterKey)
237
+ -- Add the job to the prioritized set
238
+ local isPause = isQueuePaused(metaKey)
239
+ addJobWithPriority( KEYS[1], priorityKey, priority, jobId, priorityCounterKey, isPause)
251
240
  -- Emit waiting event
252
241
  rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",
253
242
  "jobId", jobId)
254
243
  -- Check if this job is a child of another job, if so add it to the parents dependencies
255
- -- TODO: Should not be possible to add a child job to a parent that is not in the "waiting-children" status.
256
- -- fail in this case.
257
244
  if parentDependenciesKey ~= nil then
258
245
  rcall("SADD", parentDependenciesKey, jobIdKey)
259
246
  end
@@ -262,6 +249,6 @@ return jobId .. "" -- convert to string
262
249
  export const addPrioritizedJob = {
263
250
  name: 'addPrioritizedJob',
264
251
  content,
265
- keys: 8,
252
+ keys: 7,
266
253
  };
267
- //# sourceMappingURL=addPrioritizedJob-8.js.map
254
+ //# sourceMappingURL=addPrioritizedJob-7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addPrioritizedJob-7.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-7.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuPf,CAAC;AACF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,mBAAmB;IACzB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}