bullmq 5.10.4 → 5.11.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 (120) hide show
  1. package/dist/cjs/classes/job.js +6 -0
  2. package/dist/cjs/classes/job.js.map +1 -1
  3. package/dist/cjs/classes/queue-events.js.map +1 -1
  4. package/dist/cjs/classes/queue-keys.js +2 -1
  5. package/dist/cjs/classes/queue-keys.js.map +1 -1
  6. package/dist/cjs/classes/queue.js +9 -0
  7. package/dist/cjs/classes/queue.js.map +1 -1
  8. package/dist/cjs/classes/scripts.js +1 -0
  9. package/dist/cjs/classes/scripts.js.map +1 -1
  10. package/dist/cjs/commands/addDelayedJob-6.lua +11 -1
  11. package/dist/cjs/commands/addParentJob-4.lua +10 -1
  12. package/dist/cjs/commands/addPrioritizedJob-8.lua +11 -2
  13. package/dist/cjs/commands/addStandardJob-8.lua +11 -2
  14. package/dist/cjs/commands/includes/cleanList.lua +1 -1
  15. package/dist/cjs/commands/includes/cleanSet.lua +2 -2
  16. package/dist/cjs/commands/includes/debounceJob.lua +23 -0
  17. package/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +6 -3
  18. package/dist/cjs/commands/includes/removeDebounceKey.lua +12 -0
  19. package/dist/cjs/commands/includes/removeDebounceKeyIfNeeded.lua +14 -0
  20. package/dist/cjs/commands/includes/removeJob.lua +5 -1
  21. package/dist/cjs/commands/includes/removeJobs.lua +1 -1
  22. package/dist/cjs/commands/includes/removeJobsByMaxAge.lua +3 -2
  23. package/dist/cjs/commands/includes/removeJobsByMaxCount.lua +1 -1
  24. package/dist/cjs/commands/includes/removeParentDependencyKey.lua +11 -4
  25. package/dist/cjs/commands/includes/storeJob.lua +7 -1
  26. package/dist/cjs/commands/moveStalledJobsToWait-9.lua +6 -2
  27. package/dist/cjs/commands/moveToFinished-14.lua +14 -11
  28. package/dist/cjs/commands/removeChildDependency-1.lua +1 -1
  29. package/dist/cjs/commands/removeJob-2.lua +3 -1
  30. package/dist/cjs/interfaces/debounce-options.js +3 -0
  31. package/dist/cjs/interfaces/debounce-options.js.map +1 -0
  32. package/dist/cjs/interfaces/index.js +1 -0
  33. package/dist/cjs/interfaces/index.js.map +1 -1
  34. package/dist/cjs/scripts/addDelayedJob-6.js +34 -1
  35. package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
  36. package/dist/cjs/scripts/addParentJob-4.js +34 -1
  37. package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
  38. package/dist/cjs/scripts/addPrioritizedJob-8.js +34 -1
  39. package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -1
  40. package/dist/cjs/scripts/addStandardJob-8.js +34 -1
  41. package/dist/cjs/scripts/addStandardJob-8.js.map +1 -1
  42. package/dist/cjs/scripts/cleanJobsInSet-2.js +28 -8
  43. package/dist/cjs/scripts/cleanJobsInSet-2.js.map +1 -1
  44. package/dist/cjs/scripts/drain-4.js +26 -6
  45. package/dist/cjs/scripts/drain-4.js.map +1 -1
  46. package/dist/cjs/scripts/moveStalledJobsToWait-9.js +49 -13
  47. package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
  48. package/dist/cjs/scripts/moveToFinished-14.js +56 -21
  49. package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
  50. package/dist/cjs/scripts/obliterate-2.js +26 -6
  51. package/dist/cjs/scripts/obliterate-2.js.map +1 -1
  52. package/dist/cjs/scripts/removeChildDependency-1.js +12 -5
  53. package/dist/cjs/scripts/removeChildDependency-1.js.map +1 -1
  54. package/dist/cjs/scripts/removeJob-2.js +23 -5
  55. package/dist/cjs/scripts/removeJob-2.js.map +1 -1
  56. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  57. package/dist/esm/classes/job.d.ts +4 -0
  58. package/dist/esm/classes/job.js +6 -0
  59. package/dist/esm/classes/job.js.map +1 -1
  60. package/dist/esm/classes/queue-events.d.ts +8 -0
  61. package/dist/esm/classes/queue-events.js.map +1 -1
  62. package/dist/esm/classes/queue-keys.js +2 -1
  63. package/dist/esm/classes/queue-keys.js.map +1 -1
  64. package/dist/esm/classes/queue.d.ts +6 -0
  65. package/dist/esm/classes/queue.js +9 -0
  66. package/dist/esm/classes/queue.js.map +1 -1
  67. package/dist/esm/classes/scripts.js +1 -0
  68. package/dist/esm/classes/scripts.js.map +1 -1
  69. package/dist/esm/commands/addDelayedJob-6.lua +11 -1
  70. package/dist/esm/commands/addParentJob-4.lua +10 -1
  71. package/dist/esm/commands/addPrioritizedJob-8.lua +11 -2
  72. package/dist/esm/commands/addStandardJob-8.lua +11 -2
  73. package/dist/esm/commands/includes/cleanList.lua +1 -1
  74. package/dist/esm/commands/includes/cleanSet.lua +2 -2
  75. package/dist/esm/commands/includes/debounceJob.lua +23 -0
  76. package/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +6 -3
  77. package/dist/esm/commands/includes/removeDebounceKey.lua +12 -0
  78. package/dist/esm/commands/includes/removeDebounceKeyIfNeeded.lua +14 -0
  79. package/dist/esm/commands/includes/removeJob.lua +5 -1
  80. package/dist/esm/commands/includes/removeJobs.lua +1 -1
  81. package/dist/esm/commands/includes/removeJobsByMaxAge.lua +3 -2
  82. package/dist/esm/commands/includes/removeJobsByMaxCount.lua +1 -1
  83. package/dist/esm/commands/includes/removeParentDependencyKey.lua +11 -4
  84. package/dist/esm/commands/includes/storeJob.lua +7 -1
  85. package/dist/esm/commands/moveStalledJobsToWait-9.lua +6 -2
  86. package/dist/esm/commands/moveToFinished-14.lua +14 -11
  87. package/dist/esm/commands/removeChildDependency-1.lua +1 -1
  88. package/dist/esm/commands/removeJob-2.lua +3 -1
  89. package/dist/esm/interfaces/debounce-options.d.ts +13 -0
  90. package/dist/esm/interfaces/debounce-options.js +2 -0
  91. package/dist/esm/interfaces/debounce-options.js.map +1 -0
  92. package/dist/esm/interfaces/index.d.ts +1 -0
  93. package/dist/esm/interfaces/index.js +1 -0
  94. package/dist/esm/interfaces/index.js.map +1 -1
  95. package/dist/esm/interfaces/job-json.d.ts +2 -0
  96. package/dist/esm/scripts/addDelayedJob-6.js +34 -1
  97. package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
  98. package/dist/esm/scripts/addParentJob-4.js +34 -1
  99. package/dist/esm/scripts/addParentJob-4.js.map +1 -1
  100. package/dist/esm/scripts/addPrioritizedJob-8.js +34 -1
  101. package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -1
  102. package/dist/esm/scripts/addStandardJob-8.js +34 -1
  103. package/dist/esm/scripts/addStandardJob-8.js.map +1 -1
  104. package/dist/esm/scripts/cleanJobsInSet-2.js +28 -8
  105. package/dist/esm/scripts/cleanJobsInSet-2.js.map +1 -1
  106. package/dist/esm/scripts/drain-4.js +26 -6
  107. package/dist/esm/scripts/drain-4.js.map +1 -1
  108. package/dist/esm/scripts/moveStalledJobsToWait-9.js +49 -13
  109. package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
  110. package/dist/esm/scripts/moveToFinished-14.js +56 -21
  111. package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
  112. package/dist/esm/scripts/obliterate-2.js +26 -6
  113. package/dist/esm/scripts/obliterate-2.js.map +1 -1
  114. package/dist/esm/scripts/removeChildDependency-1.js +12 -5
  115. package/dist/esm/scripts/removeChildDependency-1.js.map +1 -1
  116. package/dist/esm/scripts/removeJob-2.js +23 -5
  117. package/dist/esm/scripts/removeJob-2.js.map +1 -1
  118. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  119. package/dist/esm/types/job-options.d.ts +9 -1
  120. package/package.json +1 -1
