Review funkt

This commit is contained in:
2026-08-09 21:56:00 +00:00
parent f522ae9953
commit fe9dfa4519
11366 changed files with 2335077 additions and 97 deletions

View 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