From d21b98063c7b5e7b7859d7ec2c10cc2b742ba4e0 Mon Sep 17 00:00:00 2001 From: roggervalf Date: Wed, 30 Oct 2024 22:05:26 -0500 Subject: [PATCH] refactor: change delay marker to -1 --- src/commands/addPrioritizedJob-8.lua | 4 ++-- src/commands/addStandardJob-8.lua | 4 ++-- src/commands/includes/addBaseMarkerIfNeeded.lua | 4 ++-- src/commands/includes/addDelayMarkerIfNeeded.lua | 2 +- src/commands/includes/addJobInTargetList.lua | 4 ++-- src/commands/includes/addJobWithPriority.lua | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/commands/addPrioritizedJob-8.lua b/src/commands/addPrioritizedJob-8.lua index 8d3105bd72..3610d0f94f 100644 --- a/src/commands/addPrioritizedJob-8.lua +++ b/src/commands/addPrioritizedJob-8.lua @@ -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", diff --git a/src/commands/addStandardJob-8.lua b/src/commands/addStandardJob-8.lua index eed0df802a..033af98abb 100644 --- a/src/commands/addStandardJob-8.lua +++ b/src/commands/addStandardJob-8.lua @@ -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", diff --git a/src/commands/includes/addBaseMarkerIfNeeded.lua b/src/commands/includes/addBaseMarkerIfNeeded.lua index 53c528fd96..036ac45d08 100644 --- a/src/commands/includes/addBaseMarkerIfNeeded.lua +++ b/src/commands/includes/addBaseMarkerIfNeeded.lua @@ -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 diff --git a/src/commands/includes/addDelayMarkerIfNeeded.lua b/src/commands/includes/addDelayMarkerIfNeeded.lua index 2f985004c9..7912232d64 100644 --- a/src/commands/includes/addDelayMarkerIfNeeded.lua +++ b/src/commands/includes/addDelayMarkerIfNeeded.lua @@ -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 diff --git a/src/commands/includes/addJobInTargetList.lua b/src/commands/includes/addJobInTargetList.lua index 7bd799239a..c915bc1b45 100644 --- a/src/commands/includes/addJobInTargetList.lua +++ b/src/commands/includes/addJobInTargetList.lua @@ -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 diff --git a/src/commands/includes/addJobWithPriority.lua b/src/commands/includes/addJobWithPriority.lua index b7de10289a..fb723293a9 100644 --- a/src/commands/includes/addJobWithPriority.lua +++ b/src/commands/includes/addJobWithPriority.lua @@ -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