bullmq 1.80.2 → 1.80.3
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/child-pool.js +4 -4
- package/dist/cjs/classes/child-pool.js.map +1 -1
- package/dist/cjs/classes/child-processor.js +8 -8
- package/dist/cjs/classes/child-processor.js.map +1 -1
- package/dist/cjs/classes/flow-producer.js +3 -3
- package/dist/cjs/classes/flow-producer.js.map +1 -1
- package/dist/cjs/classes/job.d.ts +1 -1
- package/dist/cjs/classes/job.js +8 -8
- package/dist/cjs/classes/job.js.map +1 -1
- package/dist/cjs/classes/master.js +2 -2
- package/dist/cjs/classes/master.js.map +1 -1
- package/dist/cjs/classes/queue-events.js +4 -4
- package/dist/cjs/classes/queue-events.js.map +1 -1
- package/dist/cjs/classes/queue-scheduler.js +2 -2
- package/dist/cjs/classes/queue-scheduler.js.map +1 -1
- package/dist/cjs/classes/queue.js +7 -7
- package/dist/cjs/classes/queue.js.map +1 -1
- package/dist/cjs/classes/redis-connection.js +16 -7
- package/dist/cjs/classes/redis-connection.js.map +1 -1
- package/dist/cjs/classes/repeat.js +2 -2
- package/dist/cjs/classes/repeat.js.map +1 -1
- package/dist/cjs/classes/sandbox.js +1 -1
- package/dist/cjs/classes/sandbox.js.map +1 -1
- package/dist/cjs/classes/scripts.js +5 -3
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/classes/timer-manager.js +1 -1
- package/dist/cjs/classes/timer-manager.js.map +1 -1
- package/dist/cjs/classes/worker.js +8 -8
- package/dist/cjs/classes/worker.js.map +1 -1
- package/dist/cjs/commands/index.js +1 -1
- package/dist/cjs/commands/script-loader.js +5 -5
- package/dist/cjs/commands/script-loader.js.map +1 -1
- package/dist/cjs/utils.js +9 -6
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/classes/job.d.ts +1 -1
- package/dist/esm/classes/job.js.map +1 -1
- package/dist/esm/classes/redis-connection.js +14 -5
- package/dist/esm/classes/redis-connection.js.map +1 -1
- package/dist/esm/classes/scripts.js +3 -1
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/classes/worker.js.map +1 -1
- package/dist/esm/interfaces/advanced-options.js +1 -0
- package/dist/esm/interfaces/backoff-options.js +1 -0
- package/dist/esm/interfaces/child-message.js +1 -0
- package/dist/esm/interfaces/connection.js +1 -0
- package/dist/esm/interfaces/flow-job.js +1 -0
- package/dist/esm/interfaces/job-json.js +1 -0
- package/dist/esm/interfaces/jobs-options.js +1 -0
- package/dist/esm/interfaces/keep-jobs.js +1 -0
- package/dist/esm/interfaces/metrics-options.js +1 -0
- package/dist/esm/interfaces/metrics.js +1 -0
- package/dist/esm/interfaces/parent-message.js +1 -0
- package/dist/esm/interfaces/parent.js +1 -0
- package/dist/esm/interfaces/queue-scheduler-options.js +1 -0
- package/dist/esm/interfaces/rate-limiter-options.js +1 -0
- package/dist/esm/interfaces/redis-options.js +1 -0
- package/dist/esm/interfaces/redis-streams.js +1 -0
- package/dist/esm/interfaces/repeat-options.js +1 -0
- package/dist/esm/interfaces/sandboxed-job-processor.js +1 -0
- package/dist/esm/interfaces/sandboxed-job.js +1 -0
- package/dist/esm/interfaces/worker-options.js +1 -0
- package/dist/esm/types/finished-status.js +1 -0
- package/dist/esm/types/job-json-sandbox.js +1 -0
- package/dist/esm/types/job-type.js +1 -0
- package/package.json +5 -13
- package/dist/bullmq.d.ts +0 -2467
- package/dist/esm/tsdoc-metadata.json +0 -11
package/dist/bullmq.d.ts
DELETED
@@ -1,2467 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
|
3
|
-
import { ChildProcess } from 'child_process';
|
4
|
-
import { Cluster } from 'ioredis';
|
5
|
-
import { EventEmitter } from 'events';
|
6
|
-
import type * as IORedis from 'ioredis';
|
7
|
-
import { ParserOptions } from 'cron-parser';
|
8
|
-
import { Pipeline } from 'ioredis';
|
9
|
-
import { Redis } from 'ioredis';
|
10
|
-
|
11
|
-
export declare type ActiveEventCallback3<T = any> = (job: Job, jobPromise?: JobPromise3) => void;
|
12
|
-
|
13
|
-
export declare interface AddChildrenOpts {
|
14
|
-
multi: Pipeline;
|
15
|
-
nodes: FlowJob[];
|
16
|
-
parent: {
|
17
|
-
parentOpts: {
|
18
|
-
id: string;
|
19
|
-
queue: string;
|
20
|
-
};
|
21
|
-
parentDependenciesKey: string;
|
22
|
-
};
|
23
|
-
queuesOpts?: FlowQueuesOpts;
|
24
|
-
}
|
25
|
-
|
26
|
-
export declare interface AddNodeOpts {
|
27
|
-
multi: Pipeline;
|
28
|
-
node: FlowJob;
|
29
|
-
parent?: {
|
30
|
-
parentOpts: {
|
31
|
-
id: string;
|
32
|
-
queue: string;
|
33
|
-
};
|
34
|
-
parentDependenciesKey: string;
|
35
|
-
};
|
36
|
-
/**
|
37
|
-
* Queues options that will be applied in each node depending on queue name presence.
|
38
|
-
*/
|
39
|
-
queuesOpts?: FlowQueuesOpts;
|
40
|
-
}
|
41
|
-
|
42
|
-
export declare interface AdvancedOptions {
|
43
|
-
/**
|
44
|
-
* A set of custom backoff strategies keyed by name.
|
45
|
-
*/
|
46
|
-
backoffStrategies?: {};
|
47
|
-
}
|
48
|
-
|
49
|
-
export declare function array2obj(arr: string[]): Record<string, string>;
|
50
|
-
|
51
|
-
export declare const asyncSend: <T extends procSendLike>(proc: T, msg: any) => Promise<void>;
|
52
|
-
|
53
|
-
export declare type BackoffFunction = (attemptsMade?: number, err?: Error, job?: Job) => number;
|
54
|
-
|
55
|
-
/**
|
56
|
-
* Settings for backing off failed jobs.
|
57
|
-
*
|
58
|
-
* @see {@link https://docs.bullmq.io/guide/retrying-failing-jobs}
|
59
|
-
*/
|
60
|
-
export declare interface BackoffOptions {
|
61
|
-
/**
|
62
|
-
* Name of the backoff strategy.
|
63
|
-
*/
|
64
|
-
type: 'fixed' | 'exponential' | (string & {});
|
65
|
-
/**
|
66
|
-
* Delay in milliseconds.
|
67
|
-
*/
|
68
|
-
delay?: number;
|
69
|
-
}
|
70
|
-
|
71
|
-
export declare class Backoffs {
|
72
|
-
static builtinStrategies: BuiltInStrategies;
|
73
|
-
static normalize(backoff: number | BackoffOptions): BackoffOptions;
|
74
|
-
static calculate(backoff: BackoffOptions, attemptsMade: number, customStrategies: Strategies, err: Error, job: Job): number;
|
75
|
-
}
|
76
|
-
|
77
|
-
declare interface BaseOptions {
|
78
|
-
skipVersionCheck?: boolean;
|
79
|
-
}
|
80
|
-
|
81
|
-
declare interface BuiltInStrategies {
|
82
|
-
[index: string]: (delay: number) => BackoffFunction;
|
83
|
-
}
|
84
|
-
|
85
|
-
export declare type BulkJobOptions = Omit<JobsOptions, 'repeat'>;
|
86
|
-
|
87
|
-
export declare enum ChildCommand {
|
88
|
-
Init = 0,
|
89
|
-
Start = 1,
|
90
|
-
Stop = 2
|
91
|
-
}
|
92
|
-
|
93
|
-
export declare interface ChildMessage {
|
94
|
-
cmd: ParentCommand;
|
95
|
-
value?: any;
|
96
|
-
err?: Error;
|
97
|
-
}
|
98
|
-
|
99
|
-
export declare class ChildPool {
|
100
|
-
private masterFile;
|
101
|
-
retained: {
|
102
|
-
[key: number]: ChildProcessExt;
|
103
|
-
};
|
104
|
-
free: {
|
105
|
-
[key: string]: ChildProcessExt[];
|
106
|
-
};
|
107
|
-
constructor(masterFile?: string);
|
108
|
-
retain(processFile: string): Promise<ChildProcessExt>;
|
109
|
-
release(child: ChildProcessExt): void;
|
110
|
-
remove(child: ChildProcessExt): void;
|
111
|
-
kill(child: ChildProcess, signal?: 'SIGTERM' | 'SIGKILL'): Promise<void>;
|
112
|
-
clean(): Promise<void>;
|
113
|
-
getFree(id: string): ChildProcessExt[];
|
114
|
-
getAllFree(): ChildProcessExt[];
|
115
|
-
}
|
116
|
-
|
117
|
-
export declare interface ChildProcessExt extends ChildProcess {
|
118
|
-
processFile?: string;
|
119
|
-
}
|
120
|
-
|
121
|
-
/**
|
122
|
-
* ChildProcessor
|
123
|
-
*
|
124
|
-
* This class acts as the interface between a child process and it parent process
|
125
|
-
* so that jobs can be processed in different processes than the parent.
|
126
|
-
*
|
127
|
-
*/
|
128
|
-
export declare class ChildProcessor {
|
129
|
-
status: ChildStatus;
|
130
|
-
processor: any;
|
131
|
-
currentJobPromise: Promise<unknown> | undefined;
|
132
|
-
init(processorFile: string): Promise<void>;
|
133
|
-
start(jobJson: JobJson): Promise<void>;
|
134
|
-
stop(): Promise<void>;
|
135
|
-
waitForCurrentJobAndExit(): Promise<void>;
|
136
|
-
}
|
137
|
-
|
138
|
-
export declare const childSend: (proc: NodeJS.Process, msg: ChildMessage) => Promise<void>;
|
139
|
-
|
140
|
-
declare enum ChildStatus {
|
141
|
-
Idle = 0,
|
142
|
-
Started = 1,
|
143
|
-
Terminating = 2,
|
144
|
-
Errored = 3
|
145
|
-
}
|
146
|
-
|
147
|
-
export declare type CleanedEventCallback3<T = any> = (jobs: Array<Job>, status: JobStatusClean3) => void;
|
148
|
-
|
149
|
-
export declare const clientCommandMessageReg: RegExp;
|
150
|
-
|
151
|
-
export declare enum ClientType {
|
152
|
-
blocking = "blocking",
|
153
|
-
normal = "normal"
|
154
|
-
}
|
155
|
-
|
156
|
-
export declare type ClusterOptions = IORedis.ClusterOptions & BaseOptions;
|
157
|
-
|
158
|
-
export declare interface Command {
|
159
|
-
name: string;
|
160
|
-
options: {
|
161
|
-
numberOfKeys: number;
|
162
|
-
lua: string;
|
163
|
-
};
|
164
|
-
}
|
165
|
-
|
166
|
-
declare type CommonOptions = QueueSchedulerOptions & QueueOptions & WorkerOptions & QueueEventsOptions;
|
167
|
-
|
168
|
-
export declare type CompletedEventCallback3<T = any> = (job: Job, result: any) => void;
|
169
|
-
|
170
|
-
export declare type ConnectionOptions = RedisOptions | ClusterOptions | IORedis.Redis | IORedis.Cluster;
|
171
|
-
|
172
|
-
export declare function delay(ms: number): Promise<void>;
|
173
|
-
|
174
|
-
export declare const DELAY_TIME_1 = 100;
|
175
|
-
|
176
|
-
export declare const DELAY_TIME_5 = 5000;
|
177
|
-
|
178
|
-
export declare interface DependenciesOpts {
|
179
|
-
processed?: {
|
180
|
-
cursor?: number;
|
181
|
-
count?: number;
|
182
|
-
};
|
183
|
-
unprocessed?: {
|
184
|
-
cursor?: number;
|
185
|
-
count?: number;
|
186
|
-
};
|
187
|
-
}
|
188
|
-
|
189
|
-
export declare type EntryId = string;
|
190
|
-
|
191
|
-
export declare type EntryRaw = [EntryId, string[]];
|
192
|
-
|
193
|
-
export declare enum ErrorCode {
|
194
|
-
JobNotExist = -1,
|
195
|
-
JobLockNotExist = -2,
|
196
|
-
JobNotInState = -3,
|
197
|
-
JobPendingDependencies = -4,
|
198
|
-
ParentJobNotExist = -5
|
199
|
-
}
|
200
|
-
|
201
|
-
export declare type ErrorEventCallback3 = (error: Error) => void;
|
202
|
-
|
203
|
-
export declare const errorObject: {
|
204
|
-
[index: string]: any;
|
205
|
-
};
|
206
|
-
|
207
|
-
export declare type EventCallback3 = () => void;
|
208
|
-
|
209
|
-
export declare type FailedEventCallback3<T = any> = (job: Job, error: Error) => void;
|
210
|
-
|
211
|
-
export declare type FinishedPropValAttribute = 'returnvalue' | 'failedReason';
|
212
|
-
|
213
|
-
export declare type FinishedStatus = 'completed' | 'failed';
|
214
|
-
|
215
|
-
export declare interface FlowJob {
|
216
|
-
name: string;
|
217
|
-
queueName: string;
|
218
|
-
data?: any;
|
219
|
-
prefix?: string;
|
220
|
-
opts?: Omit<JobsOptions, 'parent' | 'repeat'>;
|
221
|
-
children?: FlowJob[];
|
222
|
-
}
|
223
|
-
|
224
|
-
export declare interface FlowOpts {
|
225
|
-
/**
|
226
|
-
* Map of options for Queue classes.
|
227
|
-
*/
|
228
|
-
queuesOptions: FlowQueuesOpts;
|
229
|
-
}
|
230
|
-
|
231
|
-
/**
|
232
|
-
* This class allows to add jobs with dependencies between them in such
|
233
|
-
* a way that it is possible to build complex flows.
|
234
|
-
* Note: A flow is a tree-like structure of jobs that depend on each other.
|
235
|
-
* Whenever the children of a given parent are completed, the parent
|
236
|
-
* will be processed, being able to access the children's result data.
|
237
|
-
* All Jobs can be in different queues, either children or parents,
|
238
|
-
*/
|
239
|
-
export declare class FlowProducer extends EventEmitter {
|
240
|
-
opts: QueueBaseOptions;
|
241
|
-
toKey: (name: string, type: string) => string;
|
242
|
-
keys: KeysMap;
|
243
|
-
closing: Promise<void>;
|
244
|
-
queueKeys: QueueKeys;
|
245
|
-
protected connection: RedisConnection;
|
246
|
-
constructor(opts?: QueueBaseOptions);
|
247
|
-
/**
|
248
|
-
* Adds a flow.
|
249
|
-
*
|
250
|
-
* This call would be atomic, either it fails and no jobs will
|
251
|
-
* be added to the queues, or it succeeds and all jobs will be added.
|
252
|
-
*
|
253
|
-
* @param flow - an object with a tree-like structure where children jobs
|
254
|
-
* will be processed before their parents.
|
255
|
-
* @param opts - options that will be applied to the flow object.
|
256
|
-
*/
|
257
|
-
add(flow: FlowJob, opts?: FlowOpts): Promise<JobNode>;
|
258
|
-
/**
|
259
|
-
* Get a flow.
|
260
|
-
*
|
261
|
-
* @param opts - an object with options for getting a JobNode.
|
262
|
-
*/
|
263
|
-
getFlow(opts: NodeOpts): Promise<JobNode>;
|
264
|
-
get client(): Promise<RedisClient>;
|
265
|
-
/**
|
266
|
-
* Adds multiple flows.
|
267
|
-
*
|
268
|
-
* A flow is a tree-like structure of jobs that depend on each other.
|
269
|
-
* Whenever the children of a given parent are completed, the parent
|
270
|
-
* will be processed, being able to access the children's result data.
|
271
|
-
*
|
272
|
-
* All Jobs can be in different queues, either children or parents,
|
273
|
-
* however this call would be atomic, either it fails and no jobs will
|
274
|
-
* be added to the queues, or it succeeds and all jobs will be added.
|
275
|
-
*
|
276
|
-
* @param flows - an array of objects with a tree-like structure where children jobs
|
277
|
-
* will be processed before their parents.
|
278
|
-
*/
|
279
|
-
addBulk(flows: FlowJob[]): Promise<JobNode[]>;
|
280
|
-
/**
|
281
|
-
* Add a node (job) of a flow to the queue. This method will recursively
|
282
|
-
* add all its children as well. Note that a given job can potentially be
|
283
|
-
* a parent and a child job at the same time depending on where it is located
|
284
|
-
* in the tree hierarchy.
|
285
|
-
*
|
286
|
-
* @param multi - ioredis pipeline
|
287
|
-
* @param node - the node representing a job to be added to some queue
|
288
|
-
* @param parent - parent data sent to children to create the "links" to their parent
|
289
|
-
* @returns
|
290
|
-
*/
|
291
|
-
private addNode;
|
292
|
-
/**
|
293
|
-
* Adds nodes (jobs) of multiple flows to the queue. This method will recursively
|
294
|
-
* add all its children as well. Note that a given job can potentially be
|
295
|
-
* a parent and a child job at the same time depending on where it is located
|
296
|
-
* in the tree hierarchy.
|
297
|
-
*
|
298
|
-
* @param multi - ioredis pipeline
|
299
|
-
* @param nodes - the nodes representing jobs to be added to some queue
|
300
|
-
* @returns
|
301
|
-
*/
|
302
|
-
private addNodes;
|
303
|
-
private getNode;
|
304
|
-
private addChildren;
|
305
|
-
private getChildren;
|
306
|
-
/**
|
307
|
-
* Helper factory method that creates a queue-like object
|
308
|
-
* required to create jobs in any queue.
|
309
|
-
*
|
310
|
-
* @param node -
|
311
|
-
* @param queueKeys -
|
312
|
-
* @returns
|
313
|
-
*/
|
314
|
-
private queueFromNode;
|
315
|
-
close(): Promise<void>;
|
316
|
-
disconnect(): Promise<void>;
|
317
|
-
}
|
318
|
-
|
319
|
-
export declare type FlowQueuesOpts = Record<string, Omit<QueueOptions, 'connection' | 'prefix'>>;
|
320
|
-
|
321
|
-
export declare interface GetNextJobOptions {
|
322
|
-
block?: boolean;
|
323
|
-
}
|
324
|
-
|
325
|
-
export declare function getParentKey(opts: {
|
326
|
-
id: string;
|
327
|
-
queue: string;
|
328
|
-
}): string;
|
329
|
-
|
330
|
-
export declare interface IConnection extends EventEmitter {
|
331
|
-
waitUntilReady(): Promise<boolean>;
|
332
|
-
client: Promise<RedisClient>;
|
333
|
-
}
|
334
|
-
|
335
|
-
export declare function isEmpty(obj: object): boolean;
|
336
|
-
|
337
|
-
export declare function isNotConnectionError(error: Error): boolean;
|
338
|
-
|
339
|
-
export declare function isRedisCluster(obj: unknown): obj is Cluster;
|
340
|
-
|
341
|
-
export declare function isRedisInstance(obj: any): obj is Redis | Cluster;
|
342
|
-
|
343
|
-
export declare class Job<DataType = any, ReturnType = any, NameType extends string = string> {
|
344
|
-
protected queue: MinimalQueue;
|
345
|
-
/**
|
346
|
-
* The name of the Job
|
347
|
-
*/
|
348
|
-
name: NameType;
|
349
|
-
/**
|
350
|
-
* The payload for this job.
|
351
|
-
*/
|
352
|
-
data: DataType;
|
353
|
-
/**
|
354
|
-
* The options object for this job.
|
355
|
-
*/
|
356
|
-
opts: JobsOptions;
|
357
|
-
id?: string;
|
358
|
-
/**
|
359
|
-
* The progress a job has performed so far.
|
360
|
-
* @defaultValue 0
|
361
|
-
*/
|
362
|
-
progress: number | object;
|
363
|
-
/**
|
364
|
-
* The value returned by the processor when processing this job.
|
365
|
-
* @defaultValue null
|
366
|
-
*/
|
367
|
-
returnvalue: ReturnType;
|
368
|
-
/**
|
369
|
-
* Stacktrace for the error (for failed jobs).
|
370
|
-
* @defaultValue null
|
371
|
-
*/
|
372
|
-
stacktrace: string[];
|
373
|
-
/**
|
374
|
-
* Timestamp when the job was created (unless overridden with job options).
|
375
|
-
*/
|
376
|
-
timestamp: number;
|
377
|
-
/**
|
378
|
-
* Number of attempts after the job has failed.
|
379
|
-
* @defaultValue 0
|
380
|
-
*/
|
381
|
-
attemptsMade: number;
|
382
|
-
/**
|
383
|
-
* Reason for failing.
|
384
|
-
*/
|
385
|
-
failedReason: string;
|
386
|
-
/**
|
387
|
-
* Timestamp for when the job finished (completed or failed).
|
388
|
-
*/
|
389
|
-
finishedOn?: number;
|
390
|
-
/**
|
391
|
-
* Timestamp for when the job was processed.
|
392
|
-
*/
|
393
|
-
processedOn?: number;
|
394
|
-
/**
|
395
|
-
* Fully qualified key (including the queue prefix) pointing to the parent of this job.
|
396
|
-
*/
|
397
|
-
parentKey?: string;
|
398
|
-
/**
|
399
|
-
* Object that contains parentId (id) and parent queueKey.
|
400
|
-
*/
|
401
|
-
parent?: ParentKeys;
|
402
|
-
protected toKey: (type: string) => string;
|
403
|
-
private discarded;
|
404
|
-
constructor(queue: MinimalQueue,
|
405
|
-
/**
|
406
|
-
* The name of the Job
|
407
|
-
*/
|
408
|
-
name: NameType,
|
409
|
-
/**
|
410
|
-
* The payload for this job.
|
411
|
-
*/
|
412
|
-
data: DataType,
|
413
|
-
/**
|
414
|
-
* The options object for this job.
|
415
|
-
*/
|
416
|
-
opts?: JobsOptions, id?: string);
|
417
|
-
/**
|
418
|
-
* Creates a new job and adds it to the queue.
|
419
|
-
*
|
420
|
-
* @param queue - the queue where to add the job.
|
421
|
-
* @param name - the name of the job.
|
422
|
-
* @param data - the payload of the job.
|
423
|
-
* @param opts - the options bag for this job.
|
424
|
-
* @returns
|
425
|
-
*/
|
426
|
-
static create<T = any, R = any, N extends string = string>(queue: MinimalQueue, name: N, data: T, opts?: JobsOptions): Promise<Job<T, R, N>>;
|
427
|
-
/**
|
428
|
-
* Creates a bulk of jobs and adds them atomically to the given queue.
|
429
|
-
*
|
430
|
-
* @param queue -the queue were to add the jobs.
|
431
|
-
* @param jobs - an array of jobs to be added to the queue.
|
432
|
-
* @returns
|
433
|
-
*/
|
434
|
-
static createBulk<T = any, R = any, N extends string = string>(queue: MinimalQueue, jobs: {
|
435
|
-
name: N;
|
436
|
-
data: T;
|
437
|
-
opts?: BulkJobOptions;
|
438
|
-
}[]): Promise<Job<T, R, N>[]>;
|
439
|
-
/**
|
440
|
-
* Instantiates a Job from a JobJsonRaw object (coming from a deserialized JSON object)
|
441
|
-
*
|
442
|
-
* @param queue - the queue where the job belongs to.
|
443
|
-
* @param json - the plain object containing the job.
|
444
|
-
* @param jobId - an optional job id (overrides the id coming from the JSON object)
|
445
|
-
* @returns
|
446
|
-
*/
|
447
|
-
static fromJSON<T = any, R = any, N extends string = string>(queue: MinimalQueue, json: JobJsonRaw, jobId?: string): Job<T, R, N>;
|
448
|
-
/**
|
449
|
-
* Fetches a Job from the queue given the passed job id.
|
450
|
-
*
|
451
|
-
* @param queue - the queue where the job belongs to.
|
452
|
-
* @param jobId - the job id.
|
453
|
-
* @returns
|
454
|
-
*/
|
455
|
-
static fromId<T = any, R = any, N extends string = string>(queue: MinimalQueue, jobId: string): Promise<Job<T, R, N> | undefined>;
|
456
|
-
toJSON(): Omit<this, 'queue'>;
|
457
|
-
/**
|
458
|
-
* Prepares a job to be serialized for storage in Redis.
|
459
|
-
* @returns
|
460
|
-
*/
|
461
|
-
asJSON(): JobJson;
|
462
|
-
/**
|
463
|
-
* Prepares a job to be passed to Sandbox.
|
464
|
-
* @returns
|
465
|
-
*/
|
466
|
-
asJSONSandbox(): JobJsonSandbox;
|
467
|
-
/**
|
468
|
-
* Updates a job's data
|
469
|
-
*
|
470
|
-
* @param data - the data that will replace the current jobs data.
|
471
|
-
*/
|
472
|
-
update(data: DataType): Promise<void>;
|
473
|
-
/**
|
474
|
-
* Updates a job's progress
|
475
|
-
*
|
476
|
-
* @param progress - number or object to be saved as progress.
|
477
|
-
*/
|
478
|
-
updateProgress(progress: number | object): Promise<void>;
|
479
|
-
/**
|
480
|
-
* Logs one row of log data.
|
481
|
-
*
|
482
|
-
* @param logRow - string with log data to be logged.
|
483
|
-
*/
|
484
|
-
log(logRow: string): Promise<number>;
|
485
|
-
/**
|
486
|
-
* Completely remove the job from the queue.
|
487
|
-
* Note, this call will throw an exception if the job
|
488
|
-
* is being processed when the call is performed.
|
489
|
-
*/
|
490
|
-
remove(): Promise<void>;
|
491
|
-
/**
|
492
|
-
* Extend the lock for this job.
|
493
|
-
*
|
494
|
-
* @param token - unique token for the lock
|
495
|
-
* @param duration - lock duration in milliseconds
|
496
|
-
*/
|
497
|
-
extendLock(token: string, duration: number): Promise<number>;
|
498
|
-
/**
|
499
|
-
* Moves a job to the completed queue.
|
500
|
-
* Returned job to be used with Queue.prototype.nextJobFromJobData.
|
501
|
-
*
|
502
|
-
* @param returnValue - The jobs success message.
|
503
|
-
* @param token - Worker token used to acquire completed job.
|
504
|
-
* @param fetchNext - True when wanting to fetch the next job.
|
505
|
-
* @returns Returns the jobData of the next job in the waiting queue.
|
506
|
-
*/
|
507
|
-
moveToCompleted(returnValue: ReturnType, token: string, fetchNext?: boolean): Promise<JobData | []>;
|
508
|
-
/**
|
509
|
-
* Moves a job to the failed queue.
|
510
|
-
*
|
511
|
-
* @param err - the jobs error message.
|
512
|
-
* @param token - token to check job is locked by current worker
|
513
|
-
* @param fetchNext - true when wanting to fetch the next job
|
514
|
-
* @returns void
|
515
|
-
*/
|
516
|
-
moveToFailed<E extends Error>(err: E, token: string, fetchNext?: boolean): Promise<void>;
|
517
|
-
/**
|
518
|
-
* @returns true if the job has completed.
|
519
|
-
*/
|
520
|
-
isCompleted(): Promise<boolean>;
|
521
|
-
/**
|
522
|
-
* @returns true if the job has failed.
|
523
|
-
*/
|
524
|
-
isFailed(): Promise<boolean>;
|
525
|
-
/**
|
526
|
-
* @returns true if the job is delayed.
|
527
|
-
*/
|
528
|
-
isDelayed(): Promise<boolean>;
|
529
|
-
/**
|
530
|
-
* @returns true if the job is waiting for children.
|
531
|
-
*/
|
532
|
-
isWaitingChildren(): Promise<boolean>;
|
533
|
-
/**
|
534
|
-
* @returns true of the job is active.
|
535
|
-
*/
|
536
|
-
isActive(): Promise<boolean>;
|
537
|
-
/**
|
538
|
-
* @returns true if the job is waiting.
|
539
|
-
*/
|
540
|
-
isWaiting(): Promise<boolean>;
|
541
|
-
/**
|
542
|
-
* @returns the queue name this job belongs to.
|
543
|
-
*/
|
544
|
-
get queueName(): string;
|
545
|
-
get prefix(): string;
|
546
|
-
/**
|
547
|
-
* Get current state.
|
548
|
-
*
|
549
|
-
* @returns Returns one of these values:
|
550
|
-
* 'completed', 'failed', 'delayed', 'active', 'waiting', 'waiting-children', 'unknown'.
|
551
|
-
*/
|
552
|
-
getState(): Promise<JobState | 'unknown'>;
|
553
|
-
/**
|
554
|
-
* Change delay of a delayed job.
|
555
|
-
*
|
556
|
-
* @param delay - milliseconds to be added to current time.
|
557
|
-
* @returns void
|
558
|
-
*/
|
559
|
-
changeDelay(delay: number): Promise<void>;
|
560
|
-
/**
|
561
|
-
* Get this jobs children result values if any.
|
562
|
-
*
|
563
|
-
* @returns Object mapping children job keys with their values.
|
564
|
-
*/
|
565
|
-
getChildrenValues<CT = any>(): Promise<{
|
566
|
-
[jobKey: string]: CT;
|
567
|
-
}>;
|
568
|
-
/**
|
569
|
-
* Get children job keys if this job is a parent and has children.
|
570
|
-
*
|
571
|
-
* @returns dependencies separated by processed and unprocessed.
|
572
|
-
*/
|
573
|
-
getDependencies(opts?: DependenciesOpts): Promise<{
|
574
|
-
nextProcessedCursor?: number;
|
575
|
-
processed?: Record<string, any>;
|
576
|
-
nextUnprocessedCursor?: number;
|
577
|
-
unprocessed?: string[];
|
578
|
-
}>;
|
579
|
-
/**
|
580
|
-
* Get children job counts if this job is a parent and has children.
|
581
|
-
*
|
582
|
-
* @returns dependencies count separated by processed and unprocessed.
|
583
|
-
*/
|
584
|
-
getDependenciesCount(opts?: {
|
585
|
-
processed?: boolean;
|
586
|
-
unprocessed?: boolean;
|
587
|
-
}): Promise<{
|
588
|
-
processed?: number;
|
589
|
-
unprocessed?: number;
|
590
|
-
}>;
|
591
|
-
/**
|
592
|
-
* Returns a promise the resolves when the job has completed (containing the return value of the job),
|
593
|
-
* or rejects when the job has failed (containing the failedReason).
|
594
|
-
*
|
595
|
-
* @param queueEvents - Instance of QueueEvents.
|
596
|
-
* @param ttl - Time in milliseconds to wait for job to finish before timing out.
|
597
|
-
*/
|
598
|
-
waitUntilFinished(queueEvents: QueueEvents, ttl?: number): Promise<ReturnType>;
|
599
|
-
/**
|
600
|
-
* Moves the job to the delay set.
|
601
|
-
*
|
602
|
-
* @param timestamp - timestamp where the job should be moved back to "wait"
|
603
|
-
* @returns
|
604
|
-
*/
|
605
|
-
moveToDelayed(timestamp: number): Promise<void>;
|
606
|
-
/**
|
607
|
-
* Moves the job to the waiting-children set.
|
608
|
-
*
|
609
|
-
* @param token - Token to check job is locked by current worker
|
610
|
-
* @param opts - The options bag for moving a job to waiting-children.
|
611
|
-
* @returns true if the job was moved
|
612
|
-
*/
|
613
|
-
moveToWaitingChildren(token: string, opts?: MoveToChildrenOpts): Promise<boolean>;
|
614
|
-
/**
|
615
|
-
* Promotes a delayed job so that it starts to be processed as soon as possible.
|
616
|
-
*/
|
617
|
-
promote(): Promise<void>;
|
618
|
-
/**
|
619
|
-
* Attempts to retry the job. Only a job that has failed or completed can be retried.
|
620
|
-
*
|
621
|
-
* @param state - completed / failed
|
622
|
-
* @returns If resolved and return code is 1, then the queue emits a waiting event
|
623
|
-
* otherwise the operation was not a success and throw the corresponding error. If the promise
|
624
|
-
* rejects, it indicates that the script failed to execute
|
625
|
-
*/
|
626
|
-
retry(state?: FinishedStatus): Promise<void>;
|
627
|
-
/**
|
628
|
-
* Marks a job to not be retried if it fails (even if attempts has been configured)
|
629
|
-
*/
|
630
|
-
discard(): void;
|
631
|
-
private isInZSet;
|
632
|
-
private isInList;
|
633
|
-
/**
|
634
|
-
* Adds the job to Redis.
|
635
|
-
*
|
636
|
-
* @param client -
|
637
|
-
* @param parentOpts -
|
638
|
-
* @returns
|
639
|
-
*/
|
640
|
-
addJob(client: RedisClient, parentOpts?: ParentOpts): Promise<string>;
|
641
|
-
private saveStacktrace;
|
642
|
-
}
|
643
|
-
|
644
|
-
export declare type JobData = [JobJsonRaw | number, string?];
|
645
|
-
|
646
|
-
export declare function jobIdForGroup(jobOpts: JobsOptions, data: any, queueOpts: QueueOptions): string;
|
647
|
-
|
648
|
-
export declare interface JobInformation3 {
|
649
|
-
key: string;
|
650
|
-
name: string;
|
651
|
-
id?: string;
|
652
|
-
endDate?: number;
|
653
|
-
tz?: string;
|
654
|
-
cron: string;
|
655
|
-
next: number;
|
656
|
-
}
|
657
|
-
|
658
|
-
export declare interface JobJson {
|
659
|
-
id: string;
|
660
|
-
name: string;
|
661
|
-
data: string;
|
662
|
-
opts: JobsOptions;
|
663
|
-
progress: number | object;
|
664
|
-
attemptsMade: number;
|
665
|
-
finishedOn?: number;
|
666
|
-
processedOn?: number;
|
667
|
-
timestamp: number;
|
668
|
-
failedReason: string;
|
669
|
-
stacktrace: string;
|
670
|
-
returnvalue: string;
|
671
|
-
parentKey?: string;
|
672
|
-
}
|
673
|
-
|
674
|
-
export declare interface JobJsonRaw {
|
675
|
-
id: string;
|
676
|
-
name: string;
|
677
|
-
data: string;
|
678
|
-
opts: string;
|
679
|
-
progress: string;
|
680
|
-
attemptsMade: string;
|
681
|
-
finishedOn?: string;
|
682
|
-
processedOn?: string;
|
683
|
-
timestamp: string;
|
684
|
-
failedReason: string;
|
685
|
-
stacktrace: string[];
|
686
|
-
returnvalue: string;
|
687
|
-
parentKey?: string;
|
688
|
-
parent?: string;
|
689
|
-
}
|
690
|
-
|
691
|
-
export declare type JobJsonSandbox = JobJson & {
|
692
|
-
queueName: string;
|
693
|
-
parent?: ParentKeys;
|
694
|
-
prefix: string;
|
695
|
-
};
|
696
|
-
|
697
|
-
export declare interface JobNode {
|
698
|
-
job: Job;
|
699
|
-
children?: JobNode[];
|
700
|
-
}
|
701
|
-
|
702
|
-
export declare interface JobPromise3 {
|
703
|
-
/**
|
704
|
-
* Abort this job
|
705
|
-
*/
|
706
|
-
cancel(): void;
|
707
|
-
}
|
708
|
-
|
709
|
-
export declare interface JobsOptions {
|
710
|
-
/**
|
711
|
-
* Timestamp when the job was created. Defaults to `Date.now()`.
|
712
|
-
*/
|
713
|
-
timestamp?: number;
|
714
|
-
/**
|
715
|
-
* Ranges from 1 (highest priority) to MAX_INT (lowest priority). Note that
|
716
|
-
* using priorities has a slight impact on performance,
|
717
|
-
* so do not use it if not required.
|
718
|
-
*/
|
719
|
-
priority?: number;
|
720
|
-
/**
|
721
|
-
* An amount of milliseconds to wait until this job can be processed.
|
722
|
-
* Note that for accurate delays, worker and producers
|
723
|
-
* should have their clocks synchronized.
|
724
|
-
* @defaultValue 0
|
725
|
-
*/
|
726
|
-
delay?: number;
|
727
|
-
/**
|
728
|
-
* The total number of attempts to try the job until it completes.
|
729
|
-
* @defaultValue 0
|
730
|
-
*/
|
731
|
-
attempts?: number;
|
732
|
-
/**
|
733
|
-
* Repeat this job, for example based on a `cron` schedule.
|
734
|
-
*/
|
735
|
-
repeat?: RepeatOptions;
|
736
|
-
/**
|
737
|
-
* Rate limiter key to use if rate limiter enabled.
|
738
|
-
*
|
739
|
-
* @see {@link https://docs.bullmq.io/guide/rate-limiting}
|
740
|
-
*/
|
741
|
-
rateLimiterKey?: string;
|
742
|
-
/**
|
743
|
-
* Backoff setting for automatic retries if the job fails
|
744
|
-
*/
|
745
|
-
backoff?: number | BackoffOptions;
|
746
|
-
/**
|
747
|
-
* If true, adds the job to the right of the queue instead of the left (default false)
|
748
|
-
*
|
749
|
-
* @see {@link https://docs.bullmq.io/guide/jobs/lifo}
|
750
|
-
*/
|
751
|
-
lifo?: boolean;
|
752
|
-
/**
|
753
|
-
* The number of milliseconds after which the job should be
|
754
|
-
* fail with a timeout error.
|
755
|
-
*/
|
756
|
-
timeout?: number;
|
757
|
-
/**
|
758
|
-
* Override the job ID - by default, the job ID is a unique
|
759
|
-
* integer, but you can use this setting to override it.
|
760
|
-
* If you use this option, it is up to you to ensure the
|
761
|
-
* jobId is unique. If you attempt to add a job with an id that
|
762
|
-
* already exists, it will not be added.
|
763
|
-
*/
|
764
|
-
jobId?: string;
|
765
|
-
/**
|
766
|
-
* If true, removes the job when it successfully completes
|
767
|
-
* When given an number, it specifies the maximum amount of
|
768
|
-
* jobs to keep, or you can provide an object specifying max
|
769
|
-
* age and/or count to keep.
|
770
|
-
* Default behavior is to keep the job in the completed set.
|
771
|
-
*/
|
772
|
-
removeOnComplete?: boolean | number | KeepJobs;
|
773
|
-
/**
|
774
|
-
* If true, removes the job when it fails after all attempts.
|
775
|
-
* When given an number, it specifies the maximum amount of
|
776
|
-
* jobs to keep, or you can provide an object specifying max
|
777
|
-
* age and/or count to keep.
|
778
|
-
*/
|
779
|
-
removeOnFail?: boolean | number | KeepJobs;
|
780
|
-
/**
|
781
|
-
* Limits the amount of stack trace lines that will be recorded in the stacktrace.
|
782
|
-
*/
|
783
|
-
stackTraceLimit?: number;
|
784
|
-
/**
|
785
|
-
*
|
786
|
-
*/
|
787
|
-
parent?: {
|
788
|
-
id: string;
|
789
|
-
queue: string;
|
790
|
-
};
|
791
|
-
/**
|
792
|
-
* Internal property used by repeatable jobs.
|
793
|
-
*/
|
794
|
-
prevMillis?: number;
|
795
|
-
/**
|
796
|
-
* Limits the size in bytes of the job's data payload (as a JSON serialized string).
|
797
|
-
*/
|
798
|
-
sizeLimit?: number;
|
799
|
-
}
|
800
|
-
|
801
|
-
export declare type JobState = FinishedStatus | 'active' | 'delayed' | 'waiting' | 'waiting-children';
|
802
|
-
|
803
|
-
export declare type JobStatusClean3 = 'completed' | 'wait' | 'active' | 'delayed' | 'paused' | 'failed';
|
804
|
-
|
805
|
-
export declare type JobType = JobState | 'paused' | 'repeat' | 'wait';
|
806
|
-
|
807
|
-
/**
|
808
|
-
* KeepJobs
|
809
|
-
*
|
810
|
-
* Specify which jobs to keep after finishing. If both age and count are
|
811
|
-
* specified, then the jobs kept will be the ones that satisfies both
|
812
|
-
* properties.
|
813
|
-
*/
|
814
|
-
export declare interface KeepJobs {
|
815
|
-
/**
|
816
|
-
* Maximum age in seconds for job to be kept.
|
817
|
-
*/
|
818
|
-
age?: number;
|
819
|
-
/**
|
820
|
-
* Maximum count of jobs to be kept.
|
821
|
-
*/
|
822
|
-
count?: number;
|
823
|
-
}
|
824
|
-
|
825
|
-
export declare type KeysMap = {
|
826
|
-
[index in string]: string;
|
827
|
-
};
|
828
|
-
|
829
|
-
/**
|
830
|
-
* Sends a kill signal to a child resolving when the child has exited,
|
831
|
-
* resorting to SIGKILL if the given timeout is reached
|
832
|
-
*/
|
833
|
-
export declare function killAsync(child: ChildProcess, signal?: 'SIGTERM' | 'SIGKILL', timeoutMs?: number): Promise<void>;
|
834
|
-
|
835
|
-
/**
|
836
|
-
* Checks the size of string for ascii/non-ascii characters
|
837
|
-
* @see https://stackoverflow.com/a/23318053/1347170
|
838
|
-
* @param str -
|
839
|
-
*/
|
840
|
-
export declare function lengthInUtf8Bytes(str: string): number;
|
841
|
-
|
842
|
-
export declare interface Metrics {
|
843
|
-
meta: {
|
844
|
-
count: number;
|
845
|
-
prevTS: number;
|
846
|
-
prevCount: number;
|
847
|
-
};
|
848
|
-
data: number[];
|
849
|
-
count: number;
|
850
|
-
}
|
851
|
-
|
852
|
-
/**
|
853
|
-
*
|
854
|
-
*
|
855
|
-
*/
|
856
|
-
export declare interface MetricsOptions {
|
857
|
-
/**
|
858
|
-
* Enable gathering metrics for finished jobs.
|
859
|
-
* Output refers to all finished jobs, completed or
|
860
|
-
* failed.
|
861
|
-
*/
|
862
|
-
maxDataPoints?: number;
|
863
|
-
}
|
864
|
-
|
865
|
-
export declare enum MetricsTime {
|
866
|
-
ONE_MINUTE = 1,
|
867
|
-
FIVE_MINUTES = 5,
|
868
|
-
FIFTEEN_MINUTES = 15,
|
869
|
-
THIRTY_MINUTES = 30,
|
870
|
-
ONE_HOUR = 60,
|
871
|
-
ONE_WEEK = 10080,
|
872
|
-
TWO_WEEKS = 20160,
|
873
|
-
ONE_MONTH = 80640
|
874
|
-
}
|
875
|
-
|
876
|
-
export declare type MinimalQueue = Pick<QueueBase, 'name' | 'client' | 'toKey' | 'keys' | 'opts' | 'closing' | 'waitUntilReady' | 'removeListener' | 'emit' | 'on' | 'redisVersion'>;
|
877
|
-
|
878
|
-
export declare interface MoveToChildrenOpts {
|
879
|
-
timestamp?: number;
|
880
|
-
child?: {
|
881
|
-
id: string;
|
882
|
-
queue: string;
|
883
|
-
};
|
884
|
-
}
|
885
|
-
|
886
|
-
export declare interface NodeOpts {
|
887
|
-
/**
|
888
|
-
* Root job queue name.
|
889
|
-
*/
|
890
|
-
queueName: string;
|
891
|
-
/**
|
892
|
-
* Prefix included in job key.
|
893
|
-
*/
|
894
|
-
prefix?: string;
|
895
|
-
/**
|
896
|
-
* Root job id.
|
897
|
-
*/
|
898
|
-
id: string;
|
899
|
-
/**
|
900
|
-
* Maximum depth or levels to visit in the tree.
|
901
|
-
*/
|
902
|
-
depth?: number;
|
903
|
-
/**
|
904
|
-
* Maximum quantity of children per type (processed, unprocessed).
|
905
|
-
*/
|
906
|
-
maxChildren?: number;
|
907
|
-
}
|
908
|
-
|
909
|
-
export declare interface ObliterateOpts {
|
910
|
-
/**
|
911
|
-
* Use force = true to force obliteration even with active jobs in the queue
|
912
|
-
* @defaultValue false
|
913
|
-
*/
|
914
|
-
force?: boolean;
|
915
|
-
/**
|
916
|
-
* Use count with the maximum number of deleted keys per iteration
|
917
|
-
* @defaultValue 1000
|
918
|
-
*/
|
919
|
-
count?: number;
|
920
|
-
}
|
921
|
-
|
922
|
-
/**
|
923
|
-
* Describes the parent for a Job.
|
924
|
-
*/
|
925
|
-
export declare interface Parent<T> {
|
926
|
-
name: string;
|
927
|
-
prefix?: string;
|
928
|
-
queue?: string;
|
929
|
-
data?: T;
|
930
|
-
opts?: JobsOptions;
|
931
|
-
}
|
932
|
-
|
933
|
-
export declare enum ParentCommand {
|
934
|
-
InitFailed = 0,
|
935
|
-
InitCompleted = 1,
|
936
|
-
Completed = 2,
|
937
|
-
Failed = 3,
|
938
|
-
Error = 4,
|
939
|
-
Progress = 5,
|
940
|
-
Log = 6
|
941
|
-
}
|
942
|
-
|
943
|
-
export declare interface ParentKeys {
|
944
|
-
id: string;
|
945
|
-
queueKey: string;
|
946
|
-
}
|
947
|
-
|
948
|
-
export declare interface ParentMessage {
|
949
|
-
cmd: ChildCommand;
|
950
|
-
value?: any;
|
951
|
-
err?: Error;
|
952
|
-
job?: JobJson;
|
953
|
-
}
|
954
|
-
|
955
|
-
export declare type ParentOpts = {
|
956
|
-
waitChildrenKey?: string;
|
957
|
-
parentDependenciesKey?: string;
|
958
|
-
parentKey?: string;
|
959
|
-
};
|
960
|
-
|
961
|
-
export declare const parentSend: (child: ChildProcess, msg: ParentMessage) => Promise<void>;
|
962
|
-
|
963
|
-
/**
|
964
|
-
* An async function that receives `Job`s and handles them.
|
965
|
-
*/
|
966
|
-
export declare type Processor<T = any, R = any, N extends string = string> = (job: Job<T, R, N>, token?: string) => Promise<R>;
|
967
|
-
|
968
|
-
declare interface procSendLike {
|
969
|
-
send?(message: any, callback?: (error: Error | null) => void): boolean;
|
970
|
-
}
|
971
|
-
|
972
|
-
export declare type ProgressEventCallback3<T = any> = (job: Job, progress: any) => void;
|
973
|
-
|
974
|
-
/**
|
975
|
-
* Queue
|
976
|
-
*
|
977
|
-
* This class provides methods to add jobs to a queue and some othe high-level
|
978
|
-
* administration such as pausing or deleting queues.
|
979
|
-
*
|
980
|
-
*/
|
981
|
-
export declare class Queue<DataType = any, ResultType = any, NameType extends string = string> extends QueueGetters<DataType, ResultType, NameType> {
|
982
|
-
token: string;
|
983
|
-
jobsOpts: JobsOptions;
|
984
|
-
limiter: {
|
985
|
-
groupKey: string;
|
986
|
-
};
|
987
|
-
private _repeat;
|
988
|
-
constructor(name: string, opts?: QueueOptions, Connection?: typeof RedisConnection);
|
989
|
-
emit<U extends keyof QueueListener<DataType, ResultType, NameType>>(event: U, ...args: Parameters<QueueListener<DataType, ResultType, NameType>[U]>): boolean;
|
990
|
-
off<U extends keyof QueueListener<DataType, ResultType, NameType>>(eventName: U, listener: QueueListener<DataType, ResultType, NameType>[U]): this;
|
991
|
-
on<U extends keyof QueueListener<DataType, ResultType, NameType>>(event: U, listener: QueueListener<DataType, ResultType, NameType>[U]): this;
|
992
|
-
once<U extends keyof QueueListener<DataType, ResultType, NameType>>(event: U, listener: QueueListener<DataType, ResultType, NameType>[U]): this;
|
993
|
-
/**
|
994
|
-
* Returns this instance current default job options.
|
995
|
-
*/
|
996
|
-
get defaultJobOptions(): JobsOptions;
|
997
|
-
get repeat(): Promise<Repeat>;
|
998
|
-
/**
|
999
|
-
* Adds a new job to the queue.
|
1000
|
-
*
|
1001
|
-
* @param name - Name of the job to be added to the queue,.
|
1002
|
-
* @param data - Arbitrary data to append to the job.
|
1003
|
-
* @param opts - Job options that affects how the job is going to be processed.
|
1004
|
-
*/
|
1005
|
-
add(name: NameType, data: DataType, opts?: JobsOptions): Promise<Job<DataType, ResultType, NameType>>;
|
1006
|
-
/**
|
1007
|
-
* Adds an array of jobs to the queue.
|
1008
|
-
*
|
1009
|
-
* @param jobs - The array of jobs to add to the queue. Each job is defined by 3
|
1010
|
-
* properties, 'name', 'data' and 'opts'. They follow the same signature as 'Queue.add'.
|
1011
|
-
*/
|
1012
|
-
addBulk(jobs: {
|
1013
|
-
name: NameType;
|
1014
|
-
data: DataType;
|
1015
|
-
opts?: BulkJobOptions;
|
1016
|
-
}[]): Promise<Job<DataType, DataType, NameType>[]>;
|
1017
|
-
/**
|
1018
|
-
* Pauses the processing of this queue globally.
|
1019
|
-
*
|
1020
|
-
* We use an atomic RENAME operation on the wait queue. Since
|
1021
|
-
* we have blocking calls with BRPOPLPUSH on the wait queue, as long as the queue
|
1022
|
-
* is renamed to 'paused', no new jobs will be processed (the current ones
|
1023
|
-
* will run until finalized).
|
1024
|
-
*
|
1025
|
-
* Adding jobs requires a LUA script to check first if the paused list exist
|
1026
|
-
* and in that case it will add it there instead of the wait list.
|
1027
|
-
*/
|
1028
|
-
pause(): Promise<void>;
|
1029
|
-
close(): Promise<void>;
|
1030
|
-
/**
|
1031
|
-
* Resumes the processing of this queue globally.
|
1032
|
-
*
|
1033
|
-
* The method reverses the pause operation by resuming the processing of the
|
1034
|
-
* queue.
|
1035
|
-
*/
|
1036
|
-
resume(): Promise<void>;
|
1037
|
-
/**
|
1038
|
-
* Returns true if the queue is currently paused.
|
1039
|
-
*/
|
1040
|
-
isPaused(): Promise<boolean>;
|
1041
|
-
/**
|
1042
|
-
* Get all repeatable meta jobs.
|
1043
|
-
*
|
1044
|
-
* @param start - Offset of first job to return.
|
1045
|
-
* @param end - Offset of last job to return.
|
1046
|
-
* @param asc - Determine the order in which jobs are returned based on their
|
1047
|
-
* next execution time.
|
1048
|
-
*/
|
1049
|
-
getRepeatableJobs(start?: number, end?: number, asc?: boolean): Promise<{
|
1050
|
-
key: string;
|
1051
|
-
name: string;
|
1052
|
-
id: string;
|
1053
|
-
endDate: number;
|
1054
|
-
tz: string;
|
1055
|
-
cron: string;
|
1056
|
-
next: number;
|
1057
|
-
}[]>;
|
1058
|
-
removeRepeatable(name: NameType, repeatOpts: RepeatOptions, jobId?: string): Promise<void>;
|
1059
|
-
removeRepeatableByKey(key: string): Promise<void>;
|
1060
|
-
/**
|
1061
|
-
* Removes the given job from the queue as well as all its
|
1062
|
-
* dependencies.
|
1063
|
-
*
|
1064
|
-
* @param jobId - The id of the job to remove
|
1065
|
-
* @returns 1 if it managed to remove the job or 0 if the job or
|
1066
|
-
* any of its dependencies was locked.
|
1067
|
-
*/
|
1068
|
-
remove(jobId: string): Promise<number>;
|
1069
|
-
/**
|
1070
|
-
* Drains the queue, i.e., removes all jobs that are waiting
|
1071
|
-
* or delayed, but not active, completed or failed.
|
1072
|
-
*
|
1073
|
-
* @param delayed - Pass true if it should also clean the
|
1074
|
-
* delayed jobs.
|
1075
|
-
*/
|
1076
|
-
drain(delayed?: boolean): Promise<void>;
|
1077
|
-
/**
|
1078
|
-
* Cleans jobs from a queue. Similar to drain but keeps jobs within a certain
|
1079
|
-
* grace period.
|
1080
|
-
*
|
1081
|
-
* @param grace - The grace period
|
1082
|
-
* @param limit - Max number of jobs to clean
|
1083
|
-
* @param type - Default completed - The type of job to clean
|
1084
|
-
* Possible values are completed, wait, active, paused, delayed, failed. Defaults to completed.
|
1085
|
-
* @returns Id jobs from the deleted records
|
1086
|
-
*/
|
1087
|
-
clean(grace: number, limit: number, type?: 'completed' | 'wait' | 'active' | 'paused' | 'delayed' | 'failed'): Promise<string[]>;
|
1088
|
-
/**
|
1089
|
-
* Completely destroys the queue and all of its contents irreversibly.
|
1090
|
-
* This method will the *pause* the queue and requires that there are no
|
1091
|
-
* active jobs. It is possible to bypass this requirement, i.e. not
|
1092
|
-
* having active jobs using the "force" option.
|
1093
|
-
*
|
1094
|
-
* Note: This operation requires to iterate on all the jobs stored in the queue
|
1095
|
-
* and can be slow for very large queues.
|
1096
|
-
*
|
1097
|
-
* @param opts - Obliterate options.
|
1098
|
-
*/
|
1099
|
-
obliterate(opts?: ObliterateOpts): Promise<void>;
|
1100
|
-
/**
|
1101
|
-
* Retry all the failed jobs.
|
1102
|
-
*
|
1103
|
-
* @param opts - contains number to limit how many jobs will be moved to wait status per iteration,
|
1104
|
-
* state (failed, completed) failed by default or from which timestamp.
|
1105
|
-
* @returns
|
1106
|
-
*/
|
1107
|
-
retryJobs(opts?: {
|
1108
|
-
count?: number;
|
1109
|
-
state?: FinishedStatus;
|
1110
|
-
timestamp?: number;
|
1111
|
-
}): Promise<void>;
|
1112
|
-
/**
|
1113
|
-
* Trim the event stream to an approximately maxLength.
|
1114
|
-
*
|
1115
|
-
* @param maxLength -
|
1116
|
-
*/
|
1117
|
-
trimEvents(maxLength: number): Promise<number>;
|
1118
|
-
}
|
1119
|
-
|
1120
|
-
/**
|
1121
|
-
* @deprecated Use Queue class instead {@link https://docs.bullmq.io/guide/queues}
|
1122
|
-
*/
|
1123
|
-
export declare class Queue3<T = any> extends EventEmitter {
|
1124
|
-
/**
|
1125
|
-
* The name of the queue
|
1126
|
-
*/
|
1127
|
-
name: string;
|
1128
|
-
queueEvents: QueueEvents;
|
1129
|
-
private opts;
|
1130
|
-
private readonly queue;
|
1131
|
-
private worker;
|
1132
|
-
private queueScheduler;
|
1133
|
-
/**
|
1134
|
-
* This is the Queue constructor.
|
1135
|
-
* It creates a new Queue that is persisted in Redis.
|
1136
|
-
* Every time the same queue is instantiated it tries to process all the old jobs
|
1137
|
-
* that may exist from a previous unfinished session.
|
1138
|
-
*/
|
1139
|
-
constructor(name: string, opts?: CommonOptions);
|
1140
|
-
/**
|
1141
|
-
* Returns a promise that resolves when Redis is connected and the queue is ready to accept jobs.
|
1142
|
-
* This replaces the `ready` event emitted on Queue in previous versions.
|
1143
|
-
*/
|
1144
|
-
isReady(): Promise<this>;
|
1145
|
-
/**
|
1146
|
-
* Defines a processing function for the jobs placed into a given Queue.
|
1147
|
-
*
|
1148
|
-
* The callback is called every time a job is placed in the queue.
|
1149
|
-
* It is passed an instance of the job as first argument.
|
1150
|
-
*
|
1151
|
-
* If the callback signature contains the second optional done argument,
|
1152
|
-
* the callback will be passed a done callback to be called after the job has been completed.
|
1153
|
-
* The done callback can be called with an Error instance, to signal that the job did not complete successfully,
|
1154
|
-
* or with a result as second argument (e.g.: done(null, result);) when the job is successful.
|
1155
|
-
* Errors will be passed as a second argument to the "failed" event; results,
|
1156
|
-
* as a second argument to the "completed" event.
|
1157
|
-
*
|
1158
|
-
* If, however, the callback signature does not contain the done argument,
|
1159
|
-
* a promise must be returned to signal job completion.
|
1160
|
-
* If the promise is rejected, the error will be passed as a second argument to the "failed" event.
|
1161
|
-
* If it is resolved, its value will be the "completed" event's second argument.
|
1162
|
-
*/
|
1163
|
-
process(processor: string | Processor<T>): Promise<void>;
|
1164
|
-
add(jobName: string, data: any, opts?: JobsOptions): Promise<Job>;
|
1165
|
-
/**
|
1166
|
-
* Returns a promise that resolves when the queue is paused.
|
1167
|
-
*
|
1168
|
-
* A paused queue will not process new jobs until resumed, but current jobs being processed will continue until
|
1169
|
-
* they are finalized. The pause can be either global or local. If global, all workers in all queue instances
|
1170
|
-
* for a given queue will be paused. If local, just this worker will stop processing new jobs after the current
|
1171
|
-
* lock expires. This can be useful to stop a worker from taking new jobs prior to shutting down.
|
1172
|
-
*
|
1173
|
-
* Pausing a queue that is already paused does nothing.
|
1174
|
-
*/
|
1175
|
-
pause(): Promise<void>;
|
1176
|
-
pauseWorker(doNotWaitActive?: boolean): Promise<void>;
|
1177
|
-
/**
|
1178
|
-
* Returns a promise that resolves when the queue is resumed after being paused.
|
1179
|
-
*
|
1180
|
-
* The resume can be either local or global. If global, all workers in all queue instances for a given queue
|
1181
|
-
* will be resumed. If local, only this worker will be resumed. Note that resuming a queue globally will not
|
1182
|
-
* resume workers that have been paused locally; for those, resume(true) must be called directly on their
|
1183
|
-
* instances.
|
1184
|
-
*
|
1185
|
-
* Resuming a queue that is not paused does nothing.
|
1186
|
-
*/
|
1187
|
-
resume(): Promise<void>;
|
1188
|
-
resumeWorker(): Promise<void>;
|
1189
|
-
isWorkerPaused(): boolean;
|
1190
|
-
/**
|
1191
|
-
* Returns a promise that returns the number of jobs in the queue, waiting or paused.
|
1192
|
-
* Since there may be other processes adding or processing jobs,
|
1193
|
-
* this value may be true only for a very small amount of time.
|
1194
|
-
*/
|
1195
|
-
count(): Promise<number>;
|
1196
|
-
/**
|
1197
|
-
* Empties a queue deleting all the input lists and associated jobs.
|
1198
|
-
*/
|
1199
|
-
empty(): Promise<void>;
|
1200
|
-
/**
|
1201
|
-
* Closes the underlying redis client. Use this to perform a graceful shutdown.
|
1202
|
-
*
|
1203
|
-
* `close` can be called from anywhere, with one caveat:
|
1204
|
-
* if called from within a job handler the queue won't close until after the job has been processed
|
1205
|
-
*/
|
1206
|
-
close(): Promise<any>;
|
1207
|
-
/**
|
1208
|
-
* Returns a promise that will return the job instance associated with the jobId parameter.
|
1209
|
-
* If the specified job cannot be located, the promise callback parameter will be set to null.
|
1210
|
-
*/
|
1211
|
-
getJob(jobId: string): Promise<Job | null>;
|
1212
|
-
/**
|
1213
|
-
* Returns a promise that will return an array with the waiting jobs between start and end.
|
1214
|
-
*/
|
1215
|
-
getWaiting(start?: number, end?: number): Promise<Array<Job>>;
|
1216
|
-
/**
|
1217
|
-
* Returns a promise that will return an array with the active jobs between start and end.
|
1218
|
-
*/
|
1219
|
-
getActive(start?: number, end?: number): Promise<Array<Job>>;
|
1220
|
-
/**
|
1221
|
-
* Returns a promise that will return an array with the delayed jobs between start and end.
|
1222
|
-
*/
|
1223
|
-
getDelayed(start?: number, end?: number): Promise<Array<Job>>;
|
1224
|
-
/**
|
1225
|
-
* Returns a promise that will return an array with the completed jobs between start and end.
|
1226
|
-
*/
|
1227
|
-
getCompleted(start?: number, end?: number): Promise<Array<Job>>;
|
1228
|
-
/**
|
1229
|
-
* Returns a promise that will return an array with the failed jobs between start and end.
|
1230
|
-
*/
|
1231
|
-
getFailed(start?: number, end?: number): Promise<Array<Job>>;
|
1232
|
-
/**
|
1233
|
-
* Returns JobInformation of repeatable jobs (ordered descending). Provide a start and/or an end
|
1234
|
-
* index to limit the number of results. Start defaults to 0, end to -1 and asc to false.
|
1235
|
-
*/
|
1236
|
-
getRepeatableJobs(start?: number, end?: number, asc?: boolean): Promise<JobInformation3[]>;
|
1237
|
-
/**
|
1238
|
-
* ???
|
1239
|
-
*/
|
1240
|
-
nextRepeatableJob(name: string, data: any, opts?: JobsOptions, skipCheckExists?: boolean): Promise<Job>;
|
1241
|
-
/**
|
1242
|
-
* Removes a given repeatable job. The RepeatOptions and JobId needs to be the same as the ones
|
1243
|
-
* used for the job when it was added.
|
1244
|
-
*
|
1245
|
-
* name: The name of the to be removed job
|
1246
|
-
*/
|
1247
|
-
removeRepeatable(name: string, opts: RepeatOptions): Promise<void>;
|
1248
|
-
/**
|
1249
|
-
* Removes a given repeatable job by key.
|
1250
|
-
*/
|
1251
|
-
removeRepeatableByKey(repeatJobKey: string): Promise<void>;
|
1252
|
-
/**
|
1253
|
-
* Returns a promise that will return an array of job instances of the given types.
|
1254
|
-
* Optional parameters for range and ordering are provided.
|
1255
|
-
*/
|
1256
|
-
getJobs(types: JobType[] | JobType, start?: number, end?: number, asc?: boolean): Promise<Array<Job>>;
|
1257
|
-
getNextJob(): Promise<Job>;
|
1258
|
-
/**
|
1259
|
-
* Returns a object with the logs according to the start and end arguments. The returned count
|
1260
|
-
* value is the total amount of logs, useful for implementing pagination.
|
1261
|
-
*/
|
1262
|
-
getJobLogs(jobId: string, start?: number, end?: number): Promise<{
|
1263
|
-
logs: string[];
|
1264
|
-
count: number;
|
1265
|
-
}>;
|
1266
|
-
/**
|
1267
|
-
* Returns a promise that resolves with the job counts for the given queue.
|
1268
|
-
*/
|
1269
|
-
getJobCounts(...types: JobType[]): Promise<{
|
1270
|
-
[index: string]: number;
|
1271
|
-
}>;
|
1272
|
-
/**
|
1273
|
-
* Returns a promise that resolves with the job counts for the given queue of the given types.
|
1274
|
-
*/
|
1275
|
-
getJobCountByTypes(...types: JobType[]): Promise<number>;
|
1276
|
-
/**
|
1277
|
-
* Returns a promise that resolves with the quantity of completed jobs.
|
1278
|
-
*/
|
1279
|
-
getCompletedCount(): Promise<number>;
|
1280
|
-
/**
|
1281
|
-
* Returns a promise that resolves with the quantity of failed jobs.
|
1282
|
-
*/
|
1283
|
-
getFailedCount(): Promise<number>;
|
1284
|
-
/**
|
1285
|
-
* Returns a promise that resolves with the quantity of delayed jobs.
|
1286
|
-
*/
|
1287
|
-
getDelayedCount(): Promise<number>;
|
1288
|
-
/**
|
1289
|
-
* Returns a promise that resolves with the quantity of waiting jobs.
|
1290
|
-
*/
|
1291
|
-
getWaitingCount(): Promise<number>;
|
1292
|
-
/**
|
1293
|
-
* Returns a promise that resolves with the quantity of paused jobs.
|
1294
|
-
*/
|
1295
|
-
getPausedCount(): Promise<number>;
|
1296
|
-
/**
|
1297
|
-
* Returns a promise that resolves with the quantity of active jobs.
|
1298
|
-
*/
|
1299
|
-
getActiveCount(): Promise<number>;
|
1300
|
-
/**
|
1301
|
-
* Returns a promise that resolves to the quantity of repeatable jobs.
|
1302
|
-
*/
|
1303
|
-
getRepeatableCount(): Promise<number>;
|
1304
|
-
/**
|
1305
|
-
* Tells the queue remove all jobs created outside of a grace period in milliseconds.
|
1306
|
-
* You can clean the jobs with the following states: completed, wait (typo for waiting), active, delayed, and failed.
|
1307
|
-
* @param grace - Grace period in milliseconds.
|
1308
|
-
* @param limit - Maximum amount of jobs to clean per call. If not provided will clean all matching jobs.
|
1309
|
-
* @param type - Status of the job to clean. Values are completed, wait,
|
1310
|
-
* active, paused, delayed, and failed. Defaults to completed.
|
1311
|
-
*/
|
1312
|
-
clean(grace: number, limit: number, type?: 'completed' | 'wait' | 'active' | 'paused' | 'delayed' | 'failed'): Promise<string[]>;
|
1313
|
-
/**
|
1314
|
-
* Listens to queue events
|
1315
|
-
*/
|
1316
|
-
on(event: string, callback: (...args: any[]) => void): this;
|
1317
|
-
/**
|
1318
|
-
* An error occurred
|
1319
|
-
*/
|
1320
|
-
on(event: 'error', callback: ErrorEventCallback3): this;
|
1321
|
-
/**
|
1322
|
-
* A Job is waiting to be processed as soon as a worker is idling.
|
1323
|
-
*/
|
1324
|
-
on(event: 'waiting', callback: WaitingEventCallback3): this;
|
1325
|
-
/**
|
1326
|
-
* A job has started. You can use `jobPromise.cancel()` to abort it
|
1327
|
-
*/
|
1328
|
-
on(event: 'active', callback: ActiveEventCallback3<T>): this;
|
1329
|
-
/**
|
1330
|
-
* A job has been marked as stalled.
|
1331
|
-
* This is useful for debugging job workers that crash or pause the event loop.
|
1332
|
-
*/
|
1333
|
-
on(event: 'stalled', callback: StalledEventCallback3<T>): this;
|
1334
|
-
/**
|
1335
|
-
* A job's progress was updated
|
1336
|
-
*/
|
1337
|
-
on(event: 'progress', callback: ProgressEventCallback3<T>): this;
|
1338
|
-
/**
|
1339
|
-
* A job successfully completed with a `result`
|
1340
|
-
*/
|
1341
|
-
on(event: 'completed', callback: CompletedEventCallback3<T>): this;
|
1342
|
-
/**
|
1343
|
-
* A job failed with `err` as the reason
|
1344
|
-
*/
|
1345
|
-
on(event: 'failed', callback: FailedEventCallback3<T>): this;
|
1346
|
-
/**
|
1347
|
-
* The queue has been paused
|
1348
|
-
*/
|
1349
|
-
on(event: 'paused', callback: EventCallback3): this;
|
1350
|
-
/**
|
1351
|
-
* The queue has been resumed
|
1352
|
-
*/
|
1353
|
-
on(event: 'resumed', callback: EventCallback3): this;
|
1354
|
-
/**
|
1355
|
-
* A job successfully removed.
|
1356
|
-
*/
|
1357
|
-
on(event: 'removed', callback: RemovedEventCallback3<T>): this;
|
1358
|
-
/**
|
1359
|
-
* Old jobs have been cleaned from the queue.
|
1360
|
-
* `jobs` is an array of jobs that were removed, and `type` is the type of those jobs.
|
1361
|
-
*
|
1362
|
-
* @see Queue#clean() for details
|
1363
|
-
*/
|
1364
|
-
on(event: 'cleaned', callback: CleanedEventCallback3<T>): this;
|
1365
|
-
/**
|
1366
|
-
* Emitted every time the queue has processed all the waiting jobs
|
1367
|
-
* (even if there can be some delayed jobs not yet processed)
|
1368
|
-
*/
|
1369
|
-
on(event: 'drained', callback: EventCallback3): this;
|
1370
|
-
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
1371
|
-
off(event: string | symbol, listener?: (...args: any[]) => void): this;
|
1372
|
-
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
1373
|
-
removeAllListeners(event: string | symbol): this;
|
1374
|
-
/**
|
1375
|
-
* Set clientName to Redis.client
|
1376
|
-
*/
|
1377
|
-
setWorkerName(): Promise<any>;
|
1378
|
-
/**
|
1379
|
-
* Returns Redis clients array which belongs to current Queue
|
1380
|
-
*/
|
1381
|
-
getWorkers(): Promise<{
|
1382
|
-
[key: string]: string;
|
1383
|
-
}[]>;
|
1384
|
-
/**
|
1385
|
-
* Returns Queue name in base64 encoded format
|
1386
|
-
*/
|
1387
|
-
base64Name(): string;
|
1388
|
-
/**
|
1389
|
-
* Returns Queue name with keyPrefix (default: 'bull')
|
1390
|
-
*/
|
1391
|
-
clientName(): string;
|
1392
|
-
/**
|
1393
|
-
* Returns Redis clients array which belongs to current Queue from string with all redis clients
|
1394
|
-
*
|
1395
|
-
* @param list - String with all redis clients
|
1396
|
-
*/
|
1397
|
-
parseClientList(list: string): {
|
1398
|
-
[key: string]: string;
|
1399
|
-
}[];
|
1400
|
-
retryJob(job: Job): Promise<void>;
|
1401
|
-
private getQueueEvents;
|
1402
|
-
private ensureWorkerCreated;
|
1403
|
-
private attachListener;
|
1404
|
-
detachListener(event: string | symbol, listener?: (...args: any[]) => void): this;
|
1405
|
-
}
|
1406
|
-
|
1407
|
-
export declare const QUEUE_EVENT_SUFFIX = ":qe";
|
1408
|
-
|
1409
|
-
export declare const QUEUE_SCHEDULER_SUFFIX = ":qs";
|
1410
|
-
|
1411
|
-
export declare class QueueBase extends EventEmitter {
|
1412
|
-
readonly name: string;
|
1413
|
-
opts: QueueBaseOptions;
|
1414
|
-
toKey: (type: string) => string;
|
1415
|
-
keys: KeysMap;
|
1416
|
-
closing: Promise<void>;
|
1417
|
-
protected connection: RedisConnection;
|
1418
|
-
constructor(name: string, opts?: QueueBaseOptions, Connection?: typeof RedisConnection);
|
1419
|
-
get client(): Promise<RedisClient>;
|
1420
|
-
get redisVersion(): string;
|
1421
|
-
emit(event: string | symbol, ...args: any[]): boolean;
|
1422
|
-
waitUntilReady(): Promise<RedisClient>;
|
1423
|
-
protected base64Name(): string;
|
1424
|
-
protected clientName(suffix?: string): string;
|
1425
|
-
close(): Promise<void>;
|
1426
|
-
disconnect(): Promise<void>;
|
1427
|
-
}
|
1428
|
-
|
1429
|
-
/**
|
1430
|
-
* Base Queue options
|
1431
|
-
*/
|
1432
|
-
export declare interface QueueBaseOptions {
|
1433
|
-
/**
|
1434
|
-
* Options for connecting to a Redis instance.
|
1435
|
-
*/
|
1436
|
-
connection?: ConnectionOptions;
|
1437
|
-
/**
|
1438
|
-
* Specify if the connection is shared.
|
1439
|
-
*/
|
1440
|
-
sharedConnection?: boolean;
|
1441
|
-
/**
|
1442
|
-
* Denotes commands should retry indefinitely.
|
1443
|
-
*/
|
1444
|
-
blockingConnection?: boolean;
|
1445
|
-
/**
|
1446
|
-
* Prefix for all queue keys.
|
1447
|
-
*/
|
1448
|
-
prefix?: string;
|
1449
|
-
}
|
1450
|
-
|
1451
|
-
/**
|
1452
|
-
* The QueueEvents class is used for listening to the global events
|
1453
|
-
* emitted by a given queue.
|
1454
|
-
*
|
1455
|
-
* This class requires a dedicated redis connection.
|
1456
|
-
*
|
1457
|
-
*/
|
1458
|
-
export declare class QueueEvents extends QueueBase {
|
1459
|
-
private running;
|
1460
|
-
emit<U extends keyof QueueEventsListener>(event: U, ...args: Parameters<QueueEventsListener[U]>): boolean;
|
1461
|
-
off<U extends keyof QueueEventsListener>(eventName: U, listener: QueueEventsListener[U]): this;
|
1462
|
-
on<U extends keyof QueueEventsListener>(event: U, listener: QueueEventsListener[U]): this;
|
1463
|
-
once<U extends keyof QueueEventsListener>(event: U, listener: QueueEventsListener[U]): this;
|
1464
|
-
constructor(name: string, { connection, autorun, ...opts }?: QueueEventsOptions, Connection?: typeof RedisConnection);
|
1465
|
-
run(): Promise<void>;
|
1466
|
-
private consumeEvents;
|
1467
|
-
close(): Promise<void>;
|
1468
|
-
}
|
1469
|
-
|
1470
|
-
export declare interface QueueEventsListener {
|
1471
|
-
/**
|
1472
|
-
* Listen to 'active' event.
|
1473
|
-
*
|
1474
|
-
* This event is triggered when a job enters the 'active' state.
|
1475
|
-
*/
|
1476
|
-
active: (args: {
|
1477
|
-
jobId: string;
|
1478
|
-
prev?: string;
|
1479
|
-
}, id: string) => void;
|
1480
|
-
/**
|
1481
|
-
* Listen to 'added' event.
|
1482
|
-
*
|
1483
|
-
* This event is triggered when a job is created.
|
1484
|
-
*/
|
1485
|
-
added: (args: {
|
1486
|
-
jobId: string;
|
1487
|
-
name: string;
|
1488
|
-
data: string;
|
1489
|
-
opts: string;
|
1490
|
-
}, id: string) => void;
|
1491
|
-
/**
|
1492
|
-
* Listen to 'cleaned' event.
|
1493
|
-
*
|
1494
|
-
* This event is triggered when a cleaned method is triggered.
|
1495
|
-
*/
|
1496
|
-
cleaned: (args: {
|
1497
|
-
count: string;
|
1498
|
-
}, id: string) => void;
|
1499
|
-
/**
|
1500
|
-
* Listen to 'completed' event.
|
1501
|
-
*
|
1502
|
-
* This event is triggered when a job has successfully completed.
|
1503
|
-
*/
|
1504
|
-
completed: (args: {
|
1505
|
-
jobId: string;
|
1506
|
-
returnvalue: string;
|
1507
|
-
prev?: string;
|
1508
|
-
}, id: string) => void;
|
1509
|
-
/**
|
1510
|
-
* Listen to 'delayed' event.
|
1511
|
-
*
|
1512
|
-
* This event is triggered when a job is delayed.
|
1513
|
-
*/
|
1514
|
-
delayed: (args: {
|
1515
|
-
jobId: string;
|
1516
|
-
delay: number;
|
1517
|
-
}, id: string) => void;
|
1518
|
-
/**
|
1519
|
-
* Listen to 'drained' event.
|
1520
|
-
*
|
1521
|
-
* This event is triggered when the queue has drained the waiting list.
|
1522
|
-
* Note that there could still be delayed jobs waiting their timers to expire
|
1523
|
-
* and this event will still be triggered as long as the waiting list has emptied.
|
1524
|
-
*/
|
1525
|
-
drained: (id: string) => void;
|
1526
|
-
/**
|
1527
|
-
* Listen to 'error' event.
|
1528
|
-
*
|
1529
|
-
* This event is triggered when an exception is thrown.
|
1530
|
-
*/
|
1531
|
-
error: (args: Error) => void;
|
1532
|
-
/**
|
1533
|
-
* Listen to 'failed' event.
|
1534
|
-
*
|
1535
|
-
* This event is triggered when a job has thrown an exception.
|
1536
|
-
*/
|
1537
|
-
failed: (args: {
|
1538
|
-
jobId: string;
|
1539
|
-
failedReason: string;
|
1540
|
-
prev?: string;
|
1541
|
-
}, id: string) => void;
|
1542
|
-
/**
|
1543
|
-
* Listen to 'paused' event.
|
1544
|
-
*
|
1545
|
-
* This event is triggered when a queue is paused.
|
1546
|
-
*/
|
1547
|
-
paused: (args: {}, id: string) => void;
|
1548
|
-
/**
|
1549
|
-
* Listen to 'progress' event.
|
1550
|
-
*
|
1551
|
-
* This event is triggered when a job updates it progress, i.e. the
|
1552
|
-
* Job##updateProgress() method is called. This is useful to notify
|
1553
|
-
* progress or any other data from within a processor to the rest of the
|
1554
|
-
* world.
|
1555
|
-
*/
|
1556
|
-
progress: (args: {
|
1557
|
-
jobId: string;
|
1558
|
-
data: number | object;
|
1559
|
-
}, id: string) => void;
|
1560
|
-
/**
|
1561
|
-
* Listen to 'removed' event.
|
1562
|
-
*
|
1563
|
-
* This event is triggered when a job has been manually
|
1564
|
-
* removed from the queue.
|
1565
|
-
*/
|
1566
|
-
removed: (args: {
|
1567
|
-
jobId: string;
|
1568
|
-
}, id: string) => void;
|
1569
|
-
/**
|
1570
|
-
* Listen to 'resumed' event.
|
1571
|
-
*
|
1572
|
-
* This event is triggered when a queue is resumed.
|
1573
|
-
*/
|
1574
|
-
resumed: (args: {}, id: string) => void;
|
1575
|
-
/**
|
1576
|
-
* Listen to 'retries-exhausted' event.
|
1577
|
-
*
|
1578
|
-
* This event is triggered when a job has retried the maximum attempts.
|
1579
|
-
*/
|
1580
|
-
'retries-exhausted': (args: {
|
1581
|
-
jobId: string;
|
1582
|
-
attemptsMade: string;
|
1583
|
-
}, id: string) => void;
|
1584
|
-
/**
|
1585
|
-
* Listen to 'stalled' event.
|
1586
|
-
*
|
1587
|
-
* This event is triggered when a job has been moved from 'active' back
|
1588
|
-
* to 'waiting'/'failed' due to the processor not being able to renew
|
1589
|
-
* the lock on the said job.
|
1590
|
-
*/
|
1591
|
-
stalled: (args: {
|
1592
|
-
jobId: string;
|
1593
|
-
}, id: string) => void;
|
1594
|
-
/**
|
1595
|
-
* Listen to 'waiting' event.
|
1596
|
-
*
|
1597
|
-
* This event is triggered when a job enters the 'waiting' state.
|
1598
|
-
*/
|
1599
|
-
waiting: (args: {
|
1600
|
-
jobId: string;
|
1601
|
-
}, id: string) => void;
|
1602
|
-
/**
|
1603
|
-
* Listen to 'waiting-children' event.
|
1604
|
-
*
|
1605
|
-
* This event is triggered when a job enters the 'waiting-children' state.
|
1606
|
-
*/
|
1607
|
-
'waiting-children': (args: {
|
1608
|
-
jobId: string;
|
1609
|
-
}, id: string) => void;
|
1610
|
-
}
|
1611
|
-
|
1612
|
-
/**
|
1613
|
-
* Options for QueueEvents
|
1614
|
-
*/
|
1615
|
-
export declare interface QueueEventsOptions extends QueueBaseOptions {
|
1616
|
-
/**
|
1617
|
-
* Condition to start listening to events at instance creation.
|
1618
|
-
*/
|
1619
|
-
autorun?: boolean;
|
1620
|
-
/**
|
1621
|
-
* Last event Id. If provided it is possible to continue
|
1622
|
-
* consuming events from a known Id instead of from the last
|
1623
|
-
* produced event.
|
1624
|
-
*/
|
1625
|
-
lastEventId?: string;
|
1626
|
-
/**
|
1627
|
-
* Timeout for the blocking XREAD call to the events stream.
|
1628
|
-
*/
|
1629
|
-
blockingTimeout?: number;
|
1630
|
-
}
|
1631
|
-
|
1632
|
-
export declare class QueueGetters<DataType, ResultType, NameType extends string> extends QueueBase {
|
1633
|
-
getJob(jobId: string): Promise<Job<DataType, ResultType, NameType> | undefined>;
|
1634
|
-
private commandByType;
|
1635
|
-
private sanitizeJobTypes;
|
1636
|
-
/**
|
1637
|
-
Returns the number of jobs waiting to be processed.
|
1638
|
-
*/
|
1639
|
-
count(): Promise<number>;
|
1640
|
-
/**
|
1641
|
-
* Job counts by type
|
1642
|
-
*
|
1643
|
-
* Queue#getJobCountByTypes('completed') => completed count
|
1644
|
-
* Queue#getJobCountByTypes('completed,failed') => completed + failed count
|
1645
|
-
* Queue#getJobCountByTypes('completed', 'failed') => completed + failed count
|
1646
|
-
* Queue#getJobCountByTypes('completed', 'waiting', 'failed') => completed + waiting + failed count
|
1647
|
-
*/
|
1648
|
-
getJobCountByTypes(...types: JobType[]): Promise<number>;
|
1649
|
-
/**
|
1650
|
-
* Returns the job counts for each type specified or every list/set in the queue by default.
|
1651
|
-
*
|
1652
|
-
* @returns An object, key (type) and value (count)
|
1653
|
-
*/
|
1654
|
-
getJobCounts(...types: JobType[]): Promise<{
|
1655
|
-
[index: string]: number;
|
1656
|
-
}>;
|
1657
|
-
/**
|
1658
|
-
* Returns the number of jobs in completed status.
|
1659
|
-
*/
|
1660
|
-
getCompletedCount(): Promise<number>;
|
1661
|
-
/**
|
1662
|
-
* Returns the number of jobs in failed status.
|
1663
|
-
*/
|
1664
|
-
getFailedCount(): Promise<number>;
|
1665
|
-
/**
|
1666
|
-
* Returns the number of jobs in delayed status.
|
1667
|
-
*/
|
1668
|
-
getDelayedCount(): Promise<number>;
|
1669
|
-
/**
|
1670
|
-
* Returns the number of jobs in active status.
|
1671
|
-
*/
|
1672
|
-
getActiveCount(): Promise<number>;
|
1673
|
-
/**
|
1674
|
-
* Returns the number of jobs in waiting or paused statuses.
|
1675
|
-
*/
|
1676
|
-
getWaitingCount(): Promise<number>;
|
1677
|
-
/**
|
1678
|
-
* Returns the number of jobs in waiting-children status.
|
1679
|
-
*/
|
1680
|
-
getWaitingChildrenCount(): Promise<number>;
|
1681
|
-
getWaiting(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
1682
|
-
getWaitingChildren(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
1683
|
-
getActive(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
1684
|
-
getDelayed(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
1685
|
-
getCompleted(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
1686
|
-
getFailed(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
1687
|
-
getRanges(types: JobType[], start?: number, end?: number, asc?: boolean): Promise<string[]>;
|
1688
|
-
getJobs(types?: JobType[] | JobType, start?: number, end?: number, asc?: boolean): Promise<Job<DataType, ResultType, NameType>[]>;
|
1689
|
-
getJobLogs(jobId: string, start?: number, end?: number, asc?: boolean): Promise<{
|
1690
|
-
logs: [string];
|
1691
|
-
count: number;
|
1692
|
-
}>;
|
1693
|
-
private baseGetClients;
|
1694
|
-
/**
|
1695
|
-
* Get worker list related to the queue.
|
1696
|
-
*
|
1697
|
-
* @returns - Returns an array with workers info.
|
1698
|
-
*/
|
1699
|
-
getWorkers(): Promise<{
|
1700
|
-
[index: string]: string;
|
1701
|
-
}[]>;
|
1702
|
-
/**
|
1703
|
-
* Get queue schedulers list related to the queue.
|
1704
|
-
*
|
1705
|
-
* @returns - Returns an array with queue schedulers info.
|
1706
|
-
*/
|
1707
|
-
getQueueSchedulers(): Promise<{
|
1708
|
-
[index: string]: string;
|
1709
|
-
}[]>;
|
1710
|
-
/**
|
1711
|
-
* Get queue events list related to the queue.
|
1712
|
-
*
|
1713
|
-
* @returns - Returns an array with queue events info.
|
1714
|
-
*/
|
1715
|
-
getQueueEvents(): Promise<{
|
1716
|
-
[index: string]: string;
|
1717
|
-
}[]>;
|
1718
|
-
/**
|
1719
|
-
* Get queue metrics related to the queue.
|
1720
|
-
*
|
1721
|
-
* This method returns the gathered metrics for the queue.
|
1722
|
-
* The metrics are represented as an array of job counts
|
1723
|
-
* per unit of time (1 minute).
|
1724
|
-
*
|
1725
|
-
* @param start - Start point of the metrics, where 0
|
1726
|
-
* is the newest point to be returned.
|
1727
|
-
* @param end - End point of the metrics, where -1 is the
|
1728
|
-
* oldest point to be returned.
|
1729
|
-
*
|
1730
|
-
* @returns - Returns an object with queue metrics.
|
1731
|
-
*/
|
1732
|
-
getMetrics(type: 'completed' | 'failed', start?: number, end?: number): Promise<Metrics>;
|
1733
|
-
private parseClientList;
|
1734
|
-
}
|
1735
|
-
|
1736
|
-
export declare class QueueKeys {
|
1737
|
-
readonly prefix: string;
|
1738
|
-
constructor(prefix?: string);
|
1739
|
-
getKeys(name: string): KeysMap;
|
1740
|
-
toKey(name: string, type: string): string;
|
1741
|
-
getPrefixedQueueName(name: string): string;
|
1742
|
-
}
|
1743
|
-
|
1744
|
-
export declare interface QueueListener<DataType, ResultType, NameType extends string> {
|
1745
|
-
/**
|
1746
|
-
* Listen to 'cleaned' event.
|
1747
|
-
*
|
1748
|
-
* This event is triggered when the queue calls clean method.
|
1749
|
-
*/
|
1750
|
-
cleaned: (jobs: string[], type: string) => void;
|
1751
|
-
/**
|
1752
|
-
* Listen to 'error' event.
|
1753
|
-
*
|
1754
|
-
* This event is triggered when an error is thrown.
|
1755
|
-
*/
|
1756
|
-
error: (err: Error) => void;
|
1757
|
-
/**
|
1758
|
-
* Listen to 'paused' event.
|
1759
|
-
*
|
1760
|
-
* This event is triggered when the queue is paused.
|
1761
|
-
*/
|
1762
|
-
paused: () => void;
|
1763
|
-
/**
|
1764
|
-
* Listen to 'progress' event.
|
1765
|
-
*
|
1766
|
-
* This event is triggered when the job updates its progress.
|
1767
|
-
*/
|
1768
|
-
progress: (job: Job<DataType, ResultType, NameType>, progress: number | object) => void;
|
1769
|
-
/**
|
1770
|
-
* Listen to 'removed' event.
|
1771
|
-
*
|
1772
|
-
* This event is triggered when a job is removed.
|
1773
|
-
*/
|
1774
|
-
removed: (job: Job<DataType, ResultType, NameType>) => void;
|
1775
|
-
/**
|
1776
|
-
* Listen to 'resumed' event.
|
1777
|
-
*
|
1778
|
-
* This event is triggered when the queue is resumed.
|
1779
|
-
*/
|
1780
|
-
resumed: () => void;
|
1781
|
-
/**
|
1782
|
-
* Listen to 'waiting' event.
|
1783
|
-
*
|
1784
|
-
* This event is triggered when the queue creates a new job.
|
1785
|
-
*/
|
1786
|
-
waiting: (job: Job<DataType, ResultType, NameType>) => void;
|
1787
|
-
}
|
1788
|
-
|
1789
|
-
/**
|
1790
|
-
* Options for the Queue class.
|
1791
|
-
*/
|
1792
|
-
export declare interface QueueOptions extends QueueBaseOptions {
|
1793
|
-
defaultJobOptions?: JobsOptions;
|
1794
|
-
/**
|
1795
|
-
* Options for the rate limiter.
|
1796
|
-
*/
|
1797
|
-
limiter?: {
|
1798
|
-
/**
|
1799
|
-
* Group key to be used by the limiter when
|
1800
|
-
* limiting by group keys.
|
1801
|
-
*/
|
1802
|
-
groupKey: string;
|
1803
|
-
};
|
1804
|
-
/**
|
1805
|
-
* Options for the streams used internally in BullMQ.
|
1806
|
-
*/
|
1807
|
-
streams?: {
|
1808
|
-
/**
|
1809
|
-
* Options for the events stream.
|
1810
|
-
*/
|
1811
|
-
events: {
|
1812
|
-
/**
|
1813
|
-
* Max approximated length for streams. Default is 10 000 events.
|
1814
|
-
*/
|
1815
|
-
maxLen: number;
|
1816
|
-
};
|
1817
|
-
};
|
1818
|
-
}
|
1819
|
-
|
1820
|
-
/**
|
1821
|
-
* This class is just used for some automatic bookkeeping of the queue,
|
1822
|
-
* such as updating the delay set as well as moving stalled jobs back
|
1823
|
-
* to the waiting list.
|
1824
|
-
*
|
1825
|
-
* Jobs are checked for stallness once every "visibility window" seconds.
|
1826
|
-
* Jobs are then marked as candidates for being stalled, in the next check,
|
1827
|
-
* the candidates are marked as stalled and moved to wait.
|
1828
|
-
* Workers need to clean the candidate list with the jobs that they are working
|
1829
|
-
* on, failing to update the list results in the job ending being stalled.
|
1830
|
-
*
|
1831
|
-
* This class requires a dedicated redis connection, and at least one is needed
|
1832
|
-
* to be running at a given time, otherwise delays, stalled jobs, retries, repeatable
|
1833
|
-
* jobs, etc, will not work correctly or at all.
|
1834
|
-
*
|
1835
|
-
*/
|
1836
|
-
export declare class QueueScheduler extends QueueBase {
|
1837
|
-
private nextTimestamp;
|
1838
|
-
private isBlocked;
|
1839
|
-
private running;
|
1840
|
-
constructor(name: string, { connection, autorun, ...opts }?: QueueSchedulerOptions, Connection?: typeof RedisConnection);
|
1841
|
-
emit<U extends keyof QueueSchedulerListener>(event: U, ...args: Parameters<QueueSchedulerListener[U]>): boolean;
|
1842
|
-
off<U extends keyof QueueSchedulerListener>(eventName: U, listener: QueueSchedulerListener[U]): this;
|
1843
|
-
on<U extends keyof QueueSchedulerListener>(event: U, listener: QueueSchedulerListener[U]): this;
|
1844
|
-
once<U extends keyof QueueSchedulerListener>(event: U, listener: QueueSchedulerListener[U]): this;
|
1845
|
-
run(): Promise<void>;
|
1846
|
-
isRunning(): boolean;
|
1847
|
-
private readDelayedData;
|
1848
|
-
private updateDelaySet;
|
1849
|
-
private moveStalledJobsToWait;
|
1850
|
-
close(): Promise<void>;
|
1851
|
-
}
|
1852
|
-
|
1853
|
-
export declare interface QueueSchedulerListener {
|
1854
|
-
/**
|
1855
|
-
* Listen to 'stalled' event.
|
1856
|
-
*
|
1857
|
-
* This event is triggered when a job gets stalled.
|
1858
|
-
*/
|
1859
|
-
stalled: (jobId: string, prev: string) => void;
|
1860
|
-
/**
|
1861
|
-
* Listen to 'failed' event.
|
1862
|
-
*
|
1863
|
-
* This event is triggered when a job has thrown an exception.
|
1864
|
-
*/
|
1865
|
-
failed: (jobId: string, failedReason: Error, prev: string) => void;
|
1866
|
-
}
|
1867
|
-
|
1868
|
-
/**
|
1869
|
-
* Options for customizing the behaviour of the scheduler.
|
1870
|
-
*
|
1871
|
-
* @see {@link https://docs.bullmq.io/guide/jobs/stalled}
|
1872
|
-
* @see {@link https://docs.bullmq.io/guide/queuescheduler}
|
1873
|
-
*/
|
1874
|
-
export declare interface QueueSchedulerOptions extends QueueBaseOptions {
|
1875
|
-
/**
|
1876
|
-
* Condition to start scheduler at instance creation.
|
1877
|
-
*/
|
1878
|
-
autorun?: boolean;
|
1879
|
-
/**
|
1880
|
-
* Amount of times a job can be recovered from a stalled state
|
1881
|
-
* to the `wait` state. If this is exceeded, the job is moved
|
1882
|
-
* to `failed`.
|
1883
|
-
*/
|
1884
|
-
maxStalledCount?: number;
|
1885
|
-
/**
|
1886
|
-
* Number of milliseconds between stallness checks.
|
1887
|
-
*/
|
1888
|
-
stalledInterval?: number;
|
1889
|
-
}
|
1890
|
-
|
1891
|
-
export declare interface RateLimiterOptions {
|
1892
|
-
/**
|
1893
|
-
* Max number of jobs to process in the time period
|
1894
|
-
* specified in `duration`.
|
1895
|
-
*/
|
1896
|
-
max: number;
|
1897
|
-
/**
|
1898
|
-
* Time in milliseconds. During this time, a maximum
|
1899
|
-
* of `max` jobs will be processed.
|
1900
|
-
*/
|
1901
|
-
duration: number;
|
1902
|
-
/**
|
1903
|
-
* It is possible to define a rate limiter based on group keys,
|
1904
|
-
* for example you may want to have a rate limiter per customer
|
1905
|
-
* instead of a global rate limiter for all customers
|
1906
|
-
*
|
1907
|
-
* @see {@link https://docs.bullmq.io/guide/rate-limiting}
|
1908
|
-
*/
|
1909
|
-
groupKey?: string;
|
1910
|
-
/**
|
1911
|
-
* This option enables a heuristic so that when a queue is heavily
|
1912
|
-
* rete limited, it delays the workers so that they do not try
|
1913
|
-
* to pick jobs when there is no point in doing so.
|
1914
|
-
* Note: It is not recommended to use this option when using
|
1915
|
-
* groupKeys unless you have a big amount of workers since
|
1916
|
-
* you may be delaying workers that could pick jobs in groups that
|
1917
|
-
* have not been rate limited.
|
1918
|
-
*/
|
1919
|
-
workerDelay?: boolean;
|
1920
|
-
}
|
1921
|
-
|
1922
|
-
export declare function raw2jobData(raw: any[]): [JobJsonRaw | number, string?] | [];
|
1923
|
-
|
1924
|
-
export declare type RedisClient = Redis | Cluster;
|
1925
|
-
|
1926
|
-
export declare class RedisConnection extends EventEmitter {
|
1927
|
-
private readonly shared;
|
1928
|
-
private readonly blocking;
|
1929
|
-
static minimumVersion: string;
|
1930
|
-
protected _client: RedisClient;
|
1931
|
-
private readonly opts;
|
1932
|
-
private initializing;
|
1933
|
-
private closing;
|
1934
|
-
private version;
|
1935
|
-
private handleClientError;
|
1936
|
-
constructor(opts?: ConnectionOptions, shared?: boolean, blocking?: boolean);
|
1937
|
-
private checkBlockingOptions;
|
1938
|
-
private checkUpstashHost;
|
1939
|
-
/**
|
1940
|
-
* Waits for a redis client to be ready.
|
1941
|
-
* @param redis - client
|
1942
|
-
*/
|
1943
|
-
static waitUntilReady(client: RedisClient): Promise<void>;
|
1944
|
-
get client(): Promise<RedisClient>;
|
1945
|
-
protected loadCommands(): Promise<void>;
|
1946
|
-
private init;
|
1947
|
-
disconnect(): Promise<void>;
|
1948
|
-
reconnect(): Promise<void>;
|
1949
|
-
close(): Promise<void>;
|
1950
|
-
private getRedisVersion;
|
1951
|
-
get redisVersion(): string;
|
1952
|
-
}
|
1953
|
-
|
1954
|
-
export declare type RedisOptions = IORedis.RedisOptions & BaseOptions;
|
1955
|
-
|
1956
|
-
export declare function removeAllQueueData(client: RedisClient, queueName: string, prefix?: string): Promise<void | boolean>;
|
1957
|
-
|
1958
|
-
export declare type RemovedEventCallback3<T = any> = (job: Job) => void;
|
1959
|
-
|
1960
|
-
export declare class Repeat extends QueueBase {
|
1961
|
-
addNextRepeatableJob<T = any, R = any, N extends string = string>(name: N, data: T, opts: JobsOptions, skipCheckExists?: boolean): Promise<Job<T, R, N>>;
|
1962
|
-
private createNextJob;
|
1963
|
-
removeRepeatable(name: string, repeat: RepeatOptions, jobId?: string): Promise<void>;
|
1964
|
-
removeRepeatableByKey(repeatJobKey: string): Promise<void>;
|
1965
|
-
private keyToData;
|
1966
|
-
getRepeatableJobs(start?: number, end?: number, asc?: boolean): Promise<{
|
1967
|
-
key: string;
|
1968
|
-
name: string;
|
1969
|
-
id: string;
|
1970
|
-
endDate: number;
|
1971
|
-
tz: string;
|
1972
|
-
cron: string;
|
1973
|
-
next: number;
|
1974
|
-
}[]>;
|
1975
|
-
getRepeatableCount(): Promise<number>;
|
1976
|
-
}
|
1977
|
-
|
1978
|
-
/**
|
1979
|
-
* Settings for repeatable jobs
|
1980
|
-
*
|
1981
|
-
* @see {@link https://docs.bullmq.io/guide/jobs/repeatable}
|
1982
|
-
*/
|
1983
|
-
export declare interface RepeatOptions extends Omit<ParserOptions, 'iterator'> {
|
1984
|
-
/**
|
1985
|
-
* A cron pattern
|
1986
|
-
*/
|
1987
|
-
cron?: string;
|
1988
|
-
/**
|
1989
|
-
* Number of times the job should repeat at max.
|
1990
|
-
*/
|
1991
|
-
limit?: number;
|
1992
|
-
/**
|
1993
|
-
* Repeat after this amount of milliseconds
|
1994
|
-
* (`cron` setting cannot be used together with this setting.)
|
1995
|
-
*/
|
1996
|
-
every?: number;
|
1997
|
-
/**
|
1998
|
-
* Repeated job should start right now
|
1999
|
-
* ( work only with every settings)
|
2000
|
-
*/
|
2001
|
-
immediately?: boolean;
|
2002
|
-
/**
|
2003
|
-
* The start value for the repeat iteration count.
|
2004
|
-
*/
|
2005
|
-
count?: number;
|
2006
|
-
prevMillis?: number;
|
2007
|
-
offset?: number;
|
2008
|
-
jobId?: string;
|
2009
|
-
}
|
2010
|
-
|
2011
|
-
/**
|
2012
|
-
* @see {@link https://docs.bullmq.io/guide/workers/sandboxed-processors}
|
2013
|
-
*/
|
2014
|
-
export declare interface SandboxedJob<T = any, R = any> extends Omit<JobJson, 'data' | 'opts' | 'progress' | 'returnValue'> {
|
2015
|
-
data: T;
|
2016
|
-
opts: JobsOptions;
|
2017
|
-
progress: (() => object | number) | ((value: object | number) => Promise<void>);
|
2018
|
-
updateProgress: (value: object | number) => Promise<void>;
|
2019
|
-
log: (row: any) => void;
|
2020
|
-
returnValue: R;
|
2021
|
-
}
|
2022
|
-
|
2023
|
-
/**
|
2024
|
-
* @see {@link https://docs.bullmq.io/guide/workers/sandboxed-processors}
|
2025
|
-
*/
|
2026
|
-
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);
|
2027
|
-
|
2028
|
-
/**
|
2029
|
-
* Lua script loader with include support
|
2030
|
-
*/
|
2031
|
-
export declare class ScriptLoader {
|
2032
|
-
/**
|
2033
|
-
* Map an alias to a path
|
2034
|
-
*/
|
2035
|
-
private pathMapper;
|
2036
|
-
private clientScripts;
|
2037
|
-
/**
|
2038
|
-
* Cache commands by dir
|
2039
|
-
*/
|
2040
|
-
private commandCache;
|
2041
|
-
private rootPath;
|
2042
|
-
constructor();
|
2043
|
-
/**
|
2044
|
-
* Add a script path mapping. Allows includes of the form "<includes>/utils.lua" where `includes` is a user
|
2045
|
-
* defined path
|
2046
|
-
* @param name - the name of the mapping. Note: do not include angle brackets
|
2047
|
-
* @param mappedPath - if a relative path is passed, it's relative to the *caller* of this function.
|
2048
|
-
* Mapped paths are also accepted, e.g. "~/server/scripts/lua" or "<base>/includes"
|
2049
|
-
*/
|
2050
|
-
addPathMapping(name: string, mappedPath: string): void;
|
2051
|
-
/**
|
2052
|
-
* Resolve the script path considering path mappings
|
2053
|
-
* @param scriptName - the name of the script
|
2054
|
-
* @param stack - the include stack, for nicer errors
|
2055
|
-
*/
|
2056
|
-
resolvePath(scriptName: string, stack?: string[]): string;
|
2057
|
-
/**
|
2058
|
-
* Recursively collect all scripts included in a file
|
2059
|
-
* @param file - the parent file
|
2060
|
-
* @param cache - a cache for file metadata to increase efficiency. Since a file can be included
|
2061
|
-
* multiple times, we make sure to load it only once.
|
2062
|
-
* @param stack - internal stack to prevent circular references
|
2063
|
-
*/
|
2064
|
-
private resolveDependencies;
|
2065
|
-
/**
|
2066
|
-
* Parse a (top-level) lua script
|
2067
|
-
* @param filename - the full path to the script
|
2068
|
-
* @param content - the content of the script
|
2069
|
-
* @param cache - cache
|
2070
|
-
*/
|
2071
|
-
parseScript(filename: string, content: string, cache?: Map<string, ScriptMetadata>): Promise<ScriptMetadata>;
|
2072
|
-
/**
|
2073
|
-
* Construct the final version of a file by interpolating its includes in dependency order.
|
2074
|
-
* @param file - the file whose content we want to construct
|
2075
|
-
* @param processed - a cache to keep track of which includes have already been processed
|
2076
|
-
*/
|
2077
|
-
interpolate(file: ScriptMetadata, processed?: Set<string>): string;
|
2078
|
-
loadCommand(filename: string, cache?: Map<string, ScriptMetadata>): Promise<Command>;
|
2079
|
-
/**
|
2080
|
-
* Load redis lua scripts.
|
2081
|
-
* The name of the script must have the following format:
|
2082
|
-
*
|
2083
|
-
* cmdName-numKeys.lua
|
2084
|
-
*
|
2085
|
-
* cmdName must be in camel case format.
|
2086
|
-
*
|
2087
|
-
* For example:
|
2088
|
-
* moveToFinish-3.lua
|
2089
|
-
*
|
2090
|
-
*/
|
2091
|
-
loadScripts(dir?: string, cache?: Map<string, ScriptMetadata>): Promise<Command[]>;
|
2092
|
-
/**
|
2093
|
-
* Attach all lua scripts in a given directory to a client instance
|
2094
|
-
* @param client - redis client to attach script to
|
2095
|
-
* @param pathname - the path to the directory containing the scripts
|
2096
|
-
*/
|
2097
|
-
load(client: RedisClient, pathname: string): Promise<void>;
|
2098
|
-
/**
|
2099
|
-
* Clears the command cache
|
2100
|
-
*/
|
2101
|
-
clearCache(): void;
|
2102
|
-
}
|
2103
|
-
|
2104
|
-
export declare const scriptLoader: ScriptLoader;
|
2105
|
-
|
2106
|
-
export declare class ScriptLoaderError extends Error {
|
2107
|
-
readonly path: string;
|
2108
|
-
/**
|
2109
|
-
* The include stack
|
2110
|
-
*/
|
2111
|
-
readonly includes: string[];
|
2112
|
-
readonly line: number;
|
2113
|
-
readonly position: number;
|
2114
|
-
constructor(message: string, path: string, stack?: string[], line?: number, position?: number);
|
2115
|
-
}
|
2116
|
-
|
2117
|
-
/**
|
2118
|
-
* Script metadata
|
2119
|
-
*/
|
2120
|
-
export declare interface ScriptMetadata {
|
2121
|
-
/**
|
2122
|
-
* Name of the script
|
2123
|
-
*/
|
2124
|
-
name: string;
|
2125
|
-
numberOfKeys?: number;
|
2126
|
-
/**
|
2127
|
-
* The path to the script. For includes, this is the normalized path,
|
2128
|
-
* whereas it may not be normalized for the top-level parent
|
2129
|
-
*/
|
2130
|
-
path: string;
|
2131
|
-
/**
|
2132
|
-
* The raw script content
|
2133
|
-
*/
|
2134
|
-
content: string;
|
2135
|
-
/**
|
2136
|
-
* A hash of the normalized path for easy replacement in the parent
|
2137
|
-
*/
|
2138
|
-
token: string;
|
2139
|
-
/**
|
2140
|
-
* Metadata on the scripts that this script includes
|
2141
|
-
*/
|
2142
|
-
includes: ScriptMetadata[];
|
2143
|
-
}
|
2144
|
-
|
2145
|
-
export declare class Scripts {
|
2146
|
-
static isJobInList(queue: MinimalQueue, listKey: string, jobId: string): Promise<boolean>;
|
2147
|
-
static addJob(client: RedisClient, queue: MinimalQueue, job: JobJson, opts: JobsOptions, jobId: string, parentOpts?: ParentOpts): Promise<string>;
|
2148
|
-
static pause(queue: MinimalQueue, pause: boolean): Promise<void>;
|
2149
|
-
static removeRepeatableArgs(queue: MinimalQueue, repeatJobId: string, repeatJobKey: string): string[];
|
2150
|
-
static removeRepeatable(queue: MinimalQueue, repeatJobId: string, repeatJobKey: string): Promise<void>;
|
2151
|
-
static remove(queue: MinimalQueue, jobId: string): Promise<number>;
|
2152
|
-
static extendLock(queue: MinimalQueue, jobId: string, token: string, duration: number): Promise<number>;
|
2153
|
-
static updateData<T = any, R = any, N extends string = string>(queue: MinimalQueue, job: Job<T, R, N>, data: T): Promise<void>;
|
2154
|
-
static updateProgress<T = any, R = any, N extends string = string>(queue: MinimalQueue, job: Job<T, R, N>, progress: number | object): Promise<void>;
|
2155
|
-
static moveToFinishedArgs<T = any, R = any, N extends string = string>(queue: MinimalQueue, job: Job<T, R, N>, val: any, propVal: FinishedPropValAttribute, shouldRemove: boolean | number | KeepJobs, target: FinishedStatus, token: string, fetchNext?: boolean): string[];
|
2156
|
-
private static moveToFinished;
|
2157
|
-
static finishedErrors(code: number, jobId: string, command: string, state?: string): Error;
|
2158
|
-
static drainArgs(queue: MinimalQueue, delayed: boolean): (string | number)[];
|
2159
|
-
static drain(queue: MinimalQueue, delayed: boolean): Promise<void>;
|
2160
|
-
static moveToCompleted<T = any, R = any, N extends string = string>(queue: MinimalQueue, job: Job<T, R, N>, returnvalue: R, removeOnComplete: boolean | number | KeepJobs, token: string, fetchNext: boolean): Promise<JobData | []>;
|
2161
|
-
static moveToFailedArgs<T = any, R = any, N extends string = string>(queue: MinimalQueue, job: Job<T, R, N>, failedReason: string, removeOnFailed: boolean | number | KeepJobs, token: string, fetchNext?: boolean): string[];
|
2162
|
-
static isFinished(queue: MinimalQueue, jobId: string, returnValue?: boolean): Promise<number | [number, string]>;
|
2163
|
-
static getState(queue: MinimalQueue, jobId: string): Promise<JobState | 'unknown'>;
|
2164
|
-
static changeDelay(queue: MinimalQueue, jobId: string, delay: number): Promise<void>;
|
2165
|
-
static changeDelayArgs(queue: MinimalQueue, jobId: string, timestamp: number): string[];
|
2166
|
-
static moveToDelayedArgs(queue: MinimalQueue, jobId: string, timestamp: number): string[];
|
2167
|
-
static moveToWaitingChildrenArgs(queue: MinimalQueue, jobId: string, token: string, opts?: MoveToChildrenOpts): string[];
|
2168
|
-
static moveToDelayed(queue: MinimalQueue, jobId: string, timestamp: number): Promise<void>;
|
2169
|
-
/**
|
2170
|
-
* Move parent job to waiting-children state.
|
2171
|
-
*
|
2172
|
-
* @returns true if job is successfully moved, false if there are pending dependencies.
|
2173
|
-
* @throws JobNotExist
|
2174
|
-
* This exception is thrown if jobId is missing.
|
2175
|
-
* @throws JobLockNotExist
|
2176
|
-
* This exception is thrown if job lock is missing.
|
2177
|
-
* @throws JobNotInState
|
2178
|
-
* This exception is thrown if job is not in active state.
|
2179
|
-
*/
|
2180
|
-
static moveToWaitingChildren(queue: MinimalQueue, jobId: string, token: string, opts?: MoveToChildrenOpts): Promise<boolean>;
|
2181
|
-
/**
|
2182
|
-
* Remove jobs in a specific state.
|
2183
|
-
*
|
2184
|
-
* @returns Id jobs from the deleted records.
|
2185
|
-
*/
|
2186
|
-
static cleanJobsInSet(queue: MinimalQueue, set: string, timestamp: number, limit?: number): Promise<string[]>;
|
2187
|
-
static retryJobArgs<T = any, R = any, N extends string = string>(queue: MinimalQueue, job: Job<T, R, N>): string[];
|
2188
|
-
private static retryJobsArgs;
|
2189
|
-
static retryJobs(queue: MinimalQueue, state?: FinishedStatus, count?: number, timestamp?: number): Promise<number>;
|
2190
|
-
/**
|
2191
|
-
* Attempts to reprocess a job
|
2192
|
-
*
|
2193
|
-
* @param queue -
|
2194
|
-
* @param job -
|
2195
|
-
* @param state - The expected job state. If the job is not found
|
2196
|
-
* on the provided state, then it's not reprocessed. Supported states: 'failed', 'completed'
|
2197
|
-
*
|
2198
|
-
* @returns Returns a promise that evaluates to a return code:
|
2199
|
-
* 1 means the operation was a success
|
2200
|
-
* 0 means the job does not exist
|
2201
|
-
* -1 means the job is currently locked and can't be retried.
|
2202
|
-
* -2 means the job was not found in the expected set
|
2203
|
-
*/
|
2204
|
-
static reprocessJob<T = any, R = any, N extends string = string>(queue: MinimalQueue, job: Job<T, R, N>, state: 'failed' | 'completed'): Promise<void>;
|
2205
|
-
static moveToActive<T, R, N extends string>(worker: Worker<T, R, N>, token: string, jobId?: string): Promise<[] | [number | JobJsonRaw, string?]>;
|
2206
|
-
/**
|
2207
|
-
* It checks if the job in the top of the delay set should be moved back to the
|
2208
|
-
* top of the wait queue (so that it will be processed as soon as possible)
|
2209
|
-
*/
|
2210
|
-
static updateDelaySet(queue: MinimalQueue, delayedTimestamp: number): Promise<[number, string]>;
|
2211
|
-
static promote(queue: MinimalQueue, jobId: string): Promise<number>;
|
2212
|
-
/**
|
2213
|
-
* Looks for unlocked jobs in the active queue.
|
2214
|
-
*
|
2215
|
-
* The job was being worked on, but the worker process died and it failed to renew the lock.
|
2216
|
-
* We call these jobs 'stalled'. This is the most common case. We resolve these by moving them
|
2217
|
-
* back to wait to be re-processed. To prevent jobs from cycling endlessly between active and wait,
|
2218
|
-
* (e.g. if the job handler keeps crashing),
|
2219
|
-
* we limit the number stalled job recoveries to settings.maxStalledCount.
|
2220
|
-
*/
|
2221
|
-
static moveStalledJobsToWait(queue: QueueScheduler): Promise<any>;
|
2222
|
-
static obliterate(queue: MinimalQueue, opts: {
|
2223
|
-
force: boolean;
|
2224
|
-
count: number;
|
2225
|
-
}): Promise<number>;
|
2226
|
-
}
|
2227
|
-
|
2228
|
-
export declare type StalledEventCallback3<T = any> = (job: Job) => void;
|
2229
|
-
|
2230
|
-
export declare interface Strategies {
|
2231
|
-
[index: string]: BackoffFunction;
|
2232
|
-
}
|
2233
|
-
|
2234
|
-
export declare type StreamName = string;
|
2235
|
-
|
2236
|
-
export declare type StreamReadRaw = [StreamName, EntryRaw[]][];
|
2237
|
-
|
2238
|
-
/**
|
2239
|
-
* Keeps track on timers created with setTimeout to help clearTimeout
|
2240
|
-
* for all timers when no more delayed actions needed
|
2241
|
-
*/
|
2242
|
-
export declare class TimerManager {
|
2243
|
-
private readonly timers;
|
2244
|
-
/**
|
2245
|
-
* Creates a new timer and returns its ID.
|
2246
|
-
*
|
2247
|
-
* @param name - Readable name for the timer
|
2248
|
-
* @param delay - Delay in milliseconds
|
2249
|
-
* @param fn - Callback function that is executed after the timer expires
|
2250
|
-
*/
|
2251
|
-
setTimer(name: string, delay: number, fn: Function): string;
|
2252
|
-
clearTimer(id: string): void;
|
2253
|
-
clearAllTimers(): void;
|
2254
|
-
}
|
2255
|
-
|
2256
|
-
export declare function tryCatch(fn: (...args: any) => any, ctx: any, args: any[]): any;
|
2257
|
-
|
2258
|
-
/**
|
2259
|
-
* UnrecoverableError
|
2260
|
-
*
|
2261
|
-
* Error to move a job to failed even if the attemptsMade
|
2262
|
-
* are lower than the expected limit.
|
2263
|
-
*
|
2264
|
-
*/
|
2265
|
-
export declare class UnrecoverableError extends Error {
|
2266
|
-
constructor(message?: string);
|
2267
|
-
}
|
2268
|
-
|
2269
|
-
export declare type WaitingEventCallback3 = (jobId: string) => void;
|
2270
|
-
|
2271
|
-
/**
|
2272
|
-
*
|
2273
|
-
* This class represents a worker that is able to process jobs from the queue.
|
2274
|
-
* As soon as the class is instantiated it will start processing jobs.
|
2275
|
-
*
|
2276
|
-
*/
|
2277
|
-
export declare class Worker<DataType = any, ResultType = any, NameType extends string = string> extends QueueBase {
|
2278
|
-
opts: WorkerOptions;
|
2279
|
-
private drained;
|
2280
|
-
private waiting;
|
2281
|
-
private running;
|
2282
|
-
private blockTimeout;
|
2283
|
-
protected processFn: Processor<DataType, ResultType, NameType>;
|
2284
|
-
private resumeWorker;
|
2285
|
-
protected paused: Promise<void>;
|
2286
|
-
private _repeat;
|
2287
|
-
private childPool;
|
2288
|
-
protected timerManager: TimerManager;
|
2289
|
-
private blockingConnection;
|
2290
|
-
private processing;
|
2291
|
-
constructor(name: string, processor?: string | Processor<DataType, ResultType, NameType>, opts?: WorkerOptions, Connection?: typeof RedisConnection);
|
2292
|
-
emit<U extends keyof WorkerListener<DataType, ResultType, NameType>>(event: U, ...args: Parameters<WorkerListener<DataType, ResultType, NameType>[U]>): boolean;
|
2293
|
-
off<U extends keyof WorkerListener<DataType, ResultType, NameType>>(eventName: U, listener: WorkerListener<DataType, ResultType, NameType>[U]): this;
|
2294
|
-
on<U extends keyof WorkerListener<DataType, ResultType, NameType>>(event: U, listener: WorkerListener<DataType, ResultType, NameType>[U]): this;
|
2295
|
-
once<U extends keyof WorkerListener<DataType, ResultType, NameType>>(event: U, listener: WorkerListener<DataType, ResultType, NameType>[U]): this;
|
2296
|
-
protected callProcessJob(job: Job<DataType, ResultType, NameType>, token: string): Promise<ResultType>;
|
2297
|
-
protected createJob(data: JobJsonRaw, jobId: string): Job<DataType, ResultType, NameType>;
|
2298
|
-
/**
|
2299
|
-
*
|
2300
|
-
* Waits until the worker is ready to start processing jobs.
|
2301
|
-
* In general only useful when writing tests.
|
2302
|
-
*
|
2303
|
-
*/
|
2304
|
-
waitUntilReady(): Promise<RedisClient>;
|
2305
|
-
get repeat(): Promise<Repeat>;
|
2306
|
-
run(): Promise<any[]>;
|
2307
|
-
/**
|
2308
|
-
* Returns a promise that resolves to the next job in queue.
|
2309
|
-
* @param token - worker token to be assigned to retrieved job
|
2310
|
-
* @returns a Job or undefined if no job was available in the queue.
|
2311
|
-
*/
|
2312
|
-
getNextJob(token: string, { block }?: GetNextJobOptions): Promise<Job<DataType, ResultType, NameType>>;
|
2313
|
-
protected moveToActive(token: string, jobId?: string): Promise<Job<DataType, ResultType, NameType>>;
|
2314
|
-
private waitForJob;
|
2315
|
-
/**
|
2316
|
-
*
|
2317
|
-
* This function is exposed only for testing purposes.
|
2318
|
-
*/
|
2319
|
-
delay(): Promise<void>;
|
2320
|
-
protected nextJobFromJobData(jobData?: JobJsonRaw | number, jobId?: string): Promise<Job<DataType, ResultType, NameType>>;
|
2321
|
-
processJob(job: Job<DataType, ResultType, NameType>, token: string): Promise<void | Job<DataType, ResultType, NameType>>;
|
2322
|
-
/**
|
2323
|
-
*
|
2324
|
-
* Pauses the processing of this queue only for this worker.
|
2325
|
-
*/
|
2326
|
-
pause(doNotWaitActive?: boolean): Promise<void>;
|
2327
|
-
/**
|
2328
|
-
*
|
2329
|
-
* Resumes processing of this worker (if paused).
|
2330
|
-
*/
|
2331
|
-
resume(): void;
|
2332
|
-
/**
|
2333
|
-
*
|
2334
|
-
* Checks if worker is paused.
|
2335
|
-
*
|
2336
|
-
* @returns true if worker is paused, false otherwise.
|
2337
|
-
*/
|
2338
|
-
isPaused(): boolean;
|
2339
|
-
/**
|
2340
|
-
*
|
2341
|
-
* Checks if worker is currently running.
|
2342
|
-
*
|
2343
|
-
* @returns true if worker is running, false otherwise.
|
2344
|
-
*/
|
2345
|
-
isRunning(): boolean;
|
2346
|
-
/**
|
2347
|
-
*
|
2348
|
-
* Closes the worker and related redis connections.
|
2349
|
-
*
|
2350
|
-
* This method waits for current jobs to finalize before returning.
|
2351
|
-
*
|
2352
|
-
* @param force - Use force boolean parameter if you do not want to wait for
|
2353
|
-
* current jobs to be processed.
|
2354
|
-
*
|
2355
|
-
* @returns Promise that resolves when the worker has been closed.
|
2356
|
-
*/
|
2357
|
-
close(force?: boolean): Promise<void>;
|
2358
|
-
/**
|
2359
|
-
* Returns a promise that resolves when active jobs are cleared
|
2360
|
-
*
|
2361
|
-
* @returns
|
2362
|
-
*/
|
2363
|
-
private whenCurrentJobsFinished;
|
2364
|
-
private retryIfFailed;
|
2365
|
-
}
|
2366
|
-
|
2367
|
-
export declare const WORKER_SUFFIX = "";
|
2368
|
-
|
2369
|
-
export declare interface WorkerListener<DataType = any, ResultType = any, NameType extends string = string> {
|
2370
|
-
/**
|
2371
|
-
* Listen to 'active' event.
|
2372
|
-
*
|
2373
|
-
* This event is triggered when a job enters the 'active' state.
|
2374
|
-
*/
|
2375
|
-
active: (job: Job<DataType, ResultType, NameType>, prev: string) => void;
|
2376
|
-
/**
|
2377
|
-
* Listen to 'closing' event.
|
2378
|
-
*
|
2379
|
-
* This event is triggered when the worker is closed.
|
2380
|
-
*/
|
2381
|
-
closed: () => void;
|
2382
|
-
/**
|
2383
|
-
* Listen to 'closing' event.
|
2384
|
-
*
|
2385
|
-
* This event is triggered when the worker is closing.
|
2386
|
-
*/
|
2387
|
-
closing: (msg: string) => void;
|
2388
|
-
/**
|
2389
|
-
* Listen to 'completed' event.
|
2390
|
-
*
|
2391
|
-
* This event is triggered when a job has successfully completed.
|
2392
|
-
*/
|
2393
|
-
completed: (job: Job<DataType, ResultType, NameType>, result: ResultType, prev: string) => void;
|
2394
|
-
/**
|
2395
|
-
* Listen to 'drained' event.
|
2396
|
-
*
|
2397
|
-
* This event is triggered when the queue has drained the waiting list.
|
2398
|
-
* Note that there could still be delayed jobs waiting their timers to expire
|
2399
|
-
* and this event will still be triggered as long as the waiting list has emptied.
|
2400
|
-
*/
|
2401
|
-
drained: () => void;
|
2402
|
-
/**
|
2403
|
-
* Listen to 'error' event.
|
2404
|
-
*
|
2405
|
-
* This event is triggered when an error is throw.
|
2406
|
-
*/
|
2407
|
-
error: (failedReason: Error) => void;
|
2408
|
-
/**
|
2409
|
-
* Listen to 'failed' event.
|
2410
|
-
*
|
2411
|
-
* This event is triggered when a job has thrown an exception.
|
2412
|
-
*/
|
2413
|
-
failed: (job: Job<DataType, ResultType, NameType>, error: Error, prev: string) => void;
|
2414
|
-
/**
|
2415
|
-
* Listen to 'paused' event.
|
2416
|
-
*
|
2417
|
-
* This event is triggered when the queue is paused.
|
2418
|
-
*/
|
2419
|
-
paused: () => void;
|
2420
|
-
/**
|
2421
|
-
* Listen to 'progress' event.
|
2422
|
-
*
|
2423
|
-
* This event is triggered when a job updates it progress, i.e. the
|
2424
|
-
* Job##updateProgress() method is called. This is useful to notify
|
2425
|
-
* progress or any other data from within a processor to the rest of the
|
2426
|
-
* world.
|
2427
|
-
*/
|
2428
|
-
progress: (job: Job<DataType, ResultType, NameType>, progress: number | object) => void;
|
2429
|
-
/**
|
2430
|
-
* Listen to 'resumed' event.
|
2431
|
-
*
|
2432
|
-
* This event is triggered when the queue is resumed.
|
2433
|
-
*/
|
2434
|
-
resumed: () => void;
|
2435
|
-
}
|
2436
|
-
|
2437
|
-
export declare interface WorkerOptions extends QueueBaseOptions {
|
2438
|
-
/**
|
2439
|
-
* Condition to start processor at instance creation.
|
2440
|
-
*/
|
2441
|
-
autorun?: boolean;
|
2442
|
-
/**
|
2443
|
-
* Amount of jobs that a single worker is allowed to work on
|
2444
|
-
* in parallel.
|
2445
|
-
*
|
2446
|
-
* @see {@link https://docs.bullmq.io/guide/workers/concurrency}
|
2447
|
-
*/
|
2448
|
-
concurrency?: number;
|
2449
|
-
/**
|
2450
|
-
* Enable rate limiter
|
2451
|
-
* @see {@link https://docs.bullmq.io/guide/rate-limiting}
|
2452
|
-
*/
|
2453
|
-
limiter?: RateLimiterOptions;
|
2454
|
-
/**
|
2455
|
-
* Enable collect metrics.
|
2456
|
-
* @see {@link https://docs.bullmq.io/guide/metrics}
|
2457
|
-
*/
|
2458
|
-
metrics?: MetricsOptions;
|
2459
|
-
skipDelayCheck?: boolean;
|
2460
|
-
drainDelay?: number;
|
2461
|
-
lockDuration?: number;
|
2462
|
-
lockRenewTime?: number;
|
2463
|
-
runRetryDelay?: number;
|
2464
|
-
settings?: AdvancedOptions;
|
2465
|
-
}
|
2466
|
-
|
2467
|
-
export { }
|