@@ -50,6 +50,16 @@ end
50
50
  Function to remove job.
51
51
  ]]
52
52
  -- Includes
53
+ --[[
54
+ Function to remove debounce key.
55
+ ]]
56
+ local function removeDebounceKey(prefixKey, jobKey)
57
+ local debounceId = rcall("HGET", jobKey, "deid")
58
+ if debounceId then
59
+ local debounceKey = prefixKey .. "de:" .. debounceId
60
+ rcall("DEL", debounceKey)
61
+ end
62
+ end
53
63
  --[[
54
64
  Function to remove job keys.
55
65
  ]]
@@ -118,7 +128,7 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
118
128
  rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
119
129
  end
120
130
  end
121
- local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
131
+ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
122
132
  if parentKey then
123
133
  local parentDependenciesKey = parentKey .. ":dependencies"
124
134
  local result = rcall("SREM", parentDependenciesKey, jobKey)
@@ -131,8 +141,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
131
141
  if numRemovedElements == 1 then
132
142
  if hard then -- remove parent in same queue
133
143
  if parentPrefix == baseKey then
134
- removeParentDependencyKey(parentKey, hard, nil, baseKey)
144
+ removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
135
145
  removeJobKeys(parentKey)
146
+ if debounceId then
147
+ rcall("DEL", parentPrefix .. "de:" .. debounceId)
148
+ end
136
149
  else
