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.
Files changed (73) hide show
  1. package/dist/cjs/classes/job.d.ts +1 -1
  2. package/dist/cjs/classes/queue-getters.d.ts +21 -22
  3. package/dist/cjs/classes/queue-getters.js +21 -22
  4. package/dist/cjs/classes/queue-getters.js.map +1 -1
  5. package/dist/cjs/classes/queue-keys.d.ts +1 -1
  6. package/dist/cjs/classes/queue.d.ts +4 -5
  7. package/dist/cjs/classes/queue.js +4 -5
  8. package/dist/cjs/classes/queue.js.map +1 -1
  9. package/dist/cjs/classes/scripts.d.ts +3 -3
  10. package/dist/cjs/classes/worker.js +3 -3
  11. package/dist/cjs/classes/worker.js.map +1 -1
  12. package/dist/cjs/commands/addJob-8.lua +42 -41
  13. package/dist/cjs/commands/includes/getNextDelayedTimestamp.lua +7 -7
  14. package/dist/cjs/commands/includes/getRateLimitTTL.lua +10 -10
  15. package/dist/cjs/commands/includes/getTimestamp.lua +1 -1
  16. package/dist/cjs/commands/includes/isLocked.lua +12 -12
  17. package/dist/cjs/commands/includes/moveJobFromWaitToActive.lua +4 -0
  18. package/dist/cjs/interfaces/connection.d.ts +1 -1
  19. package/dist/cjs/interfaces/flow-job.d.ts +3 -3
  20. package/dist/cjs/interfaces/redis-options.d.ts +3 -3
  21. package/dist/cjs/interfaces/redis-streams.d.ts +4 -4
  22. package/dist/cjs/interfaces/sandboxed-job-processor.d.ts +1 -1
  23. package/dist/cjs/interfaces/worker-options.d.ts +1 -1
  24. package/dist/cjs/scripts/addJob-8.js +47 -47
  25. package/dist/cjs/scripts/moveToActive-9.js +19 -17
  26. package/dist/cjs/scripts/moveToActive-9.js.map +1 -1
  27. package/dist/cjs/scripts/moveToDelayed-8.js +7 -7
  28. package/dist/cjs/scripts/moveToFinished-12.js +19 -17
  29. package/dist/cjs/scripts/moveToFinished-12.js.map +1 -1
  30. package/dist/cjs/scripts/removeJob-1.js +12 -12
  31. package/dist/cjs/types/backoff-strategy.d.ts +1 -1
  32. package/dist/cjs/types/finished-status.d.ts +2 -2
  33. package/dist/cjs/types/job-json-sandbox.d.ts +1 -1
  34. package/dist/cjs/types/job-options.d.ts +2 -2
  35. package/dist/cjs/types/job-type.d.ts +2 -2
  36. package/dist/cjs/types/repeat-strategy.d.ts +1 -1
  37. package/dist/esm/classes/job.d.ts +1 -1
  38. package/dist/esm/classes/queue-getters.d.ts +21 -22
  39. package/dist/esm/classes/queue-getters.js +21 -22
  40. package/dist/esm/classes/queue-getters.js.map +1 -1
  41. package/dist/esm/classes/queue-keys.d.ts +1 -1
  42. package/dist/esm/classes/queue.d.ts +4 -5
  43. package/dist/esm/classes/queue.js +4 -5
  44. package/dist/esm/classes/queue.js.map +1 -1
  45. package/dist/esm/classes/scripts.d.ts +3 -3
  46. package/dist/esm/classes/worker.js +3 -3
  47. package/dist/esm/classes/worker.js.map +1 -1
  48. package/dist/esm/commands/addJob-8.lua +42 -41
  49. package/dist/esm/commands/includes/getNextDelayedTimestamp.lua +7 -7
  50. package/dist/esm/commands/includes/getRateLimitTTL.lua +10 -10
  51. package/dist/esm/commands/includes/getTimestamp.lua +1 -1
  52. package/dist/esm/commands/includes/isLocked.lua +12 -12
  53. package/dist/esm/commands/includes/moveJobFromWaitToActive.lua +4 -0
  54. package/dist/esm/interfaces/connection.d.ts +1 -1
  55. package/dist/esm/interfaces/flow-job.d.ts +3 -3
  56. package/dist/esm/interfaces/redis-options.d.ts +3 -3
  57. package/dist/esm/interfaces/redis-streams.d.ts +4 -4
  58. package/dist/esm/interfaces/sandboxed-job-processor.d.ts +1 -1
  59. package/dist/esm/interfaces/worker-options.d.ts +1 -1
  60. package/dist/esm/scripts/addJob-8.js +47 -47
  61. package/dist/esm/scripts/moveToActive-9.js +19 -17
  62. package/dist/esm/scripts/moveToActive-9.js.map +1 -1
  63. package/dist/esm/scripts/moveToDelayed-8.js +7 -7
  64. package/dist/esm/scripts/moveToFinished-12.js +19 -17
  65. package/dist/esm/scripts/moveToFinished-12.js.map +1 -1
  66. package/dist/esm/scripts/removeJob-1.js +12 -12
  67. package/dist/esm/types/backoff-strategy.d.ts +1 -1
  68. package/dist/esm/types/finished-status.d.ts +2 -2
  69. package/dist/esm/types/job-json-sandbox.d.ts +1 -1
  70. package/dist/esm/types/job-options.d.ts +2 -2
  71. package/dist/esm/types/job-type.d.ts +2 -2
  72. package/dist/esm/types/repeat-strategy.d.ts +1 -1
  73. 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
