Projektstart
This commit is contained in:
50
backend/node_modules/bullmq/dist/cjs/scripts/extendLocks-1.js
generated
vendored
Normal file
50
backend/node_modules/bullmq/dist/cjs/scripts/extendLocks-1.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.extendLocks = void 0;
|
||||
const content = `--[[
|
||||
Extend locks for multiple jobs and remove them from the stalled set if successful.
|
||||
Return the list of job IDs for which the operation failed.
|
||||
KEYS[1] = stalled key
|
||||
ARGV[1] = baseKey
|
||||
ARGV[2] = tokens
|
||||
ARGV[3] = jobIds
|
||||
ARGV[4] = lockDuration (ms)
|
||||
Output:
|
||||
An array of failed job IDs. If empty, all succeeded.
|
||||
]]
|
||||
local rcall = redis.call
|
||||
local stalledKey = KEYS[1]
|
||||
local baseKey = ARGV[1]
|
||||
local tokens = cmsgpack.unpack(ARGV[2])
|
||||
local jobIds = cmsgpack.unpack(ARGV[3])
|
||||
local lockDuration = ARGV[4]
|
||||
local jobCount = #jobIds
|
||||
local failedJobs = {}
|
||||
for i = 1, jobCount, 1 do
|
||||
local lockKey = baseKey .. jobIds[i] .. ':lock'
|
||||
local jobId = jobIds[i]
|
||||
local token = tokens[i]
|
||||
local currentToken = rcall("GET", lockKey)
|
||||
if currentToken then
|
||||
if currentToken == token then
|
||||
local setResult = rcall("SET", lockKey, token, "PX", lockDuration)
|
||||
if setResult then
|
||||
rcall("SREM", stalledKey, jobId)
|
||||
else
|
||||
table.insert(failedJobs, jobId)
|
||||
end
|
||||
else
|
||||
table.insert(failedJobs, jobId)
|
||||
end
|
||||
else
|
||||
table.insert(failedJobs, jobId)
|
||||
end
|
||||
end
|
||||
return failedJobs
|
||||
`;
|
||||
exports.extendLocks = {
|
||||
name: 'extendLocks',
|
||||
content,
|
||||
keys: 1,
|
||||
};
|
||||
//# sourceMappingURL=extendLocks-1.js.map
|
||||
Reference in New Issue
Block a user