Skip to content

Commit

Permalink
refactor: change delay marker to -1
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Nov 1, 2024
1 parent 34732b5 commit d21b980
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/commands/addPrioritizedJob-8.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ local delay, priority = storeJob(eventsKey, jobIdKey, jobId, args[3], ARGV[2],

-- Add the job to the prioritized set
local isPausedOrMaxed = isQueuePausedOrMaxed(metaKey, activeKey)
local markerScore = jobCounter % (markerCount or 1)
addJobWithPriority( KEYS[1], priorityKey, priority, jobId, priorityCounterKey, isPausedOrMaxed, markerScore)
local markerMember = jobCounter % (markerCount or 1)
addJobWithPriority( KEYS[1], priorityKey, priority, jobId, priorityCounterKey, isPausedOrMaxed, markerMember)

-- Emit waiting event
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/addStandardJob-8.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ local target, isPausedOrMaxed = getTargetQueueList(metaKey, KEYS[6], KEYS[1], KE

-- LIFO or FIFO
local pushCmd = opts['lifo'] and 'RPUSH' or 'LPUSH'
local markerScore = jobCounter % (markerCount or 1)
addJobInTargetList(target, KEYS[8], pushCmd, isPausedOrMaxed, jobId, markerScore)
local markerMember = jobCounter % (markerCount or 1)
addJobInTargetList(target, KEYS[8], pushCmd, isPausedOrMaxed, jobId, markerMember)

-- Emit waiting event
rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "waiting",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/includes/addBaseMarkerIfNeeded.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Add marker if needed when a job is available.
]]

local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed, markerScore)
local function addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed, markerMember)
if not isPausedOrMaxed then
rcall("ZADD", markerKey, markerScore, "0")
rcall("ZADD", markerKey, 0, markerMember)
end
end
2 changes: 1 addition & 1 deletion src/commands/includes/addDelayMarkerIfNeeded.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ local function addDelayMarkerIfNeeded(markerKey, delayedKey)
if nextTimestamp ~= nil then
-- Replace the score of the marker with the newest known
-- next timestamp.
rcall("ZADD", markerKey, nextTimestamp, "1")
rcall("ZADD", markerKey, nextTimestamp, "-1")
end
end
4 changes: 2 additions & 2 deletions src/commands/includes/addJobInTargetList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
-- Includes
--- @include "addBaseMarkerIfNeeded"

local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId, markerScore)
local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed, jobId, markerMember)
rcall(pushCmd, targetKey, jobId)
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed, markerScore)
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed, markerMember)
end
4 changes: 2 additions & 2 deletions src/commands/includes/addJobWithPriority.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
--- @include "addBaseMarkerIfNeeded"

local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, priorityCounterKey,
isPausedOrMaxed, markerScore)
isPausedOrMaxed, markerMember)
local prioCounter = rcall("INCR", priorityCounterKey)
local score = priority * 0x100000000 + prioCounter % 0x100000000
rcall("ZADD", prioritizedKey, score, jobId)
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed, markerScore)
addBaseMarkerIfNeeded(markerKey, isPausedOrMaxed, markerMember)
end

0 comments on commit d21b980

Please sign in to comment.