137
150
  moveParentToWait(parentPrefix, parentId)
138
151
  end
@@ -144,7 +157,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
144
157
  return true
145
158
  end
146
159
  else
147
- local missedParentKey = rcall("HGET", jobKey, "parentKey")
160
+ local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
161
+ local missedParentKey = parentAttributes[1]
148
162
  if( (type(missedParentKey) == "string") and missedParentKey ~= ""
149
163
  and (rcall("EXISTS", missedParentKey) == 1)) then
150
164
  local parentDependenciesKey = missedParentKey .. ":dependencies"
@@ -158,8 +172,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
158
172
  if numRemovedElements == 1 then
159
173
  if hard then
160
174
  if parentPrefix == baseKey then
161
- removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
175
+ removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
162
176
  removeJobKeys(missedParentKey)
177
+ if parentAttributes[2] then
178
+ rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
179
+ end
163
180
  else
164
181
  moveParentToWait(parentPrefix, parentId)
165
182
  end
@@ -174,9 +191,12 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
174
191
  end
175
192
  return false
176
193
  end
177
- local function removeJob(jobId, hard, baseKey)
194
+ local function removeJob(jobId, hard, baseKey, shouldRemoveDebounceKey)
178
195
  local jobKey = baseKey .. jobId
179
196
  removeParentDependencyKey(jobKey, hard, nil, baseKey)
197
+ if shouldRemoveDebounceKey then
198
+ removeDebounceKey(baseKey, jobKey)
199
+ end
180
200
  removeJobKeys(jobKey)
181
201
  end
182
202
  local function cleanList(listKey, jobKeyPrefix, rangeStart, rangeEnd,
@@ -205,7 +225,7 @@ local function cleanList(listKey, jobKeyPrefix, rangeStart, rangeEnd,
205
225
  -- replace the entry with a deletion marker; the actual deletion will
206
226
  -- occur at the end of the script
207
227
  rcall("LSET", listKey, rangeEnd - jobIdsLen + i, deletionMarker)
208
- removeJob(job, true, jobKeyPrefix)
228
+ removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]])
209
229
  deletedCount = deletedCount + 1
210
230
  table.insert(deleted, job)
211
231
  end
@@ -259,14 +279,14 @@ local function cleanSet(setKey, jobKeyPrefix, rangeEnd, timestamp, limit, attrib
259
279
  end
260
280
  local jobKey = jobKeyPrefix .. job
261
281
  if isFinished then
262
- removeJob(job, true, jobKeyPrefix)
282
+ removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]])
263
283
  deletedCount = deletedCount + 1
264
284
  table.insert(deleted, job)
265
285
  else
266
286
  -- * finishedOn says when the job was completed, but it isn't set unless the job has actually completed
267
287
  jobTS = getTimestamp(jobKey, attributes)
268
288
  if (not jobTS or jobTS <= timestamp) then
269
- removeJob(job, true, jobKeyPrefix)
289
+ removeJob(job, true, jobKeyPrefix, true --[[remove debounce key]])
270
290
  deletedCount = deletedCount + 1
271
291
  table.insert(deleted, job)
272
292
  end
@@ -1 +1 @@
1
- {"version":3,"file":"cleanJobsInSet-2.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Sf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"cleanJobsInSet-2.js","sourceRoot":"","sources":["../../../src/scripts/cleanJobsInSet-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Tf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -25,6 +25,16 @@ local queueBaseKey = ARGV[1]
25
25
  Function to remove job.
26
26
  ]]
27
27
  -- Includes
28
+ --[[
29
+ Function to remove debounce key.
30
+ ]]
31
+ local function removeDebounceKey(prefixKey, jobKey)
32
+ local debounceId = rcall("HGET", jobKey, "deid")
33
+ if debounceId then
34
+ local debounceKey = prefixKey .. "de:" .. debounceId
35
+ rcall("DEL", debounceKey)
36
+ end
37
+ end
28
38
  --[[
29
39
  Function to remove job keys.
30
40
  ]]
@@ -93,7 +103,7 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
93
103
  rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
94
104
  end
95
105
  end
96
- local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
106
+ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
97
107
  if parentKey then
98
108
  local parentDependenciesKey = parentKey .. ":dependencies"
99
109
  local result = rcall("SREM", parentDependenciesKey, jobKey)
@@ -106,8 +116,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
106
116
  if numRemovedElements == 1 then
107
117
  if hard then -- remove parent in same queue
108
118
  if parentPrefix == baseKey then
