bullmq 3.2.2 → 3.2.4
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.d.ts +1 -1
- package/dist/cjs/classes/queue-getters.d.ts +21 -22
- package/dist/cjs/classes/queue-getters.js +21 -22
- package/dist/cjs/classes/queue-getters.js.map +1 -1
- package/dist/cjs/classes/queue-keys.d.ts +1 -1
- package/dist/cjs/classes/queue.d.ts +4 -5
- package/dist/cjs/classes/queue.js +4 -5
- package/dist/cjs/classes/queue.js.map +1 -1
- package/dist/cjs/classes/scripts.d.ts +3 -3
- package/dist/cjs/classes/worker.js +3 -3
- package/dist/cjs/classes/worker.js.map +1 -1
- package/dist/cjs/commands/addJob-8.lua +42 -41
- package/dist/cjs/commands/includes/getNextDelayedTimestamp.lua +7 -7
- package/dist/cjs/commands/includes/getRateLimitTTL.lua +10 -10
- package/dist/cjs/commands/includes/getTimestamp.lua +1 -1
- package/dist/cjs/commands/includes/isLocked.lua +12 -12
- package/dist/cjs/commands/includes/moveJobFromWaitToActive.lua +4 -0
- package/dist/cjs/interfaces/connection.d.ts +1 -1
- package/dist/cjs/interfaces/flow-job.d.ts +3 -3
- package/dist/cjs/interfaces/redis-options.d.ts +3 -3
- package/dist/cjs/interfaces/redis-streams.d.ts +4 -4
- package/dist/cjs/interfaces/sandboxed-job-processor.d.ts +1 -1
- package/dist/cjs/interfaces/worker-options.d.ts +1 -1
- package/dist/cjs/scripts/addJob-8.js +47 -47
- package/dist/cjs/scripts/moveToActive-9.js +19 -17
- package/dist/cjs/scripts/moveToActive-9.js.map +1 -1
- package/dist/cjs/scripts/moveToDelayed-8.js +7 -7
- package/dist/cjs/scripts/moveToFinished-12.js +19 -17
- package/dist/cjs/scripts/moveToFinished-12.js.map +1 -1
- package/dist/cjs/scripts/removeJob-1.js +12 -12
- package/dist/cjs/types/backoff-strategy.d.ts +1 -1
- package/dist/cjs/types/finished-status.d.ts +2 -2
- package/dist/cjs/types/job-json-sandbox.d.ts +1 -1
- package/dist/cjs/types/job-options.d.ts +2 -2
- package/dist/cjs/types/job-type.d.ts +2 -2
- package/dist/cjs/types/repeat-strategy.d.ts +1 -1
- package/dist/esm/classes/job.d.ts +1 -1
- package/dist/esm/classes/queue-getters.d.ts +21 -22
- package/dist/esm/classes/queue-getters.js +21 -22
- package/dist/esm/classes/queue-getters.js.map +1 -1
- package/dist/esm/classes/queue-keys.d.ts +1 -1
- package/dist/esm/classes/queue.d.ts +4 -5
- package/dist/esm/classes/queue.js +4 -5
- package/dist/esm/classes/queue.js.map +1 -1
- package/dist/esm/classes/scripts.d.ts +3 -3
- package/dist/esm/classes/worker.js +3 -3
- package/dist/esm/classes/worker.js.map +1 -1
- package/dist/esm/commands/addJob-8.lua +42 -41
- package/dist/esm/commands/includes/getNextDelayedTimestamp.lua +7 -7
- package/dist/esm/commands/includes/getRateLimitTTL.lua +10 -10
- package/dist/esm/commands/includes/getTimestamp.lua +1 -1
- package/dist/esm/commands/includes/isLocked.lua +12 -12
- package/dist/esm/commands/includes/moveJobFromWaitToActive.lua +4 -0
- package/dist/esm/interfaces/connection.d.ts +1 -1
- package/dist/esm/interfaces/flow-job.d.ts +3 -3
- package/dist/esm/interfaces/redis-options.d.ts +3 -3
- package/dist/esm/interfaces/redis-streams.d.ts +4 -4
- package/dist/esm/interfaces/sandboxed-job-processor.d.ts +1 -1
- package/dist/esm/interfaces/worker-options.d.ts +1 -1
- package/dist/esm/scripts/addJob-8.js +47 -47
- package/dist/esm/scripts/moveToActive-9.js +19 -17
- package/dist/esm/scripts/moveToActive-9.js.map +1 -1
- package/dist/esm/scripts/moveToDelayed-8.js +7 -7
- package/dist/esm/scripts/moveToFinished-12.js +19 -17
- package/dist/esm/scripts/moveToFinished-12.js.map +1 -1
- package/dist/esm/scripts/removeJob-1.js +12 -12
- package/dist/esm/types/backoff-strategy.d.ts +1 -1
- package/dist/esm/types/finished-status.d.ts +2 -2
- package/dist/esm/types/job-json-sandbox.d.ts +1 -1
- package/dist/esm/types/job-options.d.ts +2 -2
- package/dist/esm/types/job-type.d.ts +2 -2
- package/dist/esm/types/repeat-strategy.d.ts +1 -1
- package/package.json +1 -1
@@ -13,19 +13,19 @@ local function isLocked( prefix, jobId)
|
|
13
13
|
local lockKey = jobKey .. ':lock'
|
14
14
|
local lock = rcall("GET", lockKey)
|
15
15
|
if not lock then
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
16
|
+
local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")
|
17
|
+
if (#dependencies > 0) then
|
18
|
+
for i, childJobKey in ipairs(dependencies) do
|
19
|
+
-- We need to get the jobId for this job.
|
20
|
+
local childJobId = getJobIdFromKey(childJobKey)
|
21
|
+
local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)
|
22
|
+
local result = isLocked( childJobPrefix, childJobId )
|
23
|
+
if result then
|
24
|
+
return true
|
25
|
+
end
|
27
26
|
end
|
28
|
-
|
27
|
+
end
|
28
|
+
return false
|
29
29
|
end
|
30
30
|
return true
|
31
31
|
end
|
@@ -24,6 +24,10 @@ local function moveJobFromWaitToActive(keys, keyPrefix, jobId, processedOn, opts
|
|
24
24
|
|
25
25
|
if(maxJobs) then
|
26
26
|
local rateLimiterKey = keys[6];
|
27
|
+
|
28
|
+
expireTime = tonumber(rcall("PTTL", rateLimiterKey))
|
29
|
+
if expireTime == 0 then rcall("DEL", rateLimiterKey) end
|
30
|
+
|
27
31
|
local jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
28
32
|
|
29
33
|
if jobCounter == 1 then
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
import { EventEmitter } from 'events';
|
3
3
|
import { Cluster, Redis } from 'ioredis';
|
4
|
-
export
|
4
|
+
export type RedisClient = Redis | Cluster;
|
5
5
|
export interface IConnection extends EventEmitter {
|
6
6
|
waitUntilReady(): Promise<boolean>;
|
7
7
|
client: Promise<RedisClient>;
|
@@ -8,9 +8,9 @@ interface FlowJobBase<T> {
|
|
8
8
|
opts?: Omit<T, 'repeat'>;
|
9
9
|
children?: FlowChildJob[];
|
10
10
|
}
|
11
|
-
export
|
12
|
-
export
|
13
|
-
export
|
11
|
+
export type FlowChildJob = FlowJobBase<Omit<JobsOptions, 'parent'>>;
|
12
|
+
export type FlowJob = FlowJobBase<JobsOptions>;
|
13
|
+
export type FlowQueuesOpts = Record<string, Omit<QueueOptions, 'connection' | 'prefix'>>;
|
14
14
|
export interface FlowOpts {
|
15
15
|
/**
|
16
16
|
* Map of options for Queue classes.
|
@@ -2,7 +2,7 @@ import type * as IORedis from 'ioredis';
|
|
2
2
|
interface BaseOptions {
|
3
3
|
skipVersionCheck?: boolean;
|
4
4
|
}
|
5
|
-
export
|
6
|
-
export
|
7
|
-
export
|
5
|
+
export type RedisOptions = IORedis.RedisOptions & BaseOptions;
|
6
|
+
export type ClusterOptions = IORedis.ClusterOptions & BaseOptions;
|
7
|
+
export type ConnectionOptions = RedisOptions | ClusterOptions | IORedis.Redis | IORedis.Cluster;
|
8
8
|
export {};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export
|
2
|
-
export
|
3
|
-
export
|
4
|
-
export
|
1
|
+
export type StreamName = string;
|
2
|
+
export type EntryId = string;
|
3
|
+
export type EntryRaw = [EntryId, string[]];
|
4
|
+
export type StreamReadRaw = [StreamName, EntryRaw[]][];
|
@@ -2,4 +2,4 @@ import { SandboxedJob } from './sandboxed-job';
|
|
2
2
|
/**
|
3
3
|
* @see {@link https://docs.bullmq.io/guide/workers/sandboxed-processors}
|
4
4
|
*/
|
5
|
-
export
|
5
|
+
export type SandboxedJobProcessor<T = any, R = any> = ((job: SandboxedJob<T, R>) => R | PromiseLike<R>) | ((job: SandboxedJob<T, R>, callback: (error: unknown, result: R) => void) => void);
|
@@ -6,7 +6,7 @@ import { MetricsOptions } from './metrics-options';
|
|
6
6
|
/**
|
7
7
|
* An async function that receives `Job`s and handles them.
|
8
8
|
*/
|
9
|
-
export
|
9
|
+
export type Processor<T = any, R = any, N extends string = string> = (job: Job<T, R, N>, token?: string) => Promise<R>;
|
10
10
|
export interface WorkerOptions extends QueueBaseOptions {
|
11
11
|
/**
|
12
12
|
* Condition to start processor at instance creation.
|
@@ -91,14 +91,14 @@ end
|
|
91
91
|
Function to return the next delayed job timestamp.
|
92
92
|
]]
|
93
93
|
local function getNextDelayedTimestamp(delayedKey)
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
end
|
100
|
-
return nextTimestamp
|
94
|
+
local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
|
95
|
+
if #result then
|
96
|
+
local nextTimestamp = tonumber(result[2])
|
97
|
+
if (nextTimestamp ~= nil) then
|
98
|
+
nextTimestamp = nextTimestamp / 0x1000
|
101
99
|
end
|
100
|
+
return nextTimestamp
|
101
|
+
end
|
102
102
|
end
|
103
103
|
if parentKey ~= nil then
|
104
104
|
if rcall("EXISTS", parentKey) ~= 1 then
|
@@ -154,21 +154,21 @@ if args[2] == "" then
|
|
154
154
|
else
|
155
155
|
jobId = args[2]
|
156
156
|
jobIdKey = args[1] .. jobId
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
157
|
+
end
|
158
|
+
if rcall("EXISTS", jobIdKey) == 1 then
|
159
|
+
if parentKey ~= nil then
|
160
|
+
if rcall("ZSCORE", KEYS[7], jobId) ~= false then
|
161
|
+
local returnvalue = rcall("HGET", jobIdKey, "returnvalue")
|
162
|
+
updateParentDepsIfNeeded(parentKey, parent['queueKey'], parentDependenciesKey,
|
163
|
+
parent['id'], jobIdKey, returnvalue, timestamp)
|
164
|
+
else
|
165
|
+
if parentDependenciesKey ~= nil then
|
166
|
+
rcall("SADD", parentDependenciesKey, jobIdKey)
|
167
167
|
end
|
168
|
-
rcall("HMSET", jobIdKey, "parentKey", parentKey, "parent", parentData)
|
169
168
|
end
|
170
|
-
|
169
|
+
rcall("HMSET", jobIdKey, "parentKey", parentKey, "parent", parentData)
|
171
170
|
end
|
171
|
+
return jobId .. "" -- convert to string
|
172
172
|
end
|
173
173
|
-- Store the job.
|
174
174
|
local jsonOpts = cjson.encode(opts)
|
@@ -193,42 +193,42 @@ local delayedTimestamp = (delay > 0 and (timestamp + delay)) or 0
|
|
193
193
|
-- Check if job is a parent, if so add to the parents set
|
194
194
|
local waitChildrenKey = args[6]
|
195
195
|
if waitChildrenKey ~= nil then
|
196
|
-
|
197
|
-
|
196
|
+
rcall("ZADD", waitChildrenKey, timestamp, jobId)
|
197
|
+
rcall("XADD", KEYS[8], "*", "event", "waiting-children", "jobId", jobId)
|
198
198
|
elseif (delayedTimestamp ~= 0) then
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
end
|
199
|
+
local score = delayedTimestamp * 0x1000 + bit.band(jobCounter, 0xfff)
|
200
|
+
rcall("ZADD", KEYS[5], score, jobId)
|
201
|
+
rcall("XADD", KEYS[8], "*", "event", "delayed", "jobId", jobId, "delay",
|
202
|
+
delayedTimestamp)
|
203
|
+
-- If wait list is empty, and this delayed job is the next one to be processed,
|
204
|
+
-- then we need to signal the workers by adding a dummy job (jobId 0:delay) to the wait list.
|
205
|
+
local target = getTargetQueueList(KEYS[3], KEYS[1], KEYS[2])
|
206
|
+
if rcall("LLEN", target) == 0 then
|
207
|
+
local nextTimestamp = getNextDelayedTimestamp(KEYS[5])
|
208
|
+
if not nextTimestamp or (delayedTimestamp < nextTimestamp) then
|
209
|
+
local delay = delayedTimestamp - tonumber(timestamp)
|
210
|
+
rcall("LPUSH", target, "0:" .. delay)
|
212
211
|
end
|
212
|
+
end
|
213
213
|
else
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
214
|
+
local target = getTargetQueueList(KEYS[3], KEYS[1], KEYS[2])
|
215
|
+
-- Standard or priority add
|
216
|
+
if priority == 0 then
|
217
|
+
-- LIFO or FIFO
|
218
|
+
local pushCmd = opts['lifo'] and 'RPUSH' or 'LPUSH';
|
219
|
+
rcall(pushCmd, target, jobId)
|
220
|
+
else
|
221
|
+
-- Priority add
|
222
|
+
addJobWithPriority(KEYS[6], priority, target, jobId)
|
223
|
+
end
|
224
|
+
-- Emit waiting event
|
225
|
+
rcall("XADD", KEYS[8], "*", "event", "waiting", "jobId", jobId)
|
226
226
|
end
|
227
227
|
-- Check if this job is a child of another job, if so add it to the parents dependencies
|
228
228
|
-- TODO: Should not be possible to add a child job to a parent that is not in the "waiting-children" status.
|
229
229
|
-- fail in this case.
|
230
230
|
if parentDependenciesKey ~= nil then
|
231
|
-
|
231
|
+
rcall("SADD", parentDependenciesKey, jobIdKey)
|
232
232
|
end
|
233
233
|
return jobId .. "" -- convert to string
|
234
234
|
`;
|
@@ -52,6 +52,8 @@ local function moveJobFromWaitToActive(keys, keyPrefix, jobId, processedOn, opts
|
|
52
52
|
local expireTime
|
53
53
|
if(maxJobs) then
|
54
54
|
local rateLimiterKey = keys[6];
|
55
|
+
expireTime = tonumber(rcall("PTTL", rateLimiterKey))
|
56
|
+
if expireTime == 0 then rcall("DEL", rateLimiterKey) end
|
55
57
|
local jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
56
58
|
if jobCounter == 1 then
|
57
59
|
local limiterDuration = opts['limiter'] and opts['limiter']['duration']
|
@@ -87,14 +89,14 @@ end
|
|
87
89
|
Function to return the next delayed job timestamp.
|
88
90
|
]]
|
89
91
|
local function getNextDelayedTimestamp(delayedKey)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
96
|
-
return nextTimestamp
|
92
|
+
local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
|
93
|
+
if #result then
|
94
|
+
local nextTimestamp = tonumber(result[2])
|
95
|
+
if (nextTimestamp ~= nil) then
|
96
|
+
nextTimestamp = nextTimestamp / 0x1000
|
97
97
|
end
|
98
|
+
return nextTimestamp
|
99
|
+
end
|
98
100
|
end
|
99
101
|
--[[
|
100
102
|
Updates the delay set, by moving delayed jobs that should
|
@@ -154,17 +156,17 @@ local function promoteDelayedJobs(delayedKey, waitKey, priorityKey, pausedKey,
|
|
154
156
|
end
|
155
157
|
end
|
156
158
|
local function getRateLimitTTL(opts, limiterKey)
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
end
|
159
|
+
local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
|
160
|
+
if maxJobs then
|
161
|
+
local jobCounter = tonumber(rcall("GET", limiterKey))
|
162
|
+
if jobCounter ~= nil and jobCounter >= maxJobs then
|
163
|
+
local pttl = rcall("PTTL", KEYS[6])
|
164
|
+
if pttl > 0 then
|
165
|
+
return pttl
|
166
|
+
end
|
166
167
|
end
|
167
|
-
|
168
|
+
end
|
169
|
+
return 0
|
168
170
|
end
|
169
171
|
-- Check if there are delayed jobs that we can move to wait.
|
170
172
|
promoteDelayedJobs(KEYS[7], KEYS[1], KEYS[3], KEYS[8], KEYS[9], KEYS[4], ARGV[1], ARGV[2])
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Mf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
|
@@ -87,14 +87,14 @@ end
|
|
87
87
|
Function to return the next delayed job timestamp.
|
88
88
|
]]
|
89
89
|
local function getNextDelayedTimestamp(delayedKey)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
96
|
-
return nextTimestamp
|
90
|
+
local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
|
91
|
+
if #result then
|
92
|
+
local nextTimestamp = tonumber(result[2])
|
93
|
+
if (nextTimestamp ~= nil) then
|
94
|
+
nextTimestamp = nextTimestamp / 0x1000
|
97
95
|
end
|
96
|
+
return nextTimestamp
|
97
|
+
end
|
98
98
|
end
|
99
99
|
local jobKey = KEYS[5]
|
100
100
|
if rcall("EXISTS", jobKey) == 1 then
|
@@ -108,14 +108,14 @@ end
|
|
108
108
|
Function to return the next delayed job timestamp.
|
109
109
|
]]
|
110
110
|
local function getNextDelayedTimestamp(delayedKey)
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
117
|
-
return nextTimestamp
|
111
|
+
local result = rcall("ZRANGE", delayedKey, 0, 0, "WITHSCORES")
|
112
|
+
if #result then
|
113
|
+
local nextTimestamp = tonumber(result[2])
|
114
|
+
if (nextTimestamp ~= nil) then
|
115
|
+
nextTimestamp = nextTimestamp / 0x1000
|
118
116
|
end
|
117
|
+
return nextTimestamp
|
118
|
+
end
|
119
119
|
end
|
120
120
|
--[[
|
121
121
|
Function to move job from wait state to active.
|
@@ -138,6 +138,8 @@ local function moveJobFromWaitToActive(keys, keyPrefix, jobId, processedOn, opts
|
|
138
138
|
local expireTime
|
139
139
|
if(maxJobs) then
|
140
140
|
local rateLimiterKey = keys[6];
|
141
|
+
expireTime = tonumber(rcall("PTTL", rateLimiterKey))
|
142
|
+
if expireTime == 0 then rcall("DEL", rateLimiterKey) end
|
141
143
|
local jobCounter = tonumber(rcall("INCR", rateLimiterKey))
|
142
144
|
if jobCounter == 1 then
|
143
145
|
local limiterDuration = opts['limiter'] and opts['limiter']['duration']
|
@@ -414,17 +416,17 @@ local function updateParentDepsIfNeeded(parentKey, parentQueueKey, parentDepende
|
|
414
416
|
end
|
415
417
|
end
|
416
418
|
local function getRateLimitTTL(opts, limiterKey)
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
end
|
419
|
+
local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
|
420
|
+
if maxJobs then
|
421
|
+
local jobCounter = tonumber(rcall("GET", limiterKey))
|
422
|
+
if jobCounter ~= nil and jobCounter >= maxJobs then
|
423
|
+
local pttl = rcall("PTTL", KEYS[6])
|
424
|
+
if pttl > 0 then
|
425
|
+
return pttl
|
426
|
+
end
|
426
427
|
end
|
427
|
-
|
428
|
+
end
|
429
|
+
return 0
|
428
430
|
end
|
429
431
|
local jobIdKey = KEYS[10]
|
430
432
|
if rcall("EXISTS", jobIdKey) == 1 then -- // Make sure job exists
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4iBf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
|
@@ -34,19 +34,19 @@ local function isLocked( prefix, jobId)
|
|
34
34
|
local lockKey = jobKey .. ':lock'
|
35
35
|
local lock = rcall("GET", lockKey)
|
36
36
|
if not lock then
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
37
|
+
local dependencies = rcall("SMEMBERS", jobKey .. ":dependencies")
|
38
|
+
if (#dependencies > 0) then
|
39
|
+
for i, childJobKey in ipairs(dependencies) do
|
40
|
+
-- We need to get the jobId for this job.
|
41
|
+
local childJobId = getJobIdFromKey(childJobKey)
|
42
|
+
local childJobPrefix = getJobKeyPrefix(childJobKey, childJobId)
|
43
|
+
local result = isLocked( childJobPrefix, childJobId )
|
44
|
+
if result then
|
45
|
+
return true
|
46
|
+
end
|
48
47
|
end
|
49
|
-
|
48
|
+
end
|
49
|
+
return false
|
50
50
|
end
|
51
51
|
return true
|
52
52
|
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { Job } from '../classes/job';
|
2
|
-
export
|
2
|
+
export type BackoffStrategy = (attemptsMade?: number, type?: string, err?: Error, job?: Job) => Promise<number> | number;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export
|
2
|
-
export
|
1
|
+
export type FinishedStatus = 'completed' | 'failed';
|
2
|
+
export type FinishedPropValAttribute = 'returnvalue' | 'failedReason';
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { BaseJobOptions } from '../interfaces';
|
2
|
-
export
|
2
|
+
export type JobsOptions = BaseJobOptions & {
|
3
3
|
/**
|
4
4
|
* If true, moves parent to failed.
|
5
5
|
*/
|
@@ -8,7 +8,7 @@ export declare type JobsOptions = BaseJobOptions & {
|
|
8
8
|
/**
|
9
9
|
* These fields are the ones stored in Redis with smaller keys for compactness.
|
10
10
|
*/
|
11
|
-
export
|
11
|
+
export type RedisJobOptions = BaseJobOptions & {
|
12
12
|
/**
|
13
13
|
* If true, moves parent to failed.
|
14
14
|
*/
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { FinishedStatus } from './finished-status';
|
2
|
-
export
|
3
|
-
export
|
2
|
+
export type JobState = FinishedStatus | 'active' | 'delayed' | 'waiting' | 'waiting-children';
|
3
|
+
export type JobType = JobState | 'paused' | 'repeat' | 'wait';
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { RepeatOptions } from '../interfaces/repeat-options';
|
2
|
-
export
|
2
|
+
export type RepeatStrategy = (millis: number, opts: RepeatOptions, name?: string) => number;
|
@@ -3,7 +3,7 @@ import { JobJson, JobJsonRaw, ParentKeys, RedisClient } from '../interfaces';
|
|
3
3
|
import { FinishedStatus, JobsOptions, JobState, JobJsonSandbox } from '../types';
|
4
4
|
import { QueueEvents } from './queue-events';
|
5
5
|
import { MinimalQueue, ParentOpts, Scripts } from './scripts';
|
6
|
-
export
|
6
|
+
export type BulkJobOptions = Omit<JobsOptions, 'repeat'>;
|
7
7
|
export interface MoveToWaitingChildrenOpts {
|
8
8
|
child?: {
|
9
9
|
id: string;
|
@@ -65,56 +65,55 @@ export declare class QueueGetters<DataType, ResultType, NameType extends string>
|
|
65
65
|
getWaitingChildrenCount(): Promise<number>;
|
66
66
|
/**
|
67
67
|
* Returns the jobs that are in the "waiting" status.
|
68
|
-
* @param start zero based index from where to start returning jobs.
|
69
|
-
* @param end
|
70
|
-
|
71
|
-
*/
|
68
|
+
* @param start - zero based index from where to start returning jobs.
|
69
|
+
* @param end - zero based index where to stop returning jobs.
|
70
|
+
*/
|
72
71
|
getWaiting(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
73
72
|
/**
|
74
73
|
* Returns the jobs that are in the "waiting" status.
|
75
|
-
* @param start zero based index from where to start returning jobs.
|
76
|
-
* @param end
|
74
|
+
* @param start - zero based index from where to start returning jobs.
|
75
|
+
* @param end - zero based index where to stop returning jobs.
|
77
76
|
*/
|
78
77
|
getWaitingChildren(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
79
78
|
/**
|
80
79
|
* Returns the jobs that are in the "active" status.
|
81
|
-
* @param start zero based index from where to start returning jobs.
|
82
|
-
* @param end
|
80
|
+
* @param start - zero based index from where to start returning jobs.
|
81
|
+
* @param end - zero based index where to stop returning jobs.
|
83
82
|
*/
|
84
83
|
getActive(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
85
84
|
/**
|
86
85
|
* Returns the jobs that are in the "delayed" status.
|
87
|
-
* @param start zero based index from where to start returning jobs.
|
88
|
-
* @param end
|
86
|
+
* @param start - zero based index from where to start returning jobs.
|
87
|
+
* @param end - zero based index where to stop returning jobs.
|
89
88
|
*/
|
90
89
|
getDelayed(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
91
90
|
/**
|
92
91
|
* Returns the jobs that are in the "completed" status.
|
93
|
-
* @param start zero based index from where to start returning jobs.
|
94
|
-
* @param end
|
92
|
+
* @param start - zero based index from where to start returning jobs.
|
93
|
+
* @param end - zero based index where to stop returning jobs.
|
95
94
|
*/
|
96
95
|
getCompleted(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
97
96
|
/**
|
98
97
|
* Returns the jobs that are in the "failed" status.
|
99
|
-
* @param start zero based index from where to start returning jobs.
|
100
|
-
* @param end
|
98
|
+
* @param start - zero based index from where to start returning jobs.
|
99
|
+
* @param end - zero based index where to stop returning jobs.
|
101
100
|
*/
|
102
101
|
getFailed(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
103
102
|
getRanges(types: JobType[], start?: number, end?: number, asc?: boolean): Promise<string[]>;
|
104
103
|
/**
|
105
104
|
* Returns the jobs that are on the given statuses (note that JobType is synonym for job status)
|
106
|
-
* @param types the statuses of the jobs to return.
|
107
|
-
* @param start zero based index from where to start returning jobs.
|
108
|
-
* @param end
|
109
|
-
* @param asc if true, the jobs will be returned in ascending order.
|
105
|
+
* @param types - the statuses of the jobs to return.
|
106
|
+
* @param start - zero based index from where to start returning jobs.
|
107
|
+
* @param end - zero based index where to stop returning jobs.
|
108
|
+
* @param asc - if true, the jobs will be returned in ascending order.
|
110
109
|
*/
|
111
110
|
getJobs(types?: JobType[] | JobType, start?: number, end?: number, asc?: boolean): Promise<Job<DataType, ResultType, NameType>[]>;
|
112
111
|
/**
|
113
112
|
* Returns the logs for a given Job.
|
114
|
-
* @param jobId the id of the job to get the logs for.
|
115
|
-
* @param start zero based index from where to start returning jobs.
|
116
|
-
* @param end
|
117
|
-
* @param asc if true, the jobs will be returned in ascending order.
|
113
|
+
* @param jobId - the id of the job to get the logs for.
|
114
|
+
* @param start - zero based index from where to start returning jobs.
|
115
|
+
* @param end - zero based index where to stop returning jobs.
|
116
|
+
* @param asc - if true, the jobs will be returned in ascending order.
|
118
117
|
*/
|
119
118
|
getJobLogs(jobId: string, start?: number, end?: number, asc?: boolean): Promise<{
|
120
119
|
logs: string[];
|