bullmq 5.8.5 → 5.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/classes/job.js +6 -3
- package/dist/cjs/classes/job.js.map +1 -1
- package/dist/cjs/classes/scripts.js +2 -25
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/commands/addDelayedJob-6.lua +4 -9
- package/dist/cjs/commands/changeDelay-4.lua +7 -9
- package/dist/cjs/commands/includes/getDelayedScore.lua +25 -0
- package/dist/cjs/commands/includes/getNextDelayedTimestamp.lua +2 -3
- package/dist/cjs/commands/includes/promoteDelayedJobs.lua +1 -1
- package/dist/cjs/commands/moveToDelayed-8.lua +15 -19
- package/dist/cjs/scripts/addDelayedJob-6.js +29 -11
- package/dist/cjs/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/cjs/scripts/addParentJob-4.js +2 -3
- package/dist/cjs/scripts/addParentJob-4.js.map +1 -1
- package/dist/cjs/scripts/addPrioritizedJob-7.js +2 -3
- package/dist/cjs/scripts/addPrioritizedJob-7.js.map +1 -1
- package/dist/cjs/scripts/addStandardJob-7.js +2 -3
- package/dist/cjs/scripts/addStandardJob-7.js.map +1 -1
- package/dist/cjs/scripts/changeDelay-4.js +31 -18
- package/dist/cjs/scripts/changeDelay-4.js.map +1 -1
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js +2 -3
- package/dist/cjs/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/cjs/scripts/moveToActive-11.js +3 -4
- package/dist/cjs/scripts/moveToActive-11.js.map +1 -1
- package/dist/cjs/scripts/moveToDelayed-8.js +39 -27
- package/dist/cjs/scripts/moveToDelayed-8.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-14.js +3 -4
- package/dist/cjs/scripts/moveToFinished-14.js.map +1 -1
- package/dist/cjs/scripts/pause-7.js +2 -3
- package/dist/cjs/scripts/pause-7.js.map +1 -1
- package/dist/cjs/scripts/retryJob-11.js +1 -1
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/esm/classes/job.js +6 -3
- package/dist/esm/classes/job.js.map +1 -1
- package/dist/esm/classes/scripts.js +2 -25
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/commands/addDelayedJob-6.lua +4 -9
- package/dist/esm/commands/changeDelay-4.lua +7 -9
- package/dist/esm/commands/includes/getDelayedScore.lua +25 -0
- package/dist/esm/commands/includes/getNextDelayedTimestamp.lua +2 -3
- package/dist/esm/commands/includes/promoteDelayedJobs.lua +1 -1
- package/dist/esm/commands/moveToDelayed-8.lua +15 -19
- package/dist/esm/scripts/addDelayedJob-6.js +29 -11
- package/dist/esm/scripts/addDelayedJob-6.js.map +1 -1
- package/dist/esm/scripts/addParentJob-4.js +2 -3
- package/dist/esm/scripts/addParentJob-4.js.map +1 -1
- package/dist/esm/scripts/addPrioritizedJob-7.js +2 -3
- package/dist/esm/scripts/addPrioritizedJob-7.js.map +1 -1
- package/dist/esm/scripts/addStandardJob-7.js +2 -3
- package/dist/esm/scripts/addStandardJob-7.js.map +1 -1
- package/dist/esm/scripts/changeDelay-4.js +31 -18
- package/dist/esm/scripts/changeDelay-4.js.map +1 -1
- package/dist/esm/scripts/moveStalledJobsToWait-9.js +2 -3
- package/dist/esm/scripts/moveStalledJobsToWait-9.js.map +1 -1
- package/dist/esm/scripts/moveToActive-11.js +3 -4
- package/dist/esm/scripts/moveToActive-11.js.map +1 -1
- package/dist/esm/scripts/moveToDelayed-8.js +39 -27
- package/dist/esm/scripts/moveToDelayed-8.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-14.js +3 -4
- package/dist/esm/scripts/moveToFinished-14.js.map +1 -1
- package/dist/esm/scripts/pause-7.js +2 -3
- package/dist/esm/scripts/pause-7.js.map +1 -1
- package/dist/esm/scripts/retryJob-11.js +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addPrioritizedJob-7.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-7.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addPrioritizedJob-7.js","sourceRoot":"","sources":["../../../src/scripts/addPrioritizedJob-7.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Rf,CAAC;AACW,QAAA,iBAAiB,GAAG;IAC/B,IAAI,EAAE,mBAAmB;IACzB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -119,10 +119,9 @@ local function getNextDelayedTimestamp(delayedKey)
|
|
119
119
|
local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
|
120
120
|
if #result then
|
121
121
|
local nextTimestamp = tonumber(result[2])
|
122
|
-
if
|
123
|
-
|
122
|
+
if nextTimestamp ~= nil then
|
123
|
+
return nextTimestamp / 0x1000
|
124
124
|
end
|
125
|
-
return nextTimestamp
|
126
125
|
end
|
127
126
|
end
|
128
127
|
local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addStandardJob-7.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-7.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"addStandardJob-7.js","sourceRoot":"","sources":["../../../src/scripts/addStandardJob-7.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Rf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -9,7 +9,7 @@ const content = `--[[
|
|
9
9
|
KEYS[3] marker key
|
10
10
|
KEYS[4] events stream
|
11
11
|
ARGV[1] delay
|
12
|
-
ARGV[2]
|
12
|
+
ARGV[2] timestamp
|
13
13
|
ARGV[3] the id of the job
|
14
14
|
ARGV[4] job key
|
15
15
|
Output:
|
@@ -32,10 +32,9 @@ local function getNextDelayedTimestamp(delayedKey)
|
|
32
32
|
local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
|
33
33
|
if #result then
|
34
34
|
local nextTimestamp = tonumber(result[2])
|
35
|
-
if
|
36
|
-
|
35
|
+
if nextTimestamp ~= nil then
|
36
|
+
return nextTimestamp / 0x1000
|
37
37
|
end
|
38
|
-
return nextTimestamp
|
39
38
|
end
|
40
39
|
end
|
41
40
|
local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
@@ -46,6 +45,30 @@ local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
|
46
45
|
rcall("ZADD", markerKey, nextTimestamp, "1")
|
47
46
|
end
|
48
47
|
end
|
48
|
+
--[[
|
49
|
+
Bake in the job id first 12 bits into the timestamp
|
50
|
+
to guarantee correct execution order of delayed jobs
|
51
|
+
(up to 4096 jobs per given timestamp or 4096 jobs apart per timestamp)
|
52
|
+
WARNING: Jobs that are so far apart that they wrap around will cause FIFO to fail
|
53
|
+
]]
|
54
|
+
local function getDelayedScore(delayedKey, timestamp, delay)
|
55
|
+
local delayedTimestamp = (delay > 0 and (tonumber(timestamp) + delay)) or tonumber(timestamp)
|
56
|
+
local minScore = delayedTimestamp * 0x1000
|
57
|
+
local maxScore = (delayedTimestamp + 1 ) * 0x1000 - 1
|
58
|
+
local result = rcall("ZREVRANGEBYSCORE", delayedKey, maxScore,
|
59
|
+
minScore, "WITHSCORES","LIMIT", 0, 1)
|
60
|
+
if #result then
|
61
|
+
local currentMaxScore = tonumber(result[2])
|
62
|
+
if currentMaxScore ~= nil then
|
63
|
+
if currentMaxScore >= maxScore then
|
64
|
+
return maxScore, delayedTimestamp
|
65
|
+
else
|
66
|
+
return currentMaxScore + 1, delayedTimestamp
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
return minScore, delayedTimestamp
|
71
|
+
end
|
49
72
|
--[[
|
50
73
|
Function to get max events value or set by default 10000.
|
51
74
|
]]
|
@@ -57,31 +80,21 @@ local function getOrSetMaxEvents(metaKey)
|
|
57
80
|
end
|
58
81
|
return maxEvents
|
59
82
|
end
|
60
|
-
--[[
|
61
|
-
Function to check for the meta.paused key to decide if we are paused or not
|
62
|
-
(since an empty list and !EXISTS are not really the same).
|
63
|
-
]]
|
64
|
-
local function isQueuePaused(queueMetaKey)
|
65
|
-
return rcall("HEXISTS", queueMetaKey, "paused") == 1
|
66
|
-
end
|
67
83
|
if rcall("EXISTS", ARGV[4]) == 1 then
|
68
84
|
local jobId = ARGV[3]
|
69
|
-
local
|
70
|
-
local delayedTimestamp = (
|
85
|
+
local delay = tonumber(ARGV[1])
|
86
|
+
local score, delayedTimestamp = getDelayedScore(KEYS[1], ARGV[2], delay)
|
71
87
|
local numRemovedElements = rcall("ZREM", KEYS[1], jobId)
|
72
88
|
if numRemovedElements < 1 then
|
73
89
|
return -3
|
74
90
|
end
|
75
|
-
rcall("HSET", ARGV[4], "delay",
|
91
|
+
rcall("HSET", ARGV[4], "delay", delay)
|
76
92
|
rcall("ZADD", KEYS[1], score, jobId)
|
77
93
|
local maxEvents = getOrSetMaxEvents(KEYS[2])
|
78
94
|
rcall("XADD", KEYS[4], "MAXLEN", "~", maxEvents, "*", "event", "delayed",
|
79
95
|
"jobId", jobId, "delay", delayedTimestamp)
|
80
96
|
-- mark that a delayed job is available
|
81
|
-
|
82
|
-
if not isPaused then
|
83
|
-
addDelayMarkerIfNeeded(KEYS[3], KEYS[1])
|
84
|
-
end
|
97
|
+
addDelayMarkerIfNeeded(KEYS[3], KEYS[1])
|
85
98
|
return 0
|
86
99
|
else
|
87
100
|
return -1
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"changeDelay-4.js","sourceRoot":"","sources":["../../../src/scripts/changeDelay-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"changeDelay-4.js","sourceRoot":"","sources":["../../../src/scripts/changeDelay-4.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiGZ,CAAC;AACQ,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,aAAa;IACnB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -84,10 +84,9 @@ local function getNextDelayedTimestamp(delayedKey)
|
|
84
84
|
local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
|
85
85
|
if #result then
|
86
86
|
local nextTimestamp = tonumber(result[2])
|
87
|
-
if
|
88
|
-
|
87
|
+
if nextTimestamp ~= nil then
|
88
|
+
return nextTimestamp / 0x1000
|
89
89
|
end
|
90
|
-
return nextTimestamp
|
91
90
|
end
|
92
91
|
end
|
93
92
|
local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveStalledJobsToWait-9.js","sourceRoot":"","sources":["../../../src/scripts/moveStalledJobsToWait-9.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBA2bS,CAAC;AACb,QAAA,qBAAqB,GAAG;IACnC,IAAI,EAAE,uBAAuB;IAC7B,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -45,10 +45,9 @@ local function getNextDelayedTimestamp(delayedKey)
|
|
45
45
|
local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
|
46
46
|
if #result then
|
47
47
|
local nextTimestamp = tonumber(result[2])
|
48
|
-
if
|
49
|
-
|
48
|
+
if nextTimestamp ~= nil then
|
49
|
+
return nextTimestamp / 0x1000
|
50
50
|
end
|
51
|
-
return nextTimestamp
|
52
51
|
end
|
53
52
|
end
|
54
53
|
--[[
|
@@ -160,7 +159,7 @@ end
|
|
160
159
|
-- Try to get as much as 1000 jobs at once
|
161
160
|
local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,
|
162
161
|
eventStreamKey, prefix, timestamp, priorityCounterKey, isPaused)
|
163
|
-
local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000, "LIMIT", 0, 1000)
|
162
|
+
local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000 - 1, "LIMIT", 0, 1000)
|
164
163
|
if (#jobs > 0) then
|
165
164
|
rcall("ZREM", delayedKey, unpack(jobs))
|
166
165
|
for _, jobId in ipairs(jobs) do
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToActive-11.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-11.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToActive-11.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-11.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmNf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -14,11 +14,10 @@ const content = `--[[
|
|
14
14
|
KEYS[8] stalled key
|
15
15
|
ARGV[1] key prefix
|
16
16
|
ARGV[2] timestamp
|
17
|
-
ARGV[3]
|
18
|
-
ARGV[4]
|
19
|
-
ARGV[5]
|
20
|
-
ARGV[6]
|
21
|
-
ARGV[7] skip attempt
|
17
|
+
ARGV[3] the id of the job
|
18
|
+
ARGV[4] queue token
|
19
|
+
ARGV[5] delay value
|
20
|
+
ARGV[6] skip attempt
|
22
21
|
Output:
|
23
22
|
0 - OK
|
24
23
|
-1 - Missing job.
|
@@ -39,10 +38,9 @@ local function getNextDelayedTimestamp(delayedKey)
|
|
39
38
|
local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
|
40
39
|
if #result then
|
41
40
|
local nextTimestamp = tonumber(result[2])
|
42
|
-
if
|
43
|
-
|
41
|
+
if nextTimestamp ~= nil then
|
42
|
+
return nextTimestamp / 0x1000
|
44
43
|
end
|
45
|
-
return nextTimestamp
|
46
44
|
end
|
47
45
|
end
|
48
46
|
local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
@@ -53,6 +51,30 @@ local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
|
53
51
|
rcall("ZADD", markerKey, nextTimestamp, "1")
|
54
52
|
end
|
55
53
|
end
|
54
|
+
--[[
|
55
|
+
Bake in the job id first 12 bits into the timestamp
|
56
|
+
to guarantee correct execution order of delayed jobs
|
57
|
+
(up to 4096 jobs per given timestamp or 4096 jobs apart per timestamp)
|
58
|
+
WARNING: Jobs that are so far apart that they wrap around will cause FIFO to fail
|
59
|
+
]]
|
60
|
+
local function getDelayedScore(delayedKey, timestamp, delay)
|
61
|
+
local delayedTimestamp = (delay > 0 and (tonumber(timestamp) + delay)) or tonumber(timestamp)
|
62
|
+
local minScore = delayedTimestamp * 0x1000
|
63
|
+
local maxScore = (delayedTimestamp + 1 ) * 0x1000 - 1
|
64
|
+
local result = rcall("ZREVRANGEBYSCORE", delayedKey, maxScore,
|
65
|
+
minScore, "WITHSCORES","LIMIT", 0, 1)
|
66
|
+
if #result then
|
67
|
+
local currentMaxScore = tonumber(result[2])
|
68
|
+
if currentMaxScore ~= nil then
|
69
|
+
if currentMaxScore >= maxScore then
|
70
|
+
return maxScore, delayedTimestamp
|
71
|
+
else
|
72
|
+
return currentMaxScore + 1, delayedTimestamp
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
return minScore, delayedTimestamp
|
77
|
+
end
|
56
78
|
--[[
|
57
79
|
Function to get max events value or set by default 10000.
|
58
80
|
]]
|
@@ -64,13 +86,6 @@ local function getOrSetMaxEvents(metaKey)
|
|
64
86
|
end
|
65
87
|
return maxEvents
|
66
88
|
end
|
67
|
-
--[[
|
68
|
-
Function to check for the meta.paused key to decide if we are paused or not
|
69
|
-
(since an empty list and !EXISTS are not really the same).
|
70
|
-
]]
|
71
|
-
local function isQueuePaused(queueMetaKey)
|
72
|
-
return rcall("HEXISTS", queueMetaKey, "paused") == 1
|
73
|
-
end
|
74
89
|
local function removeLock(jobKey, stalledKey, token, jobId)
|
75
90
|
if token ~= "0" then
|
76
91
|
local lockKey = jobKey .. ':lock'
|
@@ -92,32 +107,29 @@ local function removeLock(jobKey, stalledKey, token, jobId)
|
|
92
107
|
end
|
93
108
|
local jobKey = KEYS[5]
|
94
109
|
local metaKey = KEYS[7]
|
95
|
-
local token = ARGV[
|
110
|
+
local token = ARGV[4]
|
96
111
|
if rcall("EXISTS", jobKey) == 1 then
|
97
|
-
local errorCode = removeLock(jobKey, KEYS[8], token, ARGV[
|
112
|
+
local errorCode = removeLock(jobKey, KEYS[8], token, ARGV[3])
|
98
113
|
if errorCode < 0 then
|
99
114
|
return errorCode
|
100
115
|
end
|
101
116
|
local delayedKey = KEYS[4]
|
102
|
-
local jobId = ARGV[
|
103
|
-
local
|
104
|
-
local delayedTimestamp = (
|
117
|
+
local jobId = ARGV[3]
|
118
|
+
local delay = tonumber(ARGV[5])
|
119
|
+
local score, delayedTimestamp = getDelayedScore(delayedKey, ARGV[2], delay)
|
105
120
|
local numRemovedElements = rcall("LREM", KEYS[2], -1, jobId)
|
106
121
|
if numRemovedElements < 1 then return -3 end
|
107
|
-
if ARGV[
|
122
|
+
if ARGV[6] == "0" then
|
108
123
|
rcall("HINCRBY", jobKey, "atm", 1)
|
109
124
|
end
|
110
|
-
rcall("HSET", jobKey, "delay", ARGV[
|
125
|
+
rcall("HSET", jobKey, "delay", ARGV[5])
|
111
126
|
local maxEvents = getOrSetMaxEvents(metaKey)
|
112
127
|
rcall("ZADD", delayedKey, score, jobId)
|
113
128
|
rcall("XADD", KEYS[6], "MAXLEN", "~", maxEvents, "*", "event", "delayed",
|
114
129
|
"jobId", jobId, "delay", delayedTimestamp)
|
115
130
|
-- Check if we need to push a marker job to wake up sleeping workers.
|
116
|
-
local
|
117
|
-
|
118
|
-
local markerKey = KEYS[1]
|
119
|
-
addDelayMarkerIfNeeded(markerKey, delayedKey)
|
120
|
-
end
|
131
|
+
local markerKey = KEYS[1]
|
132
|
+
addDelayMarkerIfNeeded(markerKey, delayedKey)
|
121
133
|
return 0
|
122
134
|
else
|
123
135
|
return -1
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToDelayed-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToDelayed-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToDelayed-8.js","sourceRoot":"","sources":["../../../src/scripts/moveToDelayed-8.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqIf,CAAC;AACW,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -111,10 +111,9 @@ local function getNextDelayedTimestamp(delayedKey)
|
|
111
111
|
local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
|
112
112
|
if #result then
|
113
113
|
local nextTimestamp = tonumber(result[2])
|
114
|
-
if
|
115
|
-
|
114
|
+
if nextTimestamp ~= nil then
|
115
|
+
return nextTimestamp / 0x1000
|
116
116
|
end
|
117
|
-
return nextTimestamp
|
118
117
|
end
|
119
118
|
end
|
120
119
|
--[[
|
@@ -320,7 +319,7 @@ end
|
|
320
319
|
-- Try to get as much as 1000 jobs at once
|
321
320
|
local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,
|
322
321
|
eventStreamKey, prefix, timestamp, priorityCounterKey, isPaused)
|
323
|
-
local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000, "LIMIT", 0, 1000)
|
322
|
+
local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000 - 1, "LIMIT", 0, 1000)
|
324
323
|
if (#jobs > 0) then
|
325
324
|
rcall("ZREM", delayedKey, unpack(jobs))
|
326
325
|
for _, jobId in ipairs(jobs) do
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToFinished-14.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-14.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuqBf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -28,10 +28,9 @@ local function getNextDelayedTimestamp(delayedKey)
|
|
28
28
|
local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
|
29
29
|
if #result then
|
30
30
|
local nextTimestamp = tonumber(result[2])
|
31
|
-
if
|
32
|
-
|
31
|
+
if nextTimestamp ~= nil then
|
32
|
+
return nextTimestamp / 0x1000
|
33
33
|
end
|
34
|
-
return nextTimestamp
|
35
34
|
end
|
36
35
|
end
|
37
36
|
local function addDelayMarkerIfNeeded(markerKey, delayedKey)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pause-7.js","sourceRoot":"","sources":["../../../src/scripts/pause-7.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"pause-7.js","sourceRoot":"","sources":["../../../src/scripts/pause-7.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDf,CAAC;AACW,QAAA,KAAK,GAAG;IACnB,IAAI,EAAE,OAAO;IACb,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -88,7 +88,7 @@ end
|
|
88
88
|
-- Try to get as much as 1000 jobs at once
|
89
89
|
local function promoteDelayedJobs(delayedKey, markerKey, targetKey, prioritizedKey,
|
90
90
|
eventStreamKey, prefix, timestamp, priorityCounterKey, isPaused)
|
91
|
-
local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000, "LIMIT", 0, 1000)
|
91
|
+
local jobs = rcall("ZRANGEBYSCORE", delayedKey, 0, (timestamp + 1) * 0x1000 - 1, "LIMIT", 0, 1000)
|
92
92
|
if (#jobs > 0) then
|
93
93
|
rcall("ZREM", delayedKey, unpack(jobs))
|
94
94
|
for _, jobId in ipairs(jobs) do
|