-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(priority): consider paused state when calling getCountsPerPriority (
- Loading branch information
1 parent
79113ac
commit 6c2719a
Showing
4 changed files
with
65 additions
and
26 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--[[ | ||
Get counts per provided states | ||
Input: | ||
KEYS[1] wait key | ||
KEYS[2] paused key | ||
KEYS[3] meta-paused key | ||
KEYS[4] priority key | ||
ARGV[1...] priorities | ||
]] | ||
local rcall = redis.call | ||
local results = {} | ||
local prioritizedKey = KEYS[4] | ||
|
||
-- Includes | ||
--- @include "includes/getTargetQueueList" | ||
|
||
for i = 1, #ARGV do | ||
local priority = tonumber(ARGV[i]) | ||
if priority == 0 then | ||
local target = getTargetQueueList(KEYS[3], KEYS[1], KEYS[2]) | ||
local count = rcall("LLEN", target) - rcall("ZCARD", prioritizedKey) | ||
if count < 0 then | ||
-- considering when last waiting job is moved to active before | ||
-- removing priority reference | ||
results[#results+1] = 0 | ||
else | ||
results[#results+1] = count | ||
end | ||
else | ||
results[#results+1] = rcall("ZCOUNT", prioritizedKey, | ||
priority, priority) | ||
end | ||
end | ||
|
||
return results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters