bullmq 5.44.3 → 5.45.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/queue-events.js.map +1 -1
- package/dist/cjs/commands/addJobScheduler-11.lua +44 -20
- package/dist/cjs/commands/includes/deduplicateJob.lua +16 -17
- package/dist/cjs/scripts/addDelayedJob-6.js +16 -16
- package/dist/cjs/scripts/addJobScheduler-11.js +38 -19
- package/dist/cjs/scripts/addJobScheduler-11.js.map +1 -1
- package/dist/cjs/scripts/addParentJob-4.js +16 -16
- package/dist/cjs/scripts/addPrioritizedJob-8.js +16 -16
- package/dist/cjs/scripts/addStandardJob-8.js +16 -16
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/classes/queue-events.d.ts +113 -26
- package/dist/esm/classes/queue-events.js.map +1 -1
- package/dist/esm/commands/addJobScheduler-11.lua +44 -20
- package/dist/esm/commands/includes/deduplicateJob.lua +16 -17
- package/dist/esm/scripts/addDelayedJob-6.js +16 -16
- package/dist/esm/scripts/addJobScheduler-11.js +38 -19
- package/dist/esm/scripts/addJobScheduler-11.js.map +1 -1
- package/dist/esm/scripts/addParentJob-4.js +16 -16
- package/dist/esm/scripts/addPrioritizedJob-8.js +16 -16
- package/dist/esm/scripts/addStandardJob-8.js +16 -16
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +3 -3
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"queue-events.js","sourceRoot":"","sources":["../../../src/classes/queue-events.ts"],"names":[],"mappings":";;;;AAMA,oCAKkB;AAClB,6CAAyC;
|
1
|
+
{"version":3,"file":"queue-events.js","sourceRoot":"","sources":["../../../src/classes/queue-events.ts"],"names":[],"mappings":";;;;AAMA,oCAKkB;AAClB,6CAAyC;AAgQzC;;;;;;GAMG;AACH,MAAa,WAAY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AO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAvJD,kCAuJC"}
|
@@ -39,6 +39,7 @@ local waitKey = KEYS[3]
|
|
39
39
|
local pausedKey = KEYS[4]
|
40
40
|
local metaKey = KEYS[5]
|
41
41
|
local prioritizedKey = KEYS[6]
|
42
|
+
local eventsKey = KEYS[9]
|
42
43
|
|
43
44
|
local nextMillis = ARGV[1]
|
44
45
|
local jobSchedulerId = ARGV[3]
|
@@ -61,8 +62,35 @@ local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
|
|
61
62
|
|
62
63
|
if prevMillis ~= false then
|
63
64
|
local currentJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
|
65
|
+
local currentDelayedJobKey = schedulerKey .. ":" .. prevMillis
|
64
66
|
|
65
|
-
if rcall("EXISTS", nextDelayedJobKey)
|
67
|
+
if rcall("EXISTS", nextDelayedJobKey) == 1 then
|
68
|
+
if rcall("ZSCORE", delayedKey, nextDelayedJobId) ~= false then
|
69
|
+
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
70
|
+
rcall("ZREM", delayedKey, nextDelayedJobId)
|
71
|
+
elseif rcall("ZSCORE", prioritizedKey, nextDelayedJobId) ~= false then
|
72
|
+
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
73
|
+
rcall("ZREM", prioritizedKey, nextDelayedJobId)
|
74
|
+
else
|
75
|
+
local pausedOrWaitKey = waitKey
|
76
|
+
if isQueuePaused(metaKey) then
|
77
|
+
pausedOrWaitKey = pausedKey
|
78
|
+
end
|
79
|
+
|
80
|
+
if rcall("LREM", pausedOrWaitKey, 1, nextDelayedJobId) > 0 then
|
81
|
+
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
82
|
+
else
|
83
|
+
local maxEvents = getOrSetMaxEvents(metaKey)
|
84
|
+
|
85
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
86
|
+
"duplicated", "jobId", nextDelayedJobId)
|
87
|
+
|
88
|
+
return nextDelayedJobId .. "" -- convert to string
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
if currentJobId ~= nextDelayedJobId and rcall("EXISTS", currentDelayedJobKey) == 1 then
|
66
94
|
if rcall("ZSCORE", delayedKey, currentJobId) ~= false then
|
67
95
|
removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
|
68
96
|
rcall("ZREM", delayedKey, currentJobId)
|
@@ -70,14 +98,13 @@ if prevMillis ~= false then
|
|
70
98
|
removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
|
71
99
|
rcall("ZREM", prioritizedKey, currentJobId)
|
72
100
|
else
|
101
|
+
local pausedOrWaitKey = waitKey
|
73
102
|
if isQueuePaused(metaKey) then
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
|
80
|
-
end
|
103
|
+
pausedOrWaitKey = pausedKey
|
104
|
+
end
|
105
|
+
|
106
|
+
if rcall("LREM", pausedOrWaitKey, 1, currentJobId) > 0 then
|
107
|
+
removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
|
81
108
|
end
|
82
109
|
end
|
83
110
|
end
|
@@ -86,19 +113,16 @@ end
|
|
86
113
|
local schedulerOpts = cmsgpack.unpack(ARGV[2])
|
87
114
|
storeJobScheduler(jobSchedulerId, schedulerKey, repeatKey, nextMillis, schedulerOpts, ARGV[4], templateOpts)
|
88
115
|
|
89
|
-
|
90
|
-
local eventsKey = KEYS[9]
|
91
|
-
local maxEvents = getOrSetMaxEvents(metaKey)
|
92
|
-
|
93
|
-
rcall("INCR", KEYS[8])
|
116
|
+
rcall("INCR", KEYS[8])
|
94
117
|
|
95
|
-
|
96
|
-
KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
|
97
|
-
schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)
|
118
|
+
local maxEvents = getOrSetMaxEvents(metaKey)
|
98
119
|
|
99
|
-
|
100
|
-
|
101
|
-
|
120
|
+
addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey,
|
121
|
+
KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
|
122
|
+
schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)
|
102
123
|
|
103
|
-
|
124
|
+
if ARGV[9] ~= "" then
|
125
|
+
rcall("HSET", ARGV[9], "nrjid", nextDelayedJobId)
|
104
126
|
end
|
127
|
+
|
128
|
+
return nextDelayedJobId .. "" -- convert to string
|
@@ -1,24 +1,23 @@
|
|
1
1
|
--[[
|
2
2
|
Function to debounce a job.
|
3
|
-
]]
|
4
|
-
|
3
|
+
]]
|
5
4
|
local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
|
6
5
|
local deduplicationId = deduplicationOpts and deduplicationOpts['id']
|
7
6
|
if deduplicationId then
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
7
|
+
local ttl = deduplicationOpts['ttl']
|
8
|
+
local deduplicationKeyExists
|
9
|
+
if ttl then
|
10
|
+
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
|
11
|
+
else
|
12
|
+
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
|
13
|
+
end
|
14
|
+
if deduplicationKeyExists then
|
15
|
+
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
16
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
|
17
|
+
"debounceId", deduplicationId)
|
18
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
19
|
+
currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
|
20
|
+
return currentDebounceJobId
|
21
|
+
end
|
23
22
|
end
|
24
23
|
end
|
@@ -114,25 +114,25 @@ local function addDelayedJob(jobId, delayedKey, eventsKey, timestamp,
|
|
114
114
|
end
|
115
115
|
--[[
|
116
116
|
Function to debounce a job.
|
117
|
-
]]
|
117
|
+
]]
|
118
118
|
local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
|
119
119
|
local deduplicationId = deduplicationOpts and deduplicationOpts['id']
|
120
120
|
if deduplicationId then
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
121
|
+
local ttl = deduplicationOpts['ttl']
|
122
|
+
local deduplicationKeyExists
|
123
|
+
if ttl then
|
124
|
+
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
|
125
|
+
else
|
126
|
+
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
|
127
|
+
end
|
128
|
+
if deduplicationKeyExists then
|
129
|
+
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
130
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
|
131
|
+
"debounceId", deduplicationId)
|
132
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
133
|
+
currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
|
134
|
+
return currentDebounceJobId
|
135
|
+
end
|
136
136
|
end
|
137
137
|
end
|
138
138
|
--[[
|
@@ -39,6 +39,7 @@ local waitKey = KEYS[3]
|
|
39
39
|
local pausedKey = KEYS[4]
|
40
40
|
local metaKey = KEYS[5]
|
41
41
|
local prioritizedKey = KEYS[6]
|
42
|
+
local eventsKey = KEYS[9]
|
42
43
|
local nextMillis = ARGV[1]
|
43
44
|
local jobSchedulerId = ARGV[3]
|
44
45
|
local templateOpts = cmsgpack.unpack(ARGV[5])
|
@@ -398,7 +399,30 @@ local nextDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. nextMillis
|
|
398
399
|
local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
|
399
400
|
if prevMillis ~= false then
|
400
401
|
local currentJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
|
401
|
-
|
402
|
+
local currentDelayedJobKey = schedulerKey .. ":" .. prevMillis
|
403
|
+
if rcall("EXISTS", nextDelayedJobKey) == 1 then
|
404
|
+
if rcall("ZSCORE", delayedKey, nextDelayedJobId) ~= false then
|
405
|
+
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
406
|
+
rcall("ZREM", delayedKey, nextDelayedJobId)
|
407
|
+
elseif rcall("ZSCORE", prioritizedKey, nextDelayedJobId) ~= false then
|
408
|
+
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
409
|
+
rcall("ZREM", prioritizedKey, nextDelayedJobId)
|
410
|
+
else
|
411
|
+
local pausedOrWaitKey = waitKey
|
412
|
+
if isQueuePaused(metaKey) then
|
413
|
+
pausedOrWaitKey = pausedKey
|
414
|
+
end
|
415
|
+
if rcall("LREM", pausedOrWaitKey, 1, nextDelayedJobId) > 0 then
|
416
|
+
removeJob(nextDelayedJobId, true, prefixKey, true --[[remove debounce key]] )
|
417
|
+
else
|
418
|
+
local maxEvents = getOrSetMaxEvents(metaKey)
|
419
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
|
420
|
+
"duplicated", "jobId", nextDelayedJobId)
|
421
|
+
return nextDelayedJobId .. "" -- convert to string
|
422
|
+
end
|
423
|
+
end
|
424
|
+
end
|
425
|
+
if currentJobId ~= nextDelayedJobId and rcall("EXISTS", currentDelayedJobKey) == 1 then
|
402
426
|
if rcall("ZSCORE", delayedKey, currentJobId) ~= false then
|
403
427
|
removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
|
404
428
|
rcall("ZREM", delayedKey, currentJobId)
|
@@ -406,32 +430,27 @@ if prevMillis ~= false then
|
|
406
430
|
removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
|
407
431
|
rcall("ZREM", prioritizedKey, currentJobId)
|
408
432
|
else
|
433
|
+
local pausedOrWaitKey = waitKey
|
409
434
|
if isQueuePaused(metaKey) then
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
if rcall("LREM", waitKey, 1, currentJobId) > 0 then
|
415
|
-
removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
|
416
|
-
end
|
435
|
+
pausedOrWaitKey = pausedKey
|
436
|
+
end
|
437
|
+
if rcall("LREM", pausedOrWaitKey, 1, currentJobId) > 0 then
|
438
|
+
removeJob(currentJobId, true, prefixKey, true --[[remove debounce key]] )
|
417
439
|
end
|
418
440
|
end
|
419
441
|
end
|
420
442
|
end
|
421
443
|
local schedulerOpts = cmsgpack.unpack(ARGV[2])
|
422
444
|
storeJobScheduler(jobSchedulerId, schedulerKey, repeatKey, nextMillis, schedulerOpts, ARGV[4], templateOpts)
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
if ARGV[9] ~= "" then
|
431
|
-
rcall("HSET", ARGV[9], "nrjid", nextDelayedJobId)
|
432
|
-
end
|
433
|
-
return nextDelayedJobId .. "" -- convert to string
|
445
|
+
rcall("INCR", KEYS[8])
|
446
|
+
local maxEvents = getOrSetMaxEvents(metaKey)
|
447
|
+
addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[6], waitKey, pausedKey,
|
448
|
+
KEYS[11], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
|
449
|
+
schedulerOpts['name'], maxEvents, ARGV[7], ARGV[4], jobSchedulerId)
|
450
|
+
if ARGV[9] ~= "" then
|
451
|
+
rcall("HSET", ARGV[9], "nrjid", nextDelayedJobId)
|
434
452
|
end
|
453
|
+
return nextDelayedJobId .. "" -- convert to string
|
435
454
|
`;
|
436
455
|
exports.addJobScheduler = {
|
437
456
|
name: 'addJobScheduler',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addJobScheduler-11.js","sourceRoot":"","sources":["../../../src/scripts/addJobScheduler-11.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addJobScheduler-11.js","sourceRoot":"","sources":["../../../src/scripts/addJobScheduler-11.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkcf,CAAC;AACW,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,iBAAiB;IACvB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -46,25 +46,25 @@ local parentData
|
|
46
46
|
-- Includes
|
47
47
|
--[[
|
48
48
|
Function to debounce a job.
|
49
|
-
]]
|
49
|
+
]]
|
50
50
|
local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
|
51
51
|
local deduplicationId = deduplicationOpts and deduplicationOpts['id']
|
52
52
|
if deduplicationId then
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
53
|
+
local ttl = deduplicationOpts['ttl']
|
54
|
+
local deduplicationKeyExists
|
55
|
+
if ttl then
|
56
|
+
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
|
57
|
+
else
|
58
|
+
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
|
59
|
+
end
|
60
|
+
if deduplicationKeyExists then
|
61
|
+
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
62
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
|
63
|
+
"debounceId", deduplicationId)
|
64
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
65
|
+
currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
|
66
|
+
return currentDebounceJobId
|
67
|
+
end
|
68
68
|
end
|
69
69
|
end
|
70
70
|
--[[
|
@@ -78,25 +78,25 @@ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, pr
|
|
78
78
|
end
|
79
79
|
--[[
|
80
80
|
Function to debounce a job.
|
81
|
-
]]
|
81
|
+
]]
|
82
82
|
local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
|
83
83
|
local deduplicationId = deduplicationOpts and deduplicationOpts['id']
|
84
84
|
if deduplicationId then
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
85
|
+
local ttl = deduplicationOpts['ttl']
|
86
|
+
local deduplicationKeyExists
|
87
|
+
if ttl then
|
88
|
+
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
|
89
|
+
else
|
90
|
+
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
|
91
|
+
end
|
92
|
+
if deduplicationKeyExists then
|
93
|
+
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
94
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
|
95
|
+
"debounceId", deduplicationId)
|
96
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
97
|
+
currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
|
98
|
+
return currentDebounceJobId
|
99
|
+
end
|
100
100
|
end
|
101
101
|
end
|
102
102
|
--[[
|
@@ -72,25 +72,25 @@ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed
|
|
72
72
|
end
|
73
73
|
--[[
|
74
74
|
Function to debounce a job.
|
75
|
-
]]
|
75
|
+
]]
|
76
76
|
local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
|
77
77
|
local deduplicationId = deduplicationOpts and deduplicationOpts['id']
|
78
78
|
if deduplicationId then
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
79
|
+
local ttl = deduplicationOpts['ttl']
|
80
|
+
local deduplicationKeyExists
|
81
|
+
if ttl then
|
82
|
+
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
|
83
|
+
else
|
84
|
+
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
|
85
|
+
end
|
86
|
+
if deduplicationKeyExists then
|
87
|
+
local currentDebounceJobId = rcall('GET', deduplicationKey)
|
88
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
|
89
|
+
"debounceId", deduplicationId)
|
90
|
+
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
91
|
+
currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
|
92
|
+
return currentDebounceJobId
|
93
|
+
end
|
94
94
|
end
|
95
95
|
end
|
96
96
|
--[[
|