- 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
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
- return false
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 declare type RedisClient = Redis | Cluster;
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 declare type FlowChildJob = FlowJobBase<Omit<JobsOptions, 'parent'>>;
12
- export declare type FlowJob = FlowJobBase<JobsOptions>;
13
- export declare type FlowQueuesOpts = Record<string, Omit<QueueOptions, 'connection' | 'prefix'>>;
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 declare type RedisOptions = IORedis.RedisOptions & BaseOptions;
6
- export declare type ClusterOptions = IORedis.ClusterOptions & BaseOptions;
7
- export declare type ConnectionOptions = RedisOptions | ClusterOptions | IORedis.Redis | IORedis.Cluster;
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 declare type StreamName = string;
2
- export declare type EntryId = string;
3
- export declare type EntryRaw = [EntryId, string[]];
4
- export declare type StreamReadRaw = [StreamName, EntryRaw[]][];
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 declare type SandboxedJobProcessor<T = any, R = any> = ((job: SandboxedJob<T, R>) => R | PromiseLike<R>) | ((job: SandboxedJob<T, R>, callback: (error: unknown, result: R) => void) => void);
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 declare type Processor<T = any, R = any, N extends string = string> = (job: Job<T, R, N>, token?: string) => Promise<R>;
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
- 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
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
- if rcall("EXISTS", jobIdKey) == 1 then
158
- if parentKey ~= nil then
159
- if rcall("ZSCORE", KEYS[7], jobId) ~= false then
160
- local returnvalue = rcall("HGET", jobIdKey, "returnvalue")
161
- updateParentDepsIfNeeded(parentKey, parent['queueKey'], parentDependenciesKey,
162
- parent['id'], jobIdKey, returnvalue, timestamp)
163
- else
164
- if parentDependenciesKey ~= nil then
165
- rcall("SADD", parentDependenciesKey, jobIdKey)
166
- end
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
- return jobId .. "" -- convert to string
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
- rcall("ZADD", waitChildrenKey, timestamp, jobId)
197
- rcall("XADD", KEYS[8], "*", "event", "waiting-children", "jobId", jobId)
196
+ rcall("ZADD", waitChildrenKey, timestamp, jobId)
197
+ rcall("XADD", KEYS[8], "*", "event", "waiting-children", "jobId", jobId)
198
198
  elseif (delayedTimestamp ~= 0) then
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)
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
- 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)
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
- rcall("SADD", parentDependenciesKey, jobIdKey)
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
- 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
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
- local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
158
- if maxJobs then
159
- local jobCounter = tonumber(rcall("GET", limiterKey))
160
- if jobCounter ~= nil and jobCounter >= maxJobs then
161
- local pttl = rcall("PTTL", KEYS[6])
162
- if pttl > 0 then
163
- return pttl
164
- end
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
- return 0
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwMf,CAAC;AACW,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO;IACP,IAAI,EAAE,CAAC;CACR,CAAC"}
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
- 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
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
- 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
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
- local maxJobs = tonumber(opts['limiter'] and opts['limiter']['max'])
418
- if maxJobs then
419
- local jobCounter = tonumber(rcall("GET", limiterKey))
420
- if jobCounter ~= nil and jobCounter >= maxJobs then
421
- local pttl = rcall("PTTL", KEYS[6])
422
- if pttl > 0 then
423
- return pttl
424
- end
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
- return 0
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0iBf,CAAC;AACW,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
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
- 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
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
- return false
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 declare type BackoffStrategy = (attemptsMade?: number, type?: string, err?: Error, job?: Job) => Promise<number> | number;
2
+ export type BackoffStrategy = (attemptsMade?: number, type?: string, err?: Error, job?: Job) => Promise<number> | number;
@@ -1,2 +1,2 @@
1
- export declare type FinishedStatus = 'completed' | 'failed';
2
- export declare type FinishedPropValAttribute = 'returnvalue' | 'failedReason';
1
+ export type FinishedStatus = 'completed' | 'failed';
2
+ export type FinishedPropValAttribute = 'returnvalue' | 'failedReason';
@@ -1,5 +1,5 @@
1
1
  import { JobJson } from '../interfaces';
2
- export declare type JobJsonSandbox = JobJson & {
2
+ export type JobJsonSandbox = JobJson & {
3
3
  queueName: string;
4
4
  prefix: string;
5
5
  };
@@ -1,5 +1,5 @@
1
1
  import { BaseJobOptions } from '../interfaces';
2
- export declare type JobsOptions = BaseJobOptions & {
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 declare type RedisJobOptions = BaseJobOptions & {
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 declare type JobState = FinishedStatus | 'active' | 'delayed' | 'waiting' | 'waiting-children';
3
- export declare type JobType = JobState | 'paused' | 'repeat' | 'wait';
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 declare type RepeatStrategy = (millis: number, opts: RepeatOptions, name?: string) => number;
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 declare type BulkJobOptions = Omit<JobsOptions, 'repeat'>;
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 zeroo based index where to stop returning jobs.
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 zeroo based index where to stop returning jobs.
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 zeroo based index where to stop returning jobs.
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 zeroo based index where to stop returning jobs.
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 zeroo based index where to stop returning jobs.
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 zeroo based index where to stop returning jobs.
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 zeroo based index where to stop returning jobs.
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 zeroo based index where to stop returning jobs.
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[];