bullmq 5.10.4 → 5.12.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.
- package/dist/cjs/classes/job.js +6 -0
- package/dist/cjs/classes/job.js.map +1 -1
- package/dist/cjs/classes/queue-events.js.map +1 -1
- package/dist/cjs/classes/queue-keys.js +2 -1
- package/dist/cjs/classes/queue-keys.js.map +1 -1
- package/dist/cjs/classes/queue.js +9 -0
- package/dist/cjs/classes/queue.js.map +1 -1
- package/dist/cjs/classes/scripts.js +1 -0
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/commands/addDelayedJob-6.lua +11 -1
- package/dist/cjs/commands/addParentJob-4.lua +10 -1
- package/dist/cjs/commands/addPrioritizedJob-8.lua +11 -2
- package/dist/cjs/commands/addStandardJob-8.lua +11 -2
- package/dist/cjs/commands/includes/cleanList.lua +1 -1
- package/dist/cjs/commands/includes/cleanSet.lua +2 -2
- package/dist/cjs/commands/includes/debounceJob.lua +23 -0
- package/dist/cjs/commands/includes/moveParentFromWaitingChildrenToFailed.lua +6 -3
- package/dist/cjs/commands/includes/removeDebounceKey.lua +12 -0
- package/dist/cjs/commands/includes/removeDebounceKeyIfNeeded.lua +14 -0
- package/dist/cjs/commands/includes/removeJob.lua +5 -1
- package/dist/cjs/commands/includes/removeJobs.lua +1 -1
- package/dist/cjs/commands/includes/removeJobsByMaxAge.lua +3 -2
- package/dist/cjs/commands/includes/removeJobsByMaxCount.lua +1 -1
- package/dist/cjs/commands/includes/removeParentDependencyKey.lua +11 -4
- package/dist/cjs/commands/includes/storeJob.lua +7 -1
- package/dist/cjs/commands/moveStalledJobsToWait-9.lua +6 -2
- package/dist/cjs/commands/moveToFinished-14.lua +14 -11
- package/dist/cjs/commands/removeChildDependency-1.lua +1 -1
- package/dist/cjs/commands/removeJob-2.lua +3 -1
- package/dist/cjs/interfaces/debounce-options.js +3 -0
- package/dist/cjs/interfaces/debounce-options.js.map +1 -0
- package/dist/cjs/interfaces/index.js +1 -0
- package/dist/cjs/interfaces/index.js.map +1 -1
- package/dist/cjs/scripts/addDelayedJob-6.js +34 -1
- package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/cjs/scripts/addParentJob-4.js +34 -1
- package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
- package/dist/cjs/scripts/addPrioritizedJob-8.js +34 -1
- package/dist/cjs/scripts/addPrioritizedJob-8.js.map +1 -1
- package/dist/cjs/scripts/addStandardJob-8.js +34 -1
- package/dist/cjs/scripts/addStandardJob-8.js.map +1 -1
- package/dist/cjs/scripts/cleanJobsInSet-2.js +28 -8
- package/dist/cjs/scripts/cleanJobsInSet-2.js.map +1 -1
- package/dist/cjs/scripts/drain-4.js +26 -6
- package/dist/cjs/scripts/drain-4.js.map +1 -1
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +49 -13
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +56 -21
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/obliterate-2.js +26 -6
- package/dist/cjs/scripts/obliterate-2.js.map +1 -1
- package/dist/cjs/scripts/removeChildDependency-1.js +12 -5
- package/dist/cjs/scripts/removeChildDependency-1.js.map +1 -1
- package/dist/cjs/scripts/removeJob-2.js +23 -5
- package/dist/cjs/scripts/removeJob-2.js.map +1 -1
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/esm/classes/job.d.ts +4 -0
- package/dist/esm/classes/job.js +6 -0
- package/dist/esm/classes/job.js.map +1 -1
- package/dist/esm/classes/queue-events.d.ts +9 -0
- package/dist/esm/classes/queue-events.js.map +1 -1
- package/dist/esm/classes/queue-keys.js +2 -1
- package/dist/esm/classes/queue-keys.js.map +1 -1
- package/dist/esm/classes/queue.d.ts +6 -0
- package/dist/esm/classes/queue.js +9 -0
- package/dist/esm/classes/queue.js.map +1 -1
- package/dist/esm/classes/scripts.js +1 -0
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/commands/addDelayedJob-6.lua +11 -1
- package/dist/esm/commands/addParentJob-4.lua +10 -1
- package/dist/esm/commands/addPrioritizedJob-8.lua +11 -2
- package/dist/esm/commands/addStandardJob-8.lua +11 -2
- package/dist/esm/commands/includes/cleanList.lua +1 -1
- package/dist/esm/commands/includes/cleanSet.lua +2 -2
- package/dist/esm/commands/includes/debounceJob.lua +23 -0
- package/dist/esm/commands/includes/moveParentFromWaitingChildrenToFailed.lua +6 -3
- package/dist/esm/commands/includes/removeDebounceKey.lua +12 -0
- package/dist/esm/commands/includes/removeDebounceKeyIfNeeded.lua +14 -0
- package/dist/esm/commands/includes/removeJob.lua +5 -1
- package/dist/esm/commands/includes/removeJobs.lua +1 -1
- package/dist/esm/commands/includes/removeJobsByMaxAge.lua +3 -2
- package/dist/esm/commands/includes/removeJobsByMaxCount.lua +1 -1
- package/dist/esm/commands/includes/removeParentDependencyKey.lua +11 -4
- package/dist/esm/commands/includes/storeJob.lua +7 -1
- package/dist/esm/commands/moveStalledJobsToWait-9.lua +6 -2
- package/dist/esm/commands/moveToFinished-14.lua +14 -11
- package/dist/esm/commands/removeChildDependency-1.lua +1 -1
- package/dist/esm/commands/removeJob-2.lua +3 -1
- package/dist/esm/interfaces/debounce-options.d.ts +13 -0
- package/dist/esm/interfaces/debounce-options.js +2 -0
- package/dist/esm/interfaces/debounce-options.js.map +1 -0
- package/dist/esm/interfaces/index.d.ts +1 -0
- package/dist/esm/interfaces/index.js +1 -0
- package/dist/esm/interfaces/index.js.map +1 -1
- package/dist/esm/interfaces/job-json.d.ts +2 -0
- package/dist/esm/scripts/addDelayedJob-6.js +34 -1
- package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/esm/scripts/addParentJob-4.js +34 -1
- package/dist/esm/scripts/addParentJob-4.js.map +1 -1
- package/dist/esm/scripts/addPrioritizedJob-8.js +34 -1
- package/dist/esm/scripts/addPrioritizedJob-8.js.map +1 -1
- package/dist/esm/scripts/addStandardJob-8.js +34 -1
- package/dist/esm/scripts/addStandardJob-8.js.map +1 -1
- package/dist/esm/scripts/cleanJobsInSet-2.js +28 -8
- package/dist/esm/scripts/cleanJobsInSet-2.js.map +1 -1
- package/dist/esm/scripts/drain-4.js +26 -6
- package/dist/esm/scripts/drain-4.js.map +1 -1
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +49 -13
- package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +56 -21
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/obliterate-2.js +26 -6
- package/dist/esm/scripts/obliterate-2.js.map +1 -1
- package/dist/esm/scripts/removeChildDependency-1.js +12 -5
- package/dist/esm/scripts/removeChildDependency-1.js.map +1 -1
- package/dist/esm/scripts/removeJob-2.js +23 -5
- package/dist/esm/scripts/removeJob-2.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/types/job-options.d.ts +9 -1
- package/package.json +1 -1
@@ -0,0 +1,12 @@
|
|
1
|
+
--[[
|
2
|
+
Function to remove debounce key.
|
3
|
+
]]
|
4
|
+
|
5
|
+
local function removeDebounceKey(prefixKey, jobKey)
|
6
|
+
local debounceId = rcall("HGET", jobKey, "deid")
|
7
|
+
if debounceId then
|
8
|
+
local debounceKey = prefixKey .. "de:" .. debounceId
|
9
|
+
rcall("DEL", debounceKey)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
--[[
|
2
|
+
Function to remove debounce key if needed.
|
3
|
+
]]
|
4
|
+
|
5
|
+
local function removeDebounceKeyIfNeeded(prefixKey, debounceId)
|
6
|
+
if debounceId then
|
7
|
+
local debounceKey = prefixKey .. "de:" .. debounceId
|
8
|
+
local pttl = rcall("PTTL", debounceKey)
|
9
|
+
|
10
|
+
if pttl == 0 or pttl == -1 then
|
11
|
+
rcall("DEL", debounceKey)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -3,11 +3,15 @@
|
|
3
3
|
]]
|
4
4
|
|
5
5
|
-- Includes
|
6
|
+
--- @include "removeDebounceKey"
|
6
7
|
--- @include "removeJobKeys"
|
7
8
|
--- @include "removeParentDependencyKey"
|
8
9
|
|
9
|
-
local function removeJob(jobId, hard, baseKey)
|
10
|
+
local function removeJob(jobId, hard, baseKey, shouldRemoveDebounceKey)
|
10
11
|
local jobKey = baseKey .. jobId
|
11
12
|
removeParentDependencyKey(jobKey, hard, nil, baseKey)
|
13
|
+
if shouldRemoveDebounceKey then
|
14
|
+
removeDebounceKey(baseKey, jobKey)
|
15
|
+
end
|
12
16
|
removeJobKeys(jobKey)
|
13
17
|
end
|
@@ -5,11 +5,12 @@
|
|
5
5
|
-- Includes
|
6
6
|
--- @include "removeJob"
|
7
7
|
|
8
|
-
local function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix
|
8
|
+
local function removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix,
|
9
|
+
shouldRemoveDebounceKey)
|
9
10
|
local start = timestamp - maxAge * 1000
|
10
11
|
local jobIds = rcall("ZREVRANGEBYSCORE", targetSet, start, "-inf")
|
11
12
|
for i, jobId in ipairs(jobIds) do
|
12
|
-
removeJob(jobId, false, prefix)
|
13
|
+
removeJob(jobId, false, prefix, false --[[remove debounce key]])
|
13
14
|
end
|
14
15
|
rcall("ZREMRANGEBYSCORE", targetSet, "-inf", start)
|
15
16
|
end
|
@@ -9,7 +9,7 @@ local function removeJobsByMaxCount(maxCount, targetSet, prefix)
|
|
9
9
|
local start = maxCount
|
10
10
|
local jobIds = rcall("ZREVRANGE", targetSet, start, -1)
|
11
11
|
for i, jobId in ipairs(jobIds) do
|
12
|
-
removeJob(jobId, false, prefix)
|
12
|
+
removeJob(jobId, false, prefix, false --[[remove debounce key]])
|
13
13
|
end
|
14
14
|
rcall("ZREMRANGEBYRANK", targetSet, 0, -(maxCount + 1))
|
15
15
|
end
|
@@ -21,7 +21,7 @@ local function moveParentToWait(parentPrefix, parentId, emitEvent)
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
24
|
+
local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey, debounceId)
|
25
25
|
if parentKey then
|
26
26
|
local parentDependenciesKey = parentKey .. ":dependencies"
|
27
27
|
local result = rcall("SREM", parentDependenciesKey, jobKey)
|
@@ -36,8 +36,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
36
36
|
if numRemovedElements == 1 then
|
37
37
|
if hard then -- remove parent in same queue
|
38
38
|
if parentPrefix == baseKey then
|
39
|
-
removeParentDependencyKey(parentKey, hard, nil, baseKey)
|
39
|
+
removeParentDependencyKey(parentKey, hard, nil, baseKey, nil)
|
40
40
|
removeJobKeys(parentKey)
|
41
|
+
if debounceId then
|
42
|
+
rcall("DEL", parentPrefix .. "de:" .. debounceId)
|
43
|
+
end
|
41
44
|
else
|
42
45
|
moveParentToWait(parentPrefix, parentId)
|
43
46
|
end
|
@@ -49,7 +52,8 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
49
52
|
return true
|
50
53
|
end
|
51
54
|
else
|
52
|
-
local
|
55
|
+
local parentAttributes = rcall("HMGET", jobKey, "parentKey", "deid")
|
56
|
+
local missedParentKey = parentAttributes[1]
|
53
57
|
if( (type(missedParentKey) == "string") and missedParentKey ~= ""
|
54
58
|
and (rcall("EXISTS", missedParentKey) == 1)) then
|
55
59
|
local parentDependenciesKey = missedParentKey .. ":dependencies"
|
@@ -65,8 +69,11 @@ local function removeParentDependencyKey(jobKey, hard, parentKey, baseKey)
|
|
65
69
|
if numRemovedElements == 1 then
|
66
70
|
if hard then
|
67
71
|
if parentPrefix == baseKey then
|
68
|
-
removeParentDependencyKey(missedParentKey, hard, nil, baseKey)
|
72
|
+
removeParentDependencyKey(missedParentKey, hard, nil, baseKey, nil)
|
69
73
|
removeJobKeys(missedParentKey)
|
74
|
+
if parentAttributes[2] then
|
75
|
+
rcall("DEL", parentPrefix .. "de:" .. parentAttributes[2])
|
76
|
+
end
|
70
77
|
else
|
71
78
|
moveParentToWait(parentPrefix, parentId)
|
72
79
|
end
|
@@ -6,7 +6,8 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
6
6
|
local jsonOpts = cjson.encode(opts)
|
7
7
|
local delay = opts['delay'] or 0
|
8
8
|
local priority = opts['priority'] or 0
|
9
|
-
|
9
|
+
local debounceId = opts['de'] and opts['de']['id']
|
10
|
+
|
10
11
|
local optionalValues = {}
|
11
12
|
if parentKey ~= nil then
|
12
13
|
table.insert(optionalValues, "parentKey")
|
@@ -20,6 +21,11 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
20
21
|
table.insert(optionalValues, repeatJobKey)
|
21
22
|
end
|
22
23
|
|
24
|
+
if debounceId then
|
25
|
+
table.insert(optionalValues, "deid")
|
26
|
+
table.insert(optionalValues, debounceId)
|
27
|
+
end
|
28
|
+
|
23
29
|
rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,
|
24
30
|
"timestamp", timestamp, "delay", delay, "priority", priority,
|
25
31
|
unpack(optionalValues))
|
@@ -29,6 +29,7 @@ local rcall = redis.call
|
|
29
29
|
--- @include "includes/getTargetQueueList"
|
30
30
|
--- @include "includes/moveParentFromWaitingChildrenToFailed"
|
31
31
|
--- @include "includes/moveParentToWaitIfNeeded"
|
32
|
+
--- @include "includes/removeDebounceKeyIfNeeded"
|
32
33
|
--- @include "includes/removeJob"
|
33
34
|
--- @include "includes/removeJobsByMaxAge"
|
34
35
|
--- @include "includes/removeJobsByMaxCount"
|
@@ -83,12 +84,14 @@ if (#stalling > 0) then
|
|
83
84
|
local stalledCount =
|
84
85
|
rcall("HINCRBY", jobKey, "stalledCounter", 1)
|
85
86
|
if (stalledCount > MAX_STALLED_JOB_COUNT) then
|
86
|
-
local jobAttributes = rcall("HMGET", jobKey, "opts", "parent")
|
87
|
+
local jobAttributes = rcall("HMGET", jobKey, "opts", "parent", "deid")
|
87
88
|
local rawOpts = jobAttributes[1]
|
88
89
|
local rawParentData = jobAttributes[2]
|
89
90
|
local opts = cjson.decode(rawOpts)
|
90
91
|
local removeOnFailType = type(opts["removeOnFail"])
|
91
92
|
rcall("ZADD", failedKey, timestamp, jobId)
|
93
|
+
removeDebounceKeyIfNeeded(queueKeyPrefix, jobAttributes[3])
|
94
|
+
|
92
95
|
local failedReason =
|
93
96
|
"job stalled more than allowable limit"
|
94
97
|
rcall("HMSET", jobKey, "failedReason", failedReason,
|
@@ -122,7 +125,8 @@ if (#stalling > 0) then
|
|
122
125
|
failedKey, queueKeyPrefix)
|
123
126
|
elseif removeOnFailType == "boolean" then
|
124
127
|
if opts["removeOnFail"] then
|
125
|
-
removeJob(jobId, false, queueKeyPrefix
|
128
|
+
removeJob(jobId, false, queueKeyPrefix,
|
129
|
+
false --[[remove debounce key]])
|
126
130
|
rcall("ZREM", failedKey, jobId)
|
127
131
|
end
|
128
132
|
elseif removeOnFailType ~= "nil" then
|
@@ -65,6 +65,7 @@ local rcall = redis.call
|
|
65
65
|
--- @include "includes/moveParentToWaitIfNeeded"
|
66
66
|
--- @include "includes/prepareJobForProcessing"
|
67
67
|
--- @include "includes/promoteDelayedJobs"
|
68
|
+
--- @include "includes/removeDebounceKeyIfNeeded"
|
68
69
|
--- @include "includes/removeJobKeys"
|
69
70
|
--- @include "includes/removeJobsByMaxAge"
|
70
71
|
--- @include "includes/removeJobsByMaxCount"
|
@@ -93,12 +94,12 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
93
94
|
return -4
|
94
95
|
end
|
95
96
|
|
96
|
-
local
|
97
|
-
local parentKey =
|
97
|
+
local jobAttributes = rcall("HMGET", jobIdKey, "parentKey", "parent", "deid")
|
98
|
+
local parentKey = jobAttributes[1] or ""
|
98
99
|
local parentId = ""
|
99
100
|
local parentQueueKey = ""
|
100
|
-
if
|
101
|
-
local jsonDecodedParent = cjson.decode(
|
101
|
+
if jobAttributes[2] ~= false then
|
102
|
+
local jsonDecodedParent = cjson.decode(jobAttributes[2])
|
102
103
|
parentId = jsonDecodedParent['id']
|
103
104
|
parentQueueKey = jsonDecodedParent['queueKey']
|
104
105
|
end
|
@@ -116,6 +117,10 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
116
117
|
-- Trim events before emiting them to avoid trimming events emitted in this script
|
117
118
|
trimEvents(metaKey, eventStreamKey)
|
118
119
|
|
120
|
+
local prefix = ARGV[7]
|
121
|
+
|
122
|
+
removeDebounceKeyIfNeeded(prefix, jobAttributes[3])
|
123
|
+
|
119
124
|
-- If job has a parent we need to
|
120
125
|
-- 1) remove this job id from parents dependencies
|
121
126
|
-- 2) move the job Id to parent "processed" set
|
@@ -164,8 +169,6 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
164
169
|
-- "returnvalue" / "failedReason" and "finishedOn"
|
165
170
|
|
166
171
|
-- Remove old jobs?
|
167
|
-
local prefix = ARGV[7]
|
168
|
-
|
169
172
|
if maxAge ~= nil then
|
170
173
|
removeJobsByMaxAge(timestamp, maxAge, targetSet, prefix)
|
171
174
|
end
|
@@ -179,7 +182,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
179
182
|
-- TODO: when a child is removed when finished, result or failure in parent
|
180
183
|
-- must not be deleted, those value references should be deleted when the parent
|
181
184
|
-- is deleted
|
182
|
-
removeParentDependencyKey(jobIdKey, false, parentKey)
|
185
|
+
removeParentDependencyKey(jobIdKey, false, parentKey, jobAttributes[3])
|
183
186
|
end
|
184
187
|
end
|
185
188
|
|
@@ -205,7 +208,7 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
205
208
|
local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[2], KEYS[1], KEYS[8])
|
206
209
|
|
207
210
|
-- Check if there are delayed jobs that can be promoted
|
208
|
-
promoteDelayedJobs(KEYS[7], KEYS[14], target, KEYS[3], eventStreamKey,
|
211
|
+
promoteDelayedJobs(KEYS[7], KEYS[14], target, KEYS[3], eventStreamKey, prefix,
|
209
212
|
timestamp, KEYS[10], isPausedOrMaxed)
|
210
213
|
|
211
214
|
local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
|
@@ -229,19 +232,19 @@ if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
|
229
232
|
if jobId == "0:0" then
|
230
233
|
jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2],
|
231
234
|
KEYS[10])
|
232
|
-
return prepareJobForProcessing(
|
235
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId,
|
233
236
|
timestamp, maxJobs,
|
234
237
|
opts)
|
235
238
|
end
|
236
239
|
else
|
237
|
-
return prepareJobForProcessing(
|
240
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId,
|
238
241
|
timestamp, maxJobs,
|
239
242
|
opts)
|
240
243
|
end
|
241
244
|
else
|
242
245
|
jobId = moveJobFromPriorityToActive(KEYS[3], KEYS[2], KEYS[10])
|
243
246
|
if jobId then
|
244
|
-
return prepareJobForProcessing(
|
247
|
+
return prepareJobForProcessing(prefix, KEYS[6], eventStreamKey, jobId,
|
245
248
|
timestamp, maxJobs,
|
246
249
|
opts)
|
247
250
|
end
|
@@ -25,7 +25,7 @@ if rcall("EXISTS", jobKey) ~= 1 then return -1 end
|
|
25
25
|
|
26
26
|
if rcall("EXISTS", parentKey) ~= 1 then return -5 end
|
27
27
|
|
28
|
-
if removeParentDependencyKey(jobKey, false, parentKey, KEYS[1]) then
|
28
|
+
if removeParentDependencyKey(jobKey, false, parentKey, KEYS[1], nil) then
|
29
29
|
rcall("HDEL", jobKey, "parentKey", "parent")
|
30
30
|
|
31
31
|
return 0
|
@@ -19,6 +19,7 @@ local rcall = redis.call
|
|
19
19
|
--- @include "includes/destructureJobKey"
|
20
20
|
--- @include "includes/getOrSetMaxEvents"
|
21
21
|
--- @include "includes/isLocked"
|
22
|
+
--- @include "includes/removeDebounceKey"
|
22
23
|
--- @include "includes/removeJobFromAnyState"
|
23
24
|
--- @include "includes/removeJobKeys"
|
24
25
|
--- @include "includes/removeParentDependencyKey"
|
@@ -26,7 +27,7 @@ local rcall = redis.call
|
|
26
27
|
local function removeJob( prefix, jobId, parentKey, removeChildren)
|
27
28
|
local jobKey = prefix .. jobId;
|
28
29
|
|
29
|
-
removeParentDependencyKey(jobKey, false, parentKey)
|
30
|
+
removeParentDependencyKey(jobKey, false, parentKey, nil)
|
30
31
|
|
31
32
|
if removeChildren == "1" then
|
32
33
|
-- Check if this job has children
|
@@ -66,6 +67,7 @@ local function removeJob( prefix, jobId, parentKey, removeChildren)
|
|
66
67
|
|
67
68
|
local prev = removeJobFromAnyState(prefix, jobId)
|
68
69
|
|
70
|
+
removeDebounceKey(prefix, jobKey)
|
69
71
|
if removeJobKeys(jobKey) > 0 then
|
70
72
|
local maxEvents = getOrSetMaxEvents(KEYS[2])
|
71
73
|
rcall("XADD", prefix .. "events", "MAXLEN", "~", maxEvents, "*", "event", "removed",
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"debounce-options.js","sourceRoot":"","sources":["../../../src/interfaces/debounce-options.ts"],"names":[],"mappings":""}
|
@@ -6,6 +6,7 @@ tslib_1.__exportStar(require("./backoff-options"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./base-job-options"), exports);
|
7
7
|
tslib_1.__exportStar(require("./child-message"), exports);
|
8
8
|
tslib_1.__exportStar(require("./connection"), exports);
|
9
|
+
tslib_1.__exportStar(require("./debounce-options"), exports);
|
9
10
|
tslib_1.__exportStar(require("./flow-job"), exports);
|
10
11
|
tslib_1.__exportStar(require("./ioredis-events"), exports);
|
11
12
|
tslib_1.__exportStar(require("./job-json"), 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,+DAAqC;AACrC,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,6DAAmC;AACnC,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"}
|
@@ -25,6 +25,7 @@ const content = `--[[
|
|
25
25
|
[7] parent dependencies key.
|
26
26
|
[8] parent? {id, queueKey}
|
27
27
|
[9] repeat job key
|
28
|
+
[10] debounce key
|
28
29
|
ARGV[2] Json stringified job data
|
29
30
|
ARGV[3] msgpacked options
|
30
31
|
Output:
|
@@ -42,8 +43,9 @@ local rcall = redis.call
|
|
42
43
|
local args = cmsgpack.unpack(ARGV[1])
|
43
44
|
local data = ARGV[2]
|
44
45
|
local parentKey = args[5]
|
45
|
-
local repeatJobKey = args[9]
|
46
46
|
local parent = args[8]
|
47
|
+
local repeatJobKey = args[9]
|
48
|
+
local debounceKey = args[10]
|
47
49
|
local parentData
|
48
50
|
-- Includes
|
49
51
|
--[[
|
@@ -70,6 +72,27 @@ local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
|
70
72
|
rcall("ZADD", markerKey, nextTimestamp, "1")
|
71
73
|
end
|
72
74
|
end
|
75
|
+
--[[
|
76
|
+
Function to debounce a job.
|
77
|
+
]]
|
78
|
+
local function debounceJob(prefixKey, debounceOpts, jobId, debounceKey, eventsKey, maxEvents)
|
79
|
+
local debounceId = debounceOpts and debounceOpts['id']
|
80
|
+
if debounceId then
|
81
|
+
local ttl = debounceOpts['ttl']
|
82
|
+
local debounceKeyExists
|
83
|
+
if ttl then
|
84
|
+
debounceKeyExists = not rcall('SET', debounceKey, jobId, 'PX', ttl, 'NX')
|
85
|
+
else
|
86
|
+
debounceKeyExists = not rcall('SET', debounceKey, jobId, 'NX')
|
87
|
+
end
|
88
|
+
if debounceKeyExists then
|
89
|
+
local currentDebounceJobId = rcall('GET', debounceKey)
|
90
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
91
|
+
"debounced", "jobId", currentDebounceJobId, "debounceId", debounceId)
|
92
|
+
return currentDebounceJobId
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
73
96
|
--[[
|
74
97
|
Bake in the job id first 12 bits into the timestamp
|
75
98
|
to guarantee correct execution order of delayed jobs
|
@@ -275,6 +298,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
275
298
|
local jsonOpts = cjson.encode(opts)
|
276
299
|
local delay = opts['delay'] or 0
|
277
300
|
local priority = opts['priority'] or 0
|
301
|
+
local debounceId = opts['de'] and opts['de']['id']
|
278
302
|
local optionalValues = {}
|
279
303
|
if parentKey ~= nil then
|
280
304
|
table.insert(optionalValues, "parentKey")
|
@@ -286,6 +310,10 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
286
310
|
table.insert(optionalValues, "rjk")
|
287
311
|
table.insert(optionalValues, repeatJobKey)
|
288
312
|
end
|
313
|
+
if debounceId then
|
314
|
+
table.insert(optionalValues, "deid")
|
315
|
+
table.insert(optionalValues, debounceId)
|
316
|
+
end
|
289
317
|
rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,
|
290
318
|
"timestamp", timestamp, "delay", delay, "priority", priority,
|
291
319
|
unpack(optionalValues))
|
@@ -313,6 +341,11 @@ else
|
|
313
341
|
maxEvents, timestamp)
|
314
342
|
end
|
315
343
|
end
|
344
|
+
local debouncedJobId = debounceJob(args[1], opts['de'],
|
345
|
+
jobId, debounceKey, eventsKey, maxEvents)
|
346
|
+
if debouncedJobId then
|
347
|
+
return debouncedJobId
|
348
|
+
end
|
316
349
|
-- Store the job.
|
317
350
|
local delay, priority = storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2],
|
318
351
|
opts, timestamp, parentKey, parentData,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addDelayedJob-6.js","sourceRoot":"","sources":["../../../src/scripts/addDelayedJob-6.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyWf,CAAC;AACW,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -21,6 +21,7 @@ const content = `--[[
|
|
21
21
|
[7] parent dependencies key.
|
22
22
|
[8] parent? {id, queueKey}
|
23
23
|
[9] repeat job key
|
24
|
+
[10] debounce key
|
24
25
|
ARGV[2] Json stringified job data
|
25
26
|
ARGV[3] msgpacked options
|
26
27
|
Output:
|
@@ -38,10 +39,32 @@ local args = cmsgpack.unpack(ARGV[1])
|
|
38
39
|
local data = ARGV[2]
|
39
40
|
local opts = cmsgpack.unpack(ARGV[3])
|
40
41
|
local parentKey = args[5]
|
41
|
-
local repeatJobKey = args[9]
|
42
42
|
local parent = args[8]
|
43
|
+
local repeatJobKey = args[9]
|
44
|
+
local debounceKey = args[10]
|
43
45
|
local parentData
|
44
46
|
-- Includes
|
47
|
+
--[[
|
48
|
+
Function to debounce a job.
|
49
|
+
]]
|
50
|
+
local function debounceJob(prefixKey, debounceOpts, jobId, debounceKey, eventsKey, maxEvents)
|
51
|
+
local debounceId = debounceOpts and debounceOpts['id']
|
52
|
+
if debounceId then
|
53
|
+
local ttl = debounceOpts['ttl']
|
54
|
+
local debounceKeyExists
|
55
|
+
if ttl then
|
56
|
+
debounceKeyExists = not rcall('SET', debounceKey, jobId, 'PX', ttl, 'NX')
|
57
|
+
else
|
58
|
+
debounceKeyExists = not rcall('SET', debounceKey, jobId, 'NX')
|
59
|
+
end
|
60
|
+
if debounceKeyExists then
|
61
|
+
local currentDebounceJobId = rcall('GET', debounceKey)
|
62
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
63
|
+
"debounced", "jobId", currentDebounceJobId, "debounceId", debounceId)
|
64
|
+
return currentDebounceJobId
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
45
68
|
--[[
|
46
69
|
Function to get max events value or set by default 10000.
|
47
70
|
]]
|
@@ -247,6 +270,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
247
270
|
local jsonOpts = cjson.encode(opts)
|
248
271
|
local delay = opts['delay'] or 0
|
249
272
|
local priority = opts['priority'] or 0
|
273
|
+
local debounceId = opts['de'] and opts['de']['id']
|
250
274
|
local optionalValues = {}
|
251
275
|
if parentKey ~= nil then
|
252
276
|
table.insert(optionalValues, "parentKey")
|
@@ -258,6 +282,10 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
258
282
|
table.insert(optionalValues, "rjk")
|
259
283
|
table.insert(optionalValues, repeatJobKey)
|
260
284
|
end
|
285
|
+
if debounceId then
|
286
|
+
table.insert(optionalValues, "deid")
|
287
|
+
table.insert(optionalValues, debounceId)
|
288
|
+
end
|
261
289
|
rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,
|
262
290
|
"timestamp", timestamp, "delay", delay, "priority", priority,
|
263
291
|
unpack(optionalValues))
|
@@ -284,6 +312,11 @@ else
|
|
284
312
|
maxEvents, timestamp)
|
285
313
|
end
|
286
314
|
end
|
315
|
+
local debouncedJobId = debounceJob(args[1], opts['de'],
|
316
|
+
jobId, debounceKey, eventsKey, maxEvents)
|
317
|
+
if debouncedJobId then
|
318
|
+
return debouncedJobId
|
319
|
+
end
|
287
320
|
-- Store the job.
|
288
321
|
storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2], opts, timestamp,
|
289
322
|
parentKey, parentData, repeatJobKey)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addParentJob-4.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addParentJob-4.js","sourceRoot":"","sources":["../../../src/scripts/addParentJob-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwUf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -25,6 +25,7 @@ const content = `--[[
|
|
25
25
|
[7] parent dependencies key.
|
26
26
|
[8] parent? {id, queueKey}
|
27
27
|
[9] repeat job key
|
28
|
+
[10] debounce key
|
28
29
|
ARGV[2] Json stringified job data
|
29
30
|
ARGV[3] msgpacked options
|
30
31
|
Output:
|
@@ -45,8 +46,9 @@ local args = cmsgpack.unpack(ARGV[1])
|
|
45
46
|
local data = ARGV[2]
|
46
47
|
local opts = cmsgpack.unpack(ARGV[3])
|
47
48
|
local parentKey = args[5]
|
48
|
-
local repeatJobKey = args[9]
|
49
49
|
local parent = args[8]
|
50
|
+
local repeatJobKey = args[9]
|
51
|
+
local debounceKey = args[10]
|
50
52
|
local parentData
|
51
53
|
-- Includes
|
52
54
|
--[[
|
@@ -68,6 +70,27 @@ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, pr
|
|
68
70
|
rcall("ZADD", prioritizedKey, score, jobId)
|
69
71
|
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
70
72
|
end
|
73
|
+
--[[
|
74
|
+
Function to debounce a job.
|
75
|
+
]]
|
76
|
+
local function debounceJob(prefixKey, debounceOpts, jobId, debounceKey, eventsKey, maxEvents)
|
77
|
+
local debounceId = debounceOpts and debounceOpts['id']
|
78
|
+
if debounceId then
|
79
|
+
local ttl = debounceOpts['ttl']
|
80
|
+
local debounceKeyExists
|
81
|
+
if ttl then
|
82
|
+
debounceKeyExists = not rcall('SET', debounceKey, jobId, 'PX', ttl, 'NX')
|
83
|
+
else
|
84
|
+
debounceKeyExists = not rcall('SET', debounceKey, jobId, 'NX')
|
85
|
+
end
|
86
|
+
if debounceKeyExists then
|
87
|
+
local currentDebounceJobId = rcall('GET', debounceKey)
|
88
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
89
|
+
"debounced", "jobId", currentDebounceJobId, "debounceId", debounceId)
|
90
|
+
return currentDebounceJobId
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
71
94
|
--[[
|
72
95
|
Function to store a job
|
73
96
|
]]
|
@@ -76,6 +99,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
76
99
|
local jsonOpts = cjson.encode(opts)
|
77
100
|
local delay = opts['delay'] or 0
|
78
101
|
local priority = opts['priority'] or 0
|
102
|
+
local debounceId = opts['de'] and opts['de']['id']
|
79
103
|
local optionalValues = {}
|
80
104
|
if parentKey ~= nil then
|
81
105
|
table.insert(optionalValues, "parentKey")
|
@@ -87,6 +111,10 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
87
111
|
table.insert(optionalValues, "rjk")
|
88
112
|
table.insert(optionalValues, repeatJobKey)
|
89
113
|
end
|
114
|
+
if debounceId then
|
115
|
+
table.insert(optionalValues, "deid")
|
116
|
+
table.insert(optionalValues, debounceId)
|
117
|
+
end
|
90
118
|
rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,
|
91
119
|
"timestamp", timestamp, "delay", delay, "priority", priority,
|
92
120
|
unpack(optionalValues))
|
@@ -291,6 +319,11 @@ else
|
|
291
319
|
maxEvents, timestamp)
|
292
320
|
end
|
293
321
|
end
|
322
|
+
local debouncedJobId = debounceJob(args[1], opts['de'],
|
323
|
+
jobId, debounceKey, eventsKey, maxEvents)
|
324
|
+
if debouncedJobId then
|
325
|
+
return debouncedJobId
|
326
|
+
end
|
294
327
|
-- Store the job.
|
295
328
|
local delay, priority = storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2],
|
296
329
|
opts, timestamp, parentKey, parentData,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addPrioritizedJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addPrioritizedJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkVf,CAAC;AACW,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,mBAAmB;IACzB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -34,6 +34,7 @@ const content = `--[[
|
|
34
34
|
[7] parent dependencies key.
|
35
35
|
[8] parent? {id, queueKey}
|
36
36
|
[9] repeat job key
|
37
|
+
[10] debounce key
|
37
38
|
ARGV[2] Json stringified job data
|
38
39
|
ARGV[3] msgpacked options
|
39
40
|
Output:
|
@@ -48,8 +49,9 @@ local args = cmsgpack.unpack(ARGV[1])
|
|
48
49
|
local data = ARGV[2]
|
49
50
|
local opts = cmsgpack.unpack(ARGV[3])
|
50
51
|
local parentKey = args[5]
|
51
|
-
local repeatJobKey = args[9]
|
52
52
|
local parent = args[8]
|
53
|
+
local repeatJobKey = args[9]
|
54
|
+
local debounceKey = args[10]
|
53
55
|
local parentData
|
54
56
|
-- Includes
|
55
57
|
--[[
|
@@ -68,6 +70,27 @@ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed
|
|
68
70
|
rcall(pushCmd, targetKey, jobId)
|
69
71
|
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed)
|
70
72
|
end
|
73
|
+
--[[
|
74
|
+
Function to debounce a job.
|
75
|
+
]]
|
76
|
+
local function debounceJob(prefixKey, debounceOpts, jobId, debounceKey, eventsKey, maxEvents)
|
77
|
+
local debounceId = debounceOpts and debounceOpts['id']
|
78
|
+
if debounceId then
|
79
|
+
local ttl = debounceOpts['ttl']
|
80
|
+
local debounceKeyExists
|
81
|
+
if ttl then
|
82
|
+
debounceKeyExists = not rcall('SET', debounceKey, jobId, 'PX', ttl, 'NX')
|
83
|
+
else
|
84
|
+
debounceKeyExists = not rcall('SET', debounceKey, jobId, 'NX')
|
85
|
+
end
|
86
|
+
if debounceKeyExists then
|
87
|
+
local currentDebounceJobId = rcall('GET', debounceKey)
|
88
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
89
|
+
"debounced", "jobId", currentDebounceJobId, "debounceId", debounceId)
|
90
|
+
return currentDebounceJobId
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
71
94
|
--[[
|
72
95
|
Function to get max events value or set by default 10000.
|
73
96
|
]]
|
@@ -257,6 +280,7 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
257
280
|
local jsonOpts = cjson.encode(opts)
|
258
281
|
local delay = opts['delay'] or 0
|
259
282
|
local priority = opts['priority'] or 0
|
283
|
+
local debounceId = opts['de'] and opts['de']['id']
|
260
284
|
local optionalValues = {}
|
261
285
|
if parentKey ~= nil then
|
262
286
|
table.insert(optionalValues, "parentKey")
|
@@ -268,6 +292,10 @@ local function storeJob(eventsKey, jobIdKey, jobId, name, data, opts, timestamp,
|
|
268
292
|
table.insert(optionalValues, "rjk")
|
269
293
|
table.insert(optionalValues, repeatJobKey)
|
270
294
|
end
|
295
|
+
if debounceId then
|
296
|
+
table.insert(optionalValues, "deid")
|
297
|
+
table.insert(optionalValues, debounceId)
|
298
|
+
end
|
271
299
|
rcall("HMSET", jobIdKey, "name", name, "data", data, "opts", jsonOpts,
|
272
300
|
"timestamp", timestamp, "delay", delay, "priority", priority,
|
273
301
|
unpack(optionalValues))
|
@@ -295,6 +323,11 @@ else
|
|
295
323
|
maxEvents, timestamp)
|
296
324
|
end
|
297
325
|
end
|
326
|
+
local debouncedJobId = debounceJob(args[1], opts['de'],
|
327
|
+
jobId, debounceKey, eventsKey, maxEvents)
|
328
|
+
if debouncedJobId then
|
329
|
+
return debouncedJobId
|
330
|
+
end
|
298
331
|
-- Store the job.
|
299
332
|
storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2], opts, timestamp,
|
300
333
|
parentKey, parentData, repeatJobKey)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addStandardJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addStandardJob-8.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsVf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|