Review funkt
This commit is contained in:
61
node_modules/bullmq/dist/cjs/commands/includes/deduplicateJobWithoutReplace.lua
generated
vendored
Normal file
61
node_modules/bullmq/dist/cjs/commands/includes/deduplicateJobWithoutReplace.lua
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
--[[
|
||||
Function to deduplicate a job.
|
||||
]]
|
||||
--- @include "setDeduplicationKey"
|
||||
--- @include "storeDeduplicatedNextJob"
|
||||
|
||||
local function deduplicateJobWithoutReplace(deduplicationId, deduplicationOpts, jobId, deduplicationKey,
|
||||
eventsKey, maxEvents, prefix, jobName, jobData, fullOpts,
|
||||
parentKey, parentData, parentDependenciesKey, repeatJobKey)
|
||||
local ttl = deduplicationOpts['ttl']
|
||||
local deduplicationKeyExists
|
||||
if ttl and ttl > 0 then
|
||||
if deduplicationOpts['extend'] then
|
||||
local currentDeduplicatedJobId = rcall('GET', deduplicationKey)
|
||||
if currentDeduplicatedJobId then
|
||||
if storeDeduplicatedNextJob(deduplicationOpts, currentDeduplicatedJobId, prefix,
|
||||
deduplicationId, jobName, jobData, fullOpts, eventsKey, maxEvents, jobId,
|
||||
parentKey, parentData, parentDependenciesKey, repeatJobKey) then
|
||||
return currentDeduplicatedJobId
|
||||
end
|
||||
if deduplicationOpts['keepLastIfActive'] then
|
||||
rcall('SET', deduplicationKey, currentDeduplicatedJobId)
|
||||
else
|
||||
setDeduplicationKey(deduplicationKey, currentDeduplicatedJobId, deduplicationOpts)
|
||||
end
|
||||
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
||||
currentDeduplicatedJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
|
||||
return currentDeduplicatedJobId
|
||||
else
|
||||
if deduplicationOpts['keepLastIfActive'] then
|
||||
rcall('SET', deduplicationKey, jobId)
|
||||
else
|
||||
setDeduplicationKey(deduplicationKey, jobId, deduplicationOpts)
|
||||
end
|
||||
return
|
||||
end
|
||||
else
|
||||
if deduplicationOpts['keepLastIfActive'] then
|
||||
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
|
||||
else
|
||||
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
|
||||
end
|
||||
end
|
||||
else
|
||||
deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
|
||||
end
|
||||
|
||||
if deduplicationKeyExists then
|
||||
local currentDeduplicatedJobId = rcall('GET', deduplicationKey)
|
||||
|
||||
if storeDeduplicatedNextJob(deduplicationOpts, currentDeduplicatedJobId, prefix,
|
||||
deduplicationId, jobName, jobData, fullOpts, eventsKey, maxEvents, jobId,
|
||||
parentKey, parentData, parentDependenciesKey, repeatJobKey) then
|
||||
return currentDeduplicatedJobId
|
||||
end
|
||||
|
||||
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
|
||||
currentDeduplicatedJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
|
||||
return currentDeduplicatedJobId
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user