109
- removeParentDependencyKey(parentKey, hard, nil, baseKey)
119
+ removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
110
120
  removeJobKeys(parentKey)
121
+ if debounceId then
122
+ rcall("DEL", parentPrefix .. "de:" .. debounceId)
123
+ end
111
124
  else
112
125
  moveParentToWait(parentPrefix, parentId)
113
126
  end
@@ -119,7 +132,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
119
132
  return true
120
133
  end
121
134
  else
122
- local missedParentKey = rcall("HGET", jobKey, "parentKey")
135
+ local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
136
+ local missedParentKey = parentAttributes[1]
123
137
  if( (type(missedParentKey) == "string") and missedParentKey ~= ""
124
138
  and (rcall("EXISTS", missedParentKey) == 1)) then
125
139
  local parentDependenciesKey = missedParentKey .. ":dependencies"
@@ -133,8 +147,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
133
147
  if numRemovedElements == 1 then
134
148
  if hard then
135
149
  if parentPrefix == baseKey then
136
- removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
150
+ removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
137
151
  removeJobKeys(missedParentKey)
152
+ if parentAttributes[2] then
153
+ rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
154
+ end
138
155
  else
139
156
  moveParentToWait(parentPrefix, parentId)
140
157
  end
@@ -149,14 +166,17 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
149
166
  end
150
167
  return false
151
168
  end
152
- local function removeJob(jobId, hard, baseKey)
169
+ local function removeJob(jobId, hard, baseKey, shouldRemoveDebounceKey)
153
170
  local jobKey = baseKey .. jobId
154
171
  removeParentDependencyKey(jobKey, hard, nil, baseKey)
172
+ if shouldRemoveDebounceKey then
173
+ removeDebounceKey(baseKey, jobKey)
174
+ end
155
175
  removeJobKeys(jobKey)
156
176
  end
157
177
  local function removeJobs(keys, hard, baseKey, max)
158
178
  for i, key in ipairs(keys) do
159
- removeJob(key, hard, baseKey)
179
+ removeJob(key, hard, baseKey, true --[[remove debounce key]])
160
180
  end
161
181
  return max - #keys
162
182
  end
