bullmq 3.3.1 → 3.3.2
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/commands/includes/getRateLimitTTL.lua +1 -1
- package/dist/cjs/commands/includes/moveJobFromWaitToActive.lua +6 -9
- package/dist/cjs/commands/moveJobFromActiveToWait-4.lua +1 -1
- package/dist/cjs/scripts/moveJobFromActiveToWait-4.js +1 -1
- package/dist/cjs/scripts/moveToActive-9.js +7 -9
- package/dist/cjs/scripts/moveToActive-9.js.map +1 -1
- package/dist/cjs/scripts/moveToFinished-12.js +7 -9
- package/dist/cjs/scripts/moveToFinished-12.js.map +1 -1
- package/dist/esm/commands/includes/getRateLimitTTL.lua +1 -1
- package/dist/esm/commands/includes/moveJobFromWaitToActive.lua +6 -9
- package/dist/esm/commands/moveJobFromActiveToWait-4.lua +1 -1
- package/dist/esm/scripts/moveJobFromActiveToWait-4.js +1 -1
- package/dist/esm/scripts/moveToActive-9.js +7 -9
- package/dist/esm/scripts/moveToActive-9.js.map +1 -1
- package/dist/esm/scripts/moveToFinished-12.js +7 -9
- package/dist/esm/scripts/moveToFinished-12.js.map +1 -1
- package/package.json +1 -1
@@ -3,7 +3,7 @@ local function getRateLimitTTL(opts, limiterKey)
|
|
3
3
|
if maxJobs then
|
4
4
|
local jobCounter = tonumber(rcall("GET", limiterKey))
|
5
5
|
if jobCounter ~= nil and jobCounter >= maxJobs then
|
6
|
-
local pttl = rcall("PTTL",
|
6
|
+
local pttl = rcall("PTTL", limiterKey)
|
7
7
|
if pttl > 0 then
|
8
8
|
return pttl
|
9
9
|
end
|
@@ -26,29 +26,26 @@ local function moveJobFromWaitToActive(keys, keyPrefix, jobId, processedOn, opts
|
|
26
26
|
local rateLimiterKey = keys[6];
|
27
27
|
|
28
28
|
expireTime = tonumber(rcall("PTTL", rateLimiterKey))
|
29
|
-
if expireTime
|
29
|
+
if expireTime <= 0 then
|
30
|
+
rcall("DEL", rateLimiterKey)
|
31
|
+
end
|
30
32
|
|
31
33
|
local jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
32
34
|
|
33
35
|
if jobCounter == 1 then
|
34
36
|
local limiterDuration = opts['limiter'] and opts['limiter']['duration']
|
35
|
-
|
37
|
+
local integerDuration = math.floor(math.abs(limiterDuration))
|
38
|
+
rcall("PEXPIRE", rateLimiterKey, integerDuration)
|
36
39
|
end
|
37
40
|
|
38
41
|
-- check if we passed rate limit, we need to remove the job and return expireTime
|
39
|
-
if jobCounter > maxJobs then
|
40
|
-
expireTime = rcall("PTTL", rateLimiterKey)
|
41
|
-
|
42
|
+
if jobCounter > maxJobs then
|
42
43
|
-- remove from active queue and add back to the wait list
|
43
44
|
rcall("LREM", keys[2], 1, jobId)
|
44
45
|
rcall("RPUSH", keys[1], jobId)
|
45
46
|
|
46
47
|
-- Return when we can process more jobs
|
47
48
|
return {0, 0, expireTime}
|
48
|
-
else
|
49
|
-
if jobCounter == maxJobs then
|
50
|
-
expireTime = rcall("PTTL", rateLimiterKey)
|
51
|
-
end
|
52
49
|
end
|
53
50
|
end
|
54
51
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.moveJobFromActiveToWait = void 0;
|
4
4
|
const content = `--[[
|
5
|
-
Function to move job from
|
5
|
+
Function to move job from active state to wait.
|
6
6
|
Input:
|
7
7
|
keys[1] active key
|
8
8
|
keys[2] wait key
|
@@ -53,24 +53,22 @@ local function moveJobFromWaitToActive(keys, keyPrefix, jobId, processedOn, opts
|
|
53
53
|
if(maxJobs) then
|
54
54
|
local rateLimiterKey = keys[6];
|
55
55
|
expireTime = tonumber(rcall("PTTL", rateLimiterKey))
|
56
|
-
if expireTime
|
56
|
+
if expireTime <= 0 then
|
57
|
+
rcall("DEL", rateLimiterKey)
|
58
|
+
end
|
57
59
|
local jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
58
60
|
if jobCounter == 1 then
|
59
61
|
local limiterDuration = opts['limiter'] and opts['limiter']['duration']
|
60
|
-
|
62
|
+
local integerDuration = math.floor(math.abs(limiterDuration))
|
63
|
+
rcall("PEXPIRE", rateLimiterKey, integerDuration)
|
61
64
|
end
|
62
65
|
-- check if we passed rate limit, we need to remove the job and return expireTime
|
63
|
-
if jobCounter > maxJobs then
|
64
|
-
expireTime = rcall("PTTL", rateLimiterKey)
|
66
|
+
if jobCounter > maxJobs then
|
65
67
|
-- remove from active queue and add back to the wait list
|
66
68
|
rcall("LREM", keys[2], 1, jobId)
|
67
69
|
rcall("RPUSH", keys[1], jobId)
|
68
70
|
-- Return when we can process more jobs
|
69
71
|
return {0, 0, expireTime}
|
70
|
-
else
|
71
|
-
if jobCounter == maxJobs then
|
72
|
-
expireTime = rcall("PTTL", rateLimiterKey)
|
73
|
-
end
|
74
72
|
end
|
75
73
|
end
|
76
74
|
local jobKey = keyPrefix .. jobId
|
@@ -160,7 +158,7 @@ local function getRateLimitTTL(opts, limiterKey)
|
|
160
158
|
if maxJobs then
|
161
159
|
local jobCounter = tonumber(rcall("GET", limiterKey))
|
162
160
|
if jobCounter ~= nil and jobCounter >= maxJobs then
|
163
|
-
local pttl = rcall("PTTL",
|
161
|
+
local pttl = rcall("PTTL", limiterKey)
|
164
162
|
if pttl > 0 then
|
165
163
|
return pttl
|
166
164
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToActive-9.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-9.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToActive-9.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-9.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwMf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -139,24 +139,22 @@ local function moveJobFromWaitToActive(keys, keyPrefix, jobId, processedOn, opts
|
|
139
139
|
if(maxJobs) then
|
140
140
|
local rateLimiterKey = keys[6];
|
141
141
|
expireTime = tonumber(rcall("PTTL", rateLimiterKey))
|
142
|
-
if expireTime
|
142
|
+
if expireTime <= 0 then
|
143
|
+
rcall("DEL", rateLimiterKey)
|
144
|
+
end
|
143
145
|
local jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
144
146
|
if jobCounter == 1 then
|
145
147
|
local limiterDuration = opts['limiter'] and opts['limiter']['duration']
|
146
|
-
|
148
|
+
local integerDuration = math.floor(math.abs(limiterDuration))
|
149
|
+
rcall("PEXPIRE", rateLimiterKey, integerDuration)
|
147
150
|
end
|
148
151
|
-- check if we passed rate limit, we need to remove the job and return expireTime
|
149
|
-
if jobCounter > maxJobs then
|
150
|
-
expireTime = rcall("PTTL", rateLimiterKey)
|
152
|
+
if jobCounter > maxJobs then
|
151
153
|
-- remove from active queue and add back to the wait list
|
152
154
|
rcall("LREM", keys[2], 1, jobId)
|
153
155
|
rcall("RPUSH", keys[1], jobId)
|
154
156
|
-- Return when we can process more jobs
|
155
157
|
return {0, 0, expireTime}
|
156
|
-
else
|
157
|
-
if jobCounter == maxJobs then
|
158
|
-
expireTime = rcall("PTTL", rateLimiterKey)
|
159
|
-
end
|
160
158
|
end
|
161
159
|
end
|
162
160
|
local jobKey = keyPrefix .. jobId
|
@@ -420,7 +418,7 @@ local function getRateLimitTTL(opts, limiterKey)
|
|
420
418
|
if maxJobs then
|
421
419
|
local jobCounter = tonumber(rcall("GET", limiterKey))
|
422
420
|
if jobCounter ~= nil and jobCounter >= maxJobs then
|
423
|
-
local pttl = rcall("PTTL",
|
421
|
+
local pttl = rcall("PTTL", limiterKey)
|
424
422
|
if pttl > 0 then
|
425
423
|
return pttl
|
426
424
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToFinished-12.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-12.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToFinished-12.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-12.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0iBf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -3,7 +3,7 @@ local function getRateLimitTTL(opts, limiterKey)
|
|
3
3
|
if maxJobs then
|
4
4
|
local jobCounter = tonumber(rcall("GET", limiterKey))
|
5
5
|
if jobCounter ~= nil and jobCounter >= maxJobs then
|
6
|
-
local pttl = rcall("PTTL",
|
6
|
+
local pttl = rcall("PTTL", limiterKey)
|
7
7
|
if pttl > 0 then
|
8
8
|
return pttl
|
9
9
|
end
|
@@ -26,29 +26,26 @@ local function moveJobFromWaitToActive(keys, keyPrefix, jobId, processedOn, opts
|
|
26
26
|
local rateLimiterKey = keys[6];
|
27
27
|
|
28
28
|
expireTime = tonumber(rcall("PTTL", rateLimiterKey))
|
29
|
-
if expireTime
|
29
|
+
if expireTime <= 0 then
|
30
|
+
rcall("DEL", rateLimiterKey)
|
31
|
+
end
|
30
32
|
|
31
33
|
local jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
32
34
|
|
33
35
|
if jobCounter == 1 then
|
34
36
|
local limiterDuration = opts['limiter'] and opts['limiter']['duration']
|
35
|
-
|
37
|
+
local integerDuration = math.floor(math.abs(limiterDuration))
|
38
|
+
rcall("PEXPIRE", rateLimiterKey, integerDuration)
|
36
39
|
end
|
37
40
|
|
38
41
|
-- check if we passed rate limit, we need to remove the job and return expireTime
|
39
|
-
if jobCounter > maxJobs then
|
40
|
-
expireTime = rcall("PTTL", rateLimiterKey)
|
41
|
-
|
42
|
+
if jobCounter > maxJobs then
|
42
43
|
-- remove from active queue and add back to the wait list
|
43
44
|
rcall("LREM", keys[2], 1, jobId)
|
44
45
|
rcall("RPUSH", keys[1], jobId)
|
45
46
|
|
46
47
|
-- Return when we can process more jobs
|
47
48
|
return {0, 0, expireTime}
|
48
|
-
else
|
49
|
-
if jobCounter == maxJobs then
|
50
|
-
expireTime = rcall("PTTL", rateLimiterKey)
|
51
|
-
end
|
52
49
|
end
|
53
50
|
end
|
54
51
|
|
@@ -50,24 +50,22 @@ local function moveJobFromWaitToActive(keys, keyPrefix, jobId, processedOn, opts
|
|
50
50
|
if(maxJobs) then
|
51
51
|
local rateLimiterKey = keys[6];
|
52
52
|
expireTime = tonumber(rcall("PTTL", rateLimiterKey))
|
53
|
-
if expireTime
|
53
|
+
if expireTime <= 0 then
|
54
|
+
rcall("DEL", rateLimiterKey)
|
55
|
+
end
|
54
56
|
local jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
55
57
|
if jobCounter == 1 then
|
56
58
|
local limiterDuration = opts['limiter'] and opts['limiter']['duration']
|
57
|
-
|
59
|
+
local integerDuration = math.floor(math.abs(limiterDuration))
|
60
|
+
rcall("PEXPIRE", rateLimiterKey, integerDuration)
|
58
61
|
end
|
59
62
|
-- check if we passed rate limit, we need to remove the job and return expireTime
|
60
|
-
if jobCounter > maxJobs then
|
61
|
-
expireTime = rcall("PTTL", rateLimiterKey)
|
63
|
+
if jobCounter > maxJobs then
|
62
64
|
-- remove from active queue and add back to the wait list
|
63
65
|
rcall("LREM", keys[2], 1, jobId)
|
64
66
|
rcall("RPUSH", keys[1], jobId)
|
65
67
|
-- Return when we can process more jobs
|
66
68
|
return {0, 0, expireTime}
|
67
|
-
else
|
68
|
-
if jobCounter == maxJobs then
|
69
|
-
expireTime = rcall("PTTL", rateLimiterKey)
|
70
|
-
end
|
71
69
|
end
|
72
70
|
end
|
73
71
|
local jobKey = keyPrefix .. jobId
|
@@ -157,7 +155,7 @@ local function getRateLimitTTL(opts, limiterKey)
|
|
157
155
|
if maxJobs then
|
158
156
|
local jobCounter = tonumber(rcall("GET", limiterKey))
|
159
157
|
if jobCounter ~= nil and jobCounter >= maxJobs then
|
160
|
-
local pttl = rcall("PTTL",
|
158
|
+
local pttl = rcall("PTTL", limiterKey)
|
161
159
|
if pttl > 0 then
|
162
160
|
return pttl
|
163
161
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToActive-9.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-9.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToActive-9.js","sourceRoot":"","sources":["../../../src/scripts/moveToActive-9.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwMf,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -136,24 +136,22 @@ local function moveJobFromWaitToActive(keys, keyPrefix, jobId, processedOn, opts
|
|
136
136
|
if(maxJobs) then
|
137
137
|
local rateLimiterKey = keys[6];
|
138
138
|
expireTime = tonumber(rcall("PTTL", rateLimiterKey))
|
139
|
-
if expireTime
|
139
|
+
if expireTime <= 0 then
|
140
|
+
rcall("DEL", rateLimiterKey)
|
141
|
+
end
|
140
142
|
local jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
141
143
|
if jobCounter == 1 then
|
142
144
|
local limiterDuration = opts['limiter'] and opts['limiter']['duration']
|
143
|
-
|
145
|
+
local integerDuration = math.floor(math.abs(limiterDuration))
|
146
|
+
rcall("PEXPIRE", rateLimiterKey, integerDuration)
|
144
147
|
end
|
145
148
|
-- check if we passed rate limit, we need to remove the job and return expireTime
|
146
|
-
if jobCounter > maxJobs then
|
147
|
-
expireTime = rcall("PTTL", rateLimiterKey)
|
149
|
+
if jobCounter > maxJobs then
|
148
150
|
-- remove from active queue and add back to the wait list
|
149
151
|
rcall("LREM", keys[2], 1, jobId)
|
150
152
|
rcall("RPUSH", keys[1], jobId)
|
151
153
|
-- Return when we can process more jobs
|
152
154
|
return {0, 0, expireTime}
|
153
|
-
else
|
154
|
-
if jobCounter == maxJobs then
|
155
|
-
expireTime = rcall("PTTL", rateLimiterKey)
|
156
|
-
end
|
157
155
|
end
|
158
156
|
end
|
159
157
|
local jobKey = keyPrefix .. jobId
|
@@ -417,7 +415,7 @@ local function getRateLimitTTL(opts, limiterKey)
|
|
417
415
|
if maxJobs then
|
418
416
|
local jobCounter = tonumber(rcall("GET", limiterKey))
|
419
417
|
if jobCounter ~= nil and jobCounter >= maxJobs then
|
420
|
-
local pttl = rcall("PTTL",
|
418
|
+
local pttl = rcall("PTTL", limiterKey)
|
421
419
|
if pttl > 0 then
|
422
420
|
return pttl
|
423
421
|
end
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"moveToFinished-12.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-12.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG
|
1
|
+
{"version":3,"file":"moveToFinished-12.js","sourceRoot":"","sources":["../../../src/scripts/moveToFinished-12.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0iBf,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|