Comparing version 4.12.7 to 4.12.8
@@ -0,1 +1,8 @@ | ||
## [4.12.8](https://github.com/OptimalBits/bull/compare/v4.12.7...v4.12.8) (2024-05-22) | ||
### Bug Fixes | ||
* **move-to-finished:** throw error when job is not in active state ([#2739](https://github.com/OptimalBits/bull/issues/2739)) ([7b12be1](https://github.com/OptimalBits/bull/commit/7b12be13ea39e309d6a6a39a2e56f646f06fdfa8)) | ||
## [4.12.7](https://github.com/OptimalBits/bull/compare/v4.12.6...v4.12.7) (2024-05-21) | ||
@@ -2,0 +9,0 @@ |
@@ -38,2 +38,28 @@ 'use strict'; | ||
local rcall = redis.call | ||
-- Includes | ||
--[[ | ||
Function to add job considering priority. | ||
]] | ||
local function addJobWithPriority(priorityKey, priority, jobId, targetKey) | ||
rcall("ZADD", priorityKey, priority, jobId) | ||
local count = rcall("ZCOUNT", priorityKey, 0, priority) | ||
local len = rcall("LLEN", targetKey) | ||
local id = rcall("LINDEX", targetKey, len - (count - 1)) | ||
if id then | ||
rcall("LINSERT", targetKey, "BEFORE", id, jobId) | ||
else | ||
rcall("RPUSH", targetKey, jobId) | ||
end | ||
end | ||
--[[ | ||
Function to check for the meta.paused key to decide if we are paused or not | ||
(since an empty list and !EXISTS are not really the same). | ||
]] | ||
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey) | ||
if rcall("EXISTS", queueMetaKey) ~= 1 then | ||
return waitKey, false | ||
else | ||
return pausedKey, true | ||
end | ||
end | ||
local jobCounter = rcall("INCR", KEYS[4]) | ||
@@ -63,10 +89,3 @@ if ARGV[2] == "" then | ||
-- (since an empty list and !EXISTS are not really the same) | ||
local paused | ||
if rcall("EXISTS", KEYS[3]) ~= 1 then | ||
target = KEYS[1] | ||
paused = false | ||
else | ||
target = KEYS[2] | ||
paused = true | ||
end | ||
local target, paused = getTargetQueueList(KEYS[3], KEYS[1], KEYS[2]) | ||
-- Standard or priority add | ||
@@ -78,12 +97,3 @@ local priority = tonumber(ARGV[9]) | ||
else | ||
-- Priority add | ||
rcall("ZADD", KEYS[6], priority, jobId) | ||
local count = rcall("ZCOUNT", KEYS[6], 0, priority) | ||
local len = rcall("LLEN", target) | ||
local id = rcall("LINDEX", target, len - (count-1)) | ||
if id then | ||
rcall("LINSERT", target, "BEFORE", id, jobId) | ||
else | ||
rcall("RPUSH", target, jobId) | ||
end | ||
addJobWithPriority(KEYS[6], priority, jobId, target) | ||
end | ||
@@ -90,0 +100,0 @@ -- Emit waiting event (wait..ing@token) |
@@ -20,2 +20,30 @@ 'use strict'; | ||
local rcall = redis.call | ||
-- Includes | ||
--[[ | ||
Function to loop in batches. | ||
Just a bit of warning, some commands as ZREM | ||
could receive a maximum of 7000 parameters per call. | ||
]] | ||
local function batches(n, batchSize) | ||
local i = 0 | ||
return function() | ||
local from = i * batchSize + 1 | ||
i = i + 1 | ||
if (from <= n) then | ||
local to = math.min(from + batchSize - 1, n) | ||
return from, to | ||
end | ||
end | ||
end | ||
--[[ | ||
Function to check for the meta.paused key to decide if we are paused or not | ||
(since an empty list and !EXISTS are not really the same). | ||
]] | ||
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey) | ||
if rcall("EXISTS", queueMetaKey) ~= 1 then | ||
return waitKey, false | ||
else | ||
return pausedKey, true | ||
end | ||
end | ||
local function removeJob(jobId, baseKey) | ||
@@ -41,13 +69,2 @@ local jobKey = baseKey .. jobId | ||
end | ||
local function batches(n, batchSize) | ||
local i = 0 | ||
return function() | ||
local from = i * batchSize + 1 | ||
i = i + 1 | ||
if (from <= n) then | ||
local to = math.min(from + batchSize - 1, n) | ||
return from, to | ||
end | ||
end | ||
end | ||
-- Check if we need to check for stalled jobs now. | ||
@@ -63,9 +80,2 @@ if rcall("EXISTS", KEYS[5]) == 1 then | ||
if(#stalling > 0) then | ||
local dst | ||
-- wait or paused destination | ||
if rcall("EXISTS", KEYS[6]) ~= 1 then | ||
dst = KEYS[2] | ||
else | ||
dst = KEYS[7] | ||
end | ||
rcall('DEL', KEYS[1]) | ||
@@ -113,4 +123,5 @@ local MAX_STALLED_JOB_COUNT = tonumber(ARGV[1]) | ||
else | ||
local target = getTargetQueueList(KEYS[6], KEYS[2], KEYS[7]) | ||
-- Move the job back to the wait queue, to immediately be picked up by a waiting worker. | ||
rcall("RPUSH", dst, jobId) | ||
rcall("RPUSH", target, jobId) | ||
rcall('PUBLISH', KEYS[1] .. '@', jobId) | ||
@@ -117,0 +128,0 @@ table.insert(stalled, jobId) |
@@ -80,4 +80,5 @@ 'use strict'; | ||
end | ||
-- Remove from active list | ||
rcall("LREM", KEYS[1], -1, ARGV[1]) | ||
-- Remove from active list (if not active we shall return error) | ||
local numRemovedElements = rcall("LREM", KEYS[1], -1, ARGV[1]) | ||
if numRemovedElements < 1 then return -3 end | ||
-- Remove job? | ||
@@ -84,0 +85,0 @@ local keepJobs = cmsgpack.unpack(ARGV[6]) |
@@ -18,12 +18,18 @@ 'use strict'; | ||
local rcall = redis.call; | ||
-- Includes | ||
--[[ | ||
Function to loop in batches. | ||
Just a bit of warning, some commands as ZREM | ||
could receive a maximum of 7000 parameters per call. | ||
]] | ||
local function batches(n, batchSize) | ||
local i = 0 | ||
return function() | ||
local from = i * batchSize + 1 | ||
i = i + 1 | ||
if (from <= n) then | ||
local to = math.min(from + batchSize - 1, n) | ||
return from, to | ||
end | ||
local i = 0 | ||
return function() | ||
local from = i * batchSize + 1 | ||
i = i + 1 | ||
if (from <= n) then | ||
local to = math.min(from + batchSize - 1, n) | ||
return from, to | ||
end | ||
end | ||
end | ||
@@ -30,0 +36,0 @@ local function getZSetItems(keyName, max) |
@@ -19,2 +19,28 @@ 'use strict'; | ||
local rcall = redis.call; | ||
-- Includes | ||
--[[ | ||
Function to add job considering priority. | ||
]] | ||
local function addJobWithPriority(priorityKey, priority, jobId, targetKey) | ||
rcall("ZADD", priorityKey, priority, jobId) | ||
local count = rcall("ZCOUNT", priorityKey, 0, priority) | ||
local len = rcall("LLEN", targetKey) | ||
local id = rcall("LINDEX", targetKey, len - (count - 1)) | ||
if id then | ||
rcall("LINSERT", targetKey, "BEFORE", id, jobId) | ||
else | ||
rcall("RPUSH", targetKey, jobId) | ||
end | ||
end | ||
--[[ | ||
Function to check for the meta.paused key to decide if we are paused or not | ||
(since an empty list and !EXISTS are not really the same). | ||
]] | ||
local function getTargetQueueList(queueMetaKey, waitKey, pausedKey) | ||
if rcall("EXISTS", queueMetaKey) ~= 1 then | ||
return waitKey, false | ||
else | ||
return pausedKey, true | ||
end | ||
end | ||
-- Try to get as much as 1000 jobs at once | ||
@@ -25,8 +51,3 @@ local jobs = rcall("ZRANGEBYSCORE", KEYS[1], 0, tonumber(ARGV[2]) * 0x1000, "LIMIT", 0, 1000) | ||
-- check if we need to use push in paused instead of waiting | ||
local target; | ||
if rcall("EXISTS", KEYS[6]) ~= 1 then | ||
target = KEYS[3] | ||
else | ||
target = KEYS[5] | ||
end | ||
local target = getTargetQueueList(KEYS[6], KEYS[3], KEYS[5]) | ||
for _, jobId in ipairs(jobs) do | ||
@@ -40,12 +61,3 @@ -- Is this really needed? | ||
else | ||
-- Priority add | ||
rcall("ZADD", KEYS[4], priority, jobId) | ||
local count = rcall("ZCOUNT", KEYS[4], 0, priority) | ||
local len = rcall("LLEN", target) | ||
local id = rcall("LINDEX", target, len - (count-1)) | ||
if id then | ||
rcall("LINSERT", target, "BEFORE", id, jobId) | ||
else | ||
rcall("RPUSH", target, jobId) | ||
end | ||
addJobWithPriority(KEYS[4], priority, jobId, target) | ||
end | ||
@@ -52,0 +64,0 @@ -- Emit waiting event (wait..ing@token) |
{ | ||
"name": "bull", | ||
"version": "4.12.7", | ||
"version": "4.12.8", | ||
"description": "Job manager", | ||
@@ -5,0 +5,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
293404
74
6004