@@ -1 +1 @@
1
- {"version":3,"file":"drain-4.js","sourceRoot":"","sources":["../../../src/scripts/drain-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Mf,CAAC;AACW,QAAA,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"drain-4.js","sourceRoot":"","sources":["../../../src/scripts/drain-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmOf,CAAC;AACW,QAAA,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -173,6 +173,18 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
173
173
  end
174
174
  end
175
175
  end
176
+ --[[
177
+ Function to remove debounce key if needed.
178
+ ]]
179
+ local function removeDebounceKeyIfNeeded(prefixKey, debounceId)
180
+ if debounceId then
181
+ local debounceKey = prefixKey .. "de:" .. debounceId
182
+ local pttl = rcall("PTTL", debounceKey)
183
+ if pttl == 0 or pttl == -1 then
184
+ rcall("DEL", debounceKey)
185
+ end
186
+ end
187
+ end
176
188
  local function moveParentFromWaitingChildrenToFailed( parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
177
189
  if rcall("ZREM", parentQueueKey .. ":waiting-children", parentId) == 1 then
178
190
  rcall("ZADD", parentQueueKey .. ":failed", timestamp, parentId)
@@ -180,9 +192,10 @@ local function moveParentFromWaitingChildrenToFailed( parentQueueKey, parentKey,
180
192
  rcall("HMSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
181
193
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
182
194
  failedReason, "prev", "waiting-children")
183
- local rawParentData = rcall("HGET", parentKey, "parent")
184
- if rawParentData ~= false then
185
- local parentData = cjson.decode(rawParentData)
195
+ local jobAttributes = rcall("HMGET", parentKey, "parent", "deid")
196
+ removeDebounceKeyIfNeeded(parentQueueKey, jobAttributes[2])
197
+ if jobAttributes[1] then
198
+ local parentData = cjson.decode(jobAttributes[1])
186
199
  if parentData['fpof'] then
187
200
  moveParentFromWaitingChildrenToFailed(
188
201
  parentData['queueKey'],
@@ -206,6 +219,16 @@ end
206
219
  Function to remove job.
207
220
  ]]
208
221
  -- Includes
222
+ --[[
223
+ Function to remove debounce key.
224
+ ]]
225
+ local function removeDebounceKey(prefixKey, jobKey)
226
+ local debounceId = rcall("HGET", jobKey, "deid")
227
+ if debounceId then
228
+ local debounceKey = prefixKey .. "de:" .. debounceId
229
+ rcall("DEL", debounceKey)
230
+ end
231
+ end
209
232
  --[[
210
233
  Function to remove job keys.
211
234
  ]]
@@ -238,7 +261,7 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
238
261
  rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
239
262
  end
240
263
  end
241
- local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
264
+ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
242
265
  if parentKey then
243
266
  local parentDependenciesKey = parentKey .. ":dependencies"
244
267
  local result = rcall("SREM", parentDependenciesKey, jobKey)
@@ -251,8 +274,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
251
274
  if numRemovedElements == 1 then
252
275
  if hard then -- remove parent in same queue
253
276
  if parentPrefix == baseKey then
254
- removeParentDependencyKey(parentKey, hard, nil, baseKey)
277
+ removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
255
278
  removeJobKeys(parentKey)
279
+ if debounceId then
280
+ rcall("DEL", parentPrefix .. "de:" .. debounceId)
281
+ end
256
282
  else
257
283
  moveParentToWait(parentPrefix, parentId)
258
284
  end
@@ -264,7 +290,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
264
290
  return true
265
291
  end
266
292
  else
267
- local missedParentKey = rcall("HGET", jobKey, "parentKey")
293
+ local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
294
+ local missedParentKey = parentAttributes[1]
268
295
  if( (type(missedParentKey) == "string") and missedParentKey ~= ""
269
296
  and (rcall("EXISTS", missedParentKey) == 1)) then
270
297
  local parentDependenciesKey = missedParentKey .. ":dependencies"
@@ -278,8 +305,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
278
305
  if numRemovedElements == 1 then
279
306
  if hard then
280
307
  if parentPrefix == baseKey then
281
- removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
308
+ removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
282
309
  removeJobKeys(missedParentKey)
310
+ if parentAttributes[2] then
311
+ rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
312
+ end
283
313
  else
284
314
  moveParentToWait(parentPrefix, parentId)
285
315
  end
@@ -294,20 +324,24 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
294
324
  end
295
325
  return false
296
326
  end
297
- local function removeJob(jobId, hard, baseKey)
327
+ local function removeJob(jobId, hard, baseKey, shouldRemoveDebounceKey)
298
328
  local jobKey = baseKey .. jobId
299
329
  removeParentDependencyKey(jobKey, hard, nil, baseKey)
330
+ if shouldRemoveDebounceKey then
331
+ removeDebounceKey(baseKey, jobKey)
332
+ end
300
333
  removeJobKeys(jobKey)
301
334
  end
302
335
  --[[
303
336
  Functions to remove jobs by max age.
304
337
  ]]
305
338
  -- Includes
306
- local function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix)
339
+ local function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix,
340
+ shouldRemoveDebounceKey)
307
341
  local start = timestamp - maxAge * 1000
308
342
  local jobIds = rcall("ZREVRANGEBYSCORE", targetSet, start, "-inf")
309
343
  for i, jobId in ipairs(jobIds) do
310
- removeJob(jobId, false, prefix)
344
+ removeJob(jobId, false, prefix, false --[[remove debounce key]])
311
345
  end
312
346
  rcall("ZREMRANGEBYSCORE", targetSet, "-inf", start)
313
347
  end
@@ -319,7 +353,7 @@ local function removeJobsByMaxCount(maxCount, targetSet, prefix)
319
353
  local start = maxCount
320
354
  local jobIds = rcall("ZREVRANGE", targetSet, start, -1)
321
355
  for i, jobId in ipairs(jobIds) do
322
- removeJob(jobId, false, prefix)
356
+ removeJob(jobId, false, prefix, false --[[remove debounce key]])
323
357
  end
324
358
  rcall("ZREMRANGEBYRANK", targetSet, 0, -(maxCount + 1))
325
359
  end
@@ -387,12 +421,13 @@ if (#stalling > 0) then
387
421
  local stalledCount =
388
422
  rcall("HINCRBY", jobKey, "stalledCounter", 1)
389
423
  if (stalledCount > MAX_STALLED_JOB_COUNT) then
390
- local jobAttributes = rcall("HMGET", jobKey, "opts", "parent")
424
+ local jobAttributes = rcall("HMGET", jobKey, "opts", "parent", "deid")
391
425
  local rawOpts = jobAttributes[1]
392
426
  local rawParentData = jobAttributes[2]
393
427
  local opts = cjson.decode(rawOpts)
394
428
  local removeOnFailType = type(opts["removeOnFail"])
395
429
  rcall("ZADD", failedKey, timestamp, jobId)
430
+ removeDebounceKeyIfNeeded(queueKeyPrefix, jobAttributes[3])
396
431
  local failedReason =
397
432
  "job stalled more than allowable limit"
398
433
  rcall("HMSET", jobKey, "failedReason", failedReason,
@@ -425,7 +460,8 @@ if (#stalling > 0) then
425
460
  failedKey, queueKeyPrefix)
426
461
  elseif removeOnFailType == "boolean" then
427
462
  if opts["removeOnFail"] then
428
- removeJob(jobId, false, queueKeyPrefix)
463
+ removeJob(jobId, false, queueKeyPrefix,
464
+ false --[[remove debounce key]])
429
465
  rcall("ZREM", failedKey, jobId)
430
466
  end
431
467
  elseif removeOnFailType ~= "nil" then
@@ -1 +1 @@
1
- {"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAgdS,CAAC;AACb,QAAA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAofS,CAAC;AACb,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
@@ -266,6 +266,18 @@ local function moveParentToWaitIfNeeded(parentQueueKey, parentDependenciesKey,
266
266
  end
267
267
  end
268
268
  end
269
+ --[[
270
+ Function to remove debounce key if needed.
271
+ ]]
272
+ local function removeDebounceKeyIfNeeded(prefixKey, debounceId)
273
+ if debounceId then
274
+ local debounceKey = prefixKey .. "de:" .. debounceId
275
+ local pttl = rcall("PTTL", debounceKey)
276
+ if pttl == 0 or pttl == -1 then
277
+ rcall("DEL", debounceKey)
278
+ end
279
+ end
280
+ end
269
281
  local function moveParentFromWaitingChildrenToFailed( parentQueueKey, parentKey, parentId, jobIdKey, timestamp)
270
282
  if rcall("ZREM", parentQueueKey .. ":waiting-children", parentId) == 1 then
271
283
  rcall("ZADD", parentQueueKey .. ":failed", timestamp, parentId)
@@ -273,9 +285,10 @@ local function moveParentFromWaitingChildrenToFailed( parentQueueKey, parentKey,
273
285
  rcall("HMSET", parentKey, "failedReason", failedReason, "finishedOn", timestamp)
274
286
  rcall("XADD", parentQueueKey .. ":events", "*", "event", "failed", "jobId", parentId, "failedReason",
275
287
  failedReason, "prev", "waiting-children")
276
- local rawParentData = rcall("HGET", parentKey, "parent")
277
- if rawParentData ~= false then
278
- local parentData = cjson.decode(rawParentData)
288
+ local jobAttributes = rcall("HMGET", parentKey, "parent", "deid")
289
+ removeDebounceKeyIfNeeded(parentQueueKey, jobAttributes[2])
290
+ if jobAttributes[1] then
291
+ local parentData = cjson.decode(jobAttributes[1])
279
292
  if parentData['fpof'] then
280
293
  moveParentFromWaitingChildrenToFailed(
281
294
  parentData['queueKey'],
@@ -376,6 +389,16 @@ end
376
389
  Function to remove job.
377
390
  ]]
378
391
  -- Includes
392
+ --[[
393
+ Function to remove debounce key.
394
+ ]]
395
+ local function removeDebounceKey(prefixKey, jobKey)
396
+ local debounceId = rcall("HGET", jobKey, "deid")
397
+ if debounceId then
398
+ local debounceKey = prefixKey .. "de:" .. debounceId
399
+ rcall("DEL", debounceKey)
400
+ end
401
+ end
379
402
  --[[
380
403
  Check if this job has a parent. If so we will just remove it from
381
404
  the parent child list, but if it is the last child we should move the parent to "wait/paused"
@@ -401,7 +424,7 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
401
424
  rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
402
425
  end
403
426
  end
404
- local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
427
+ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
405
428
  if parentKey then
406
429
  local parentDependenciesKey = parentKey .. ":dependencies"
407
430
  local result = rcall("SREM", parentDependenciesKey, jobKey)
@@ -414,8 +437,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
414
437
  if numRemovedElements == 1 then
415
438
  if hard then -- remove parent in same queue
416
439
  if parentPrefix == baseKey then
417
- removeParentDependencyKey(parentKey, hard, nil, baseKey)
440
+ removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
418
441
  removeJobKeys(parentKey)
442
+ if debounceId then
443
+ rcall("DEL", parentPrefix .. "de:" .. debounceId)
444
+ end
419
445
  else
420
446
  moveParentToWait(parentPrefix, parentId)
421
447
  end
@@ -427,7 +453,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
427
453
  return true
428
454
  end
429
455
  else
430
- local missedParentKey = rcall("HGET", jobKey, "parentKey")
456
+ local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
457
+ local missedParentKey = parentAttributes[1]
431
458
  if( (type(missedParentKey) == "string") and missedParentKey ~= ""
432
459
  and (rcall("EXISTS", missedParentKey) == 1)) then
433
460
  local parentDependenciesKey = missedParentKey .. ":dependencies"
@@ -441,8 +468,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
441
468
  if numRemovedElements == 1 then
442
469
  if hard then
443
470
  if parentPrefix == baseKey then
444
- removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
471
+ removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
445
472
  removeJobKeys(missedParentKey)
473
+ if parentAttributes[2] then
474
+ rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
475
+ end
446
476
  else
447
477
  moveParentToWait(parentPrefix, parentId)
448
478
  end
@@ -457,16 +487,20 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
457
487
  end
458
488
  return false
459
489
  end
460
- local function removeJob(jobId, hard, baseKey)
490
+ local function removeJob(jobId, hard, baseKey, shouldRemoveDebounceKey)
461
491
  local jobKey = baseKey .. jobId
462
492
  removeParentDependencyKey(jobKey, hard, nil, baseKey)
493
+ if shouldRemoveDebounceKey then
494
+ removeDebounceKey(baseKey, jobKey)
495
+ end
463
496
  removeJobKeys(jobKey)
464
497
  end
465
- local function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix)
498
+ local function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix,
499
+ shouldRemoveDebounceKey)
466
500
  local start = timestamp - maxAge * 1000
467
501
  local jobIds = rcall("ZREVRANGEBYSCORE", targetSet, start, "-inf")
468
502
  for i, jobId in ipairs(jobIds) do
469
- removeJob(jobId, false, prefix)
503
+ removeJob(jobId, false, prefix, false --[[remove debounce key]])
470
504
  end
471
505
  rcall("ZREMRANGEBYSCORE", targetSet, "-inf", start)
472
506
  end
@@ -478,7 +512,7 @@ local function removeJobsByMaxCount(maxCount, targetSet, prefix)
478
512
  local start = maxCount
479
513
  local jobIds = rcall("ZREVRANGE", targetSet, start, -1)
480
514
  for i, jobId in ipairs(jobIds) do
481
- removeJob(jobId, false, prefix)
515
+ removeJob(jobId, false, prefix, false --[[remove debounce key]])
482
516
  end
483
517
  rcall("ZREMRANGEBYRANK", targetSet, 0, -(maxCount + 1))
484
518
  end
@@ -549,12 +583,12 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
549
583
  if rcall("SCARD", jobIdKey .. ":dependencies") ~= 0 then -- // Make sure it does not have pending dependencies
550
584
  return -4
551
585
  end
552
- local parentReferences = rcall("HMGET", jobIdKey, "parentKey", "parent")
553
- local parentKey = parentReferences[1] or ""
586
+ local jobAttributes = rcall("HMGET", jobIdKey, "parentKey", "parent", "deid")
587
+ local parentKey = jobAttributes[1] or ""
554
588
  local parentId = ""
555
589
  local parentQueueKey = ""
556
- if parentReferences[2] ~= false then
557
- local jsonDecodedParent = cjson.decode(parentReferences[2])
590
+ if jobAttributes[2] ~= false then
591
+ local jsonDecodedParent = cjson.decode(jobAttributes[2])
558
592
  parentId = jsonDecodedParent['id']
559
593
  parentQueueKey = jsonDecodedParent['queueKey']
560
594
  end
@@ -567,6 +601,8 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
567
601
  local metaKey = KEYS[9]
568
602
  -- Trim events before emiting them to avoid trimming events emitted in this script
569
603
  trimEvents(metaKey, eventStreamKey)
604
+ local prefix = ARGV[7]
605
+ removeDebounceKeyIfNeeded(prefix, jobAttributes[3])
570
606
  -- If job has a parent we need to
571
607
  -- 1) remove this job id from parents dependencies
572
608
  -- 2) move the job Id to parent "processed" set
@@ -611,7 +647,6 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
611
647
  rcall("HMSET", jobIdKey, ARGV[3], ARGV[4], "finishedOn", timestamp)
612
648
  -- "returnvalue" / "failedReason" and "finishedOn"
613
649
  -- Remove old jobs?
614
- local prefix = ARGV[7]
615
650
  if maxAge ~= nil then
616
651
  removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix)
617
652
  end
@@ -624,7 +659,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
624
659
  -- TODO: when a child is removed when finished, result or failure in parent
625
660
  -- must not be deleted, those value references should be deleted when the parent
626
661
  -- is deleted
627
- removeParentDependencyKey(jobIdKey, false, parentKey)
662
+ removeParentDependencyKey(jobIdKey, false, parentKey, jobAttributes[3])
628
663
  end
629
664
  end
630
665
  rcall("XADD", eventStreamKey, "*", "event", ARGV[5], "jobId", jobId, ARGV[3],
@@ -644,7 +679,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
644
679
  if (ARGV[6] == "1") then
645
680
  local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[2], KEYS[1], KEYS[8])
646
681
  -- Check if there are delayed jobs that can be promoted
647
- promoteDelayedJobs(KEYS[7], KEYS[14], target, KEYS[3], eventStreamKey, ARGV[7],
682
+ promoteDelayedJobs(KEYS[7], KEYS[14], target, KEYS[3], eventStreamKey, prefix,
648
683
  timestamp, KEYS[10], isPausedOrMaxed)
649
684
  local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
650
685
  -- Check if we are rate limited first.
@@ -662,19 +697,19 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
662
697
  if jobId == "0:0" then
663
698
  jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2],
664
699
  KEYS[10])
665
- return prepareJobForProcessing(ARGV[7], KEYS[6], eventStreamKey, jobId,
700
+ return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId,
666
701
  timestamp, maxJobs,
667
702
  opts)
668
703
  end
669
704
  else
670
- return prepareJobForProcessing(ARGV[7], KEYS[6], eventStreamKey, jobId,
705
+ return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId,
671
706
  timestamp, maxJobs,
672
707
  opts)
673
708
  end
674
709
  else
675
710
  jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2], KEYS[10])
676
711
  if jobId then
677
- return prepareJobForProcessing(ARGV[7], KEYS[6], eventStreamKey, jobId,
712
+ return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId,
678
713
  timestamp, maxJobs,
679
714
  opts)
680
715
  end
@@ -1 +1 @@
1
- {"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4rBf,CAAC;AACW,QAAA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+tBf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
@@ -27,6 +27,16 @@ local rcall = redis.call
27
27
  Function to remove job.
28
28
  ]]
29
29
  -- Includes
30
+ --[[
31
+ Function to remove debounce key.
32
+ ]]
33
+ local function removeDebounceKey(prefixKey, jobKey)
34
+ local debounceId = rcall("HGET", jobKey, "deid")
35
+ if debounceId then
36
+ local debounceKey = prefixKey .. "de:" .. debounceId
37
+ rcall("DEL", debounceKey)
38
+ end
39
+ end
30
40
  --[[
31
41
  Function to remove job keys.
32
42
  ]]
@@ -95,7 +105,7 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
95
105
  rcall("XADD", parentEventStream, "*", "event", "waiting", "jobId", parentId, "prev", "waiting-children")
96
106
  end
97
107
  end
98
- local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
108
+ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
99
109
  if parentKey then
100
110
  local parentDependenciesKey = parentKey .. ":dependencies"
101
111
  local result = rcall("SREM", parentDependenciesKey, jobKey)
@@ -108,8 +118,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
108
118
  if numRemovedElements == 1 then
109
119
  if hard then -- remove parent in same queue
110
120
  if parentPrefix == baseKey then
111
- removeParentDependencyKey(parentKey, hard, nil, baseKey)
121
+ removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
112
122
  removeJobKeys(parentKey)
123
+ if debounceId then
124
+ rcall("DEL", parentPrefix .. "de:" .. debounceId)
125
+ end
113
126
  else
114
127
  moveParentToWait(parentPrefix, parentId)
115
128
  end
@@ -121,7 +134,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
121
134
  return true
122
135
  end
123
136
  else
124
- local missedParentKey = rcall("HGET", jobKey, "parentKey")
137
+ local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
138
+ local missedParentKey = parentAttributes[1]
125
139
  if( (type(missedParentKey) == "string") and missedParentKey ~= ""
126
140
  and (rcall("EXISTS", missedParentKey) == 1)) then
127
141
  local parentDependenciesKey = missedParentKey .. ":dependencies"
@@ -135,8 +149,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
135
149
  if numRemovedElements == 1 then
136
150
  if hard then
137
151
  if parentPrefix == baseKey then
138
- removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
152
+ removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
139
153
  removeJobKeys(missedParentKey)
154
+ if parentAttributes[2] then
155
+ rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
156
+ end
140
157
  else
141
158
  moveParentToWait(parentPrefix, parentId)
142
159
  end
@@ -151,14 +168,17 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
151
168
  end
152
169
  return false
153
170
  end
154
- local function removeJob(jobId, hard, baseKey)
171
+ local function removeJob(jobId, hard, baseKey, shouldRemoveDebounceKey)
155
172
  local jobKey = baseKey .. jobId
156
173
  removeParentDependencyKey(jobKey, hard, nil, baseKey)
174
+ if shouldRemoveDebounceKey then
175
+ removeDebounceKey(baseKey, jobKey)
176
+ end
157
177
  removeJobKeys(jobKey)
158
178
  end
159
179
  local function removeJobs(keys, hard, baseKey, max)
160
180
  for i, key in ipairs(keys) do
161
- removeJob(key, hard, baseKey)
181
+ removeJob(key, hard, baseKey, true --[[remove debounce key]])
162
182
  end
163
183
  return max - #keys
164
184
  end
@@ -1 +1 @@
1
- {"version":3,"file":"obliterate-2.js","sourceRoot":"","sources":["../../../src/scripts/obliterate-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Rf,CAAC;AACW,QAAA,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
1
+ {"version":3,"file":"obliterate-2.js","sourceRoot":"","sources":["../../../src/scripts/obliterate-2.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmTf,CAAC;AACW,QAAA,UAAU,GAAG;IACxB,IAAI,EAAE,YAAY;IAClB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}