bullmq 1.51.1 → 1.52.1

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/bullmq.d.ts DELETED
@@ -1,1562 +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 { Pipeline } from 'ioredis';
7
- import { Redis } from 'ioredis';
8
- import { RedisOptions as RedisOptions_2 } from 'ioredis';
9
-
10
- export declare interface AddChildrenOpts {
11
- multi: Pipeline;
12
- nodes: FlowJob[];
13
- parent: {
14
- parentOpts: {
15
- id: string;
16
- queue: string;
17
- };
18
- parentDependenciesKey: string;
19
- };
20
- queuesOpts?: FlowQueuesOpts;
21
- }
22
-
23
- export declare interface AddNodeOpts {
24
- multi: Pipeline;
25
- node: FlowJob;
26
- parent?: {
27
- parentOpts: {
28
- id: string;
29
- queue: string;
30
- };
31
- parentDependenciesKey: string;
32
- };
33
- /**
34
- * Queues options that will be applied in each node depending on queue name presence.
35
- */
36
- queuesOpts?: FlowQueuesOpts;
37
- }
38
-
39
- export declare interface AdvancedOptions {
40
- /**
41
- * A set of custom backoff strategies keyed by name.
42
- */
43
- backoffStrategies?: {};
44
- }
45
-
46
- export declare function array2obj(arr: string[]): {
47
- [index: string]: string;
48
- };
49
-
50
- export declare type BackoffFunction = (attemptsMade?: number, err?: Error, job?: Job) => number;
51
-
52
- /**
53
- * Settings for backing off failed jobs.
54
- *
55
- * @see {@link https://docs.bullmq.io/guide/retrying-failing-jobs}
56
- */
57
- export declare interface BackoffOptions {
58
- /**
59
- * Name of the backoff strategy.
60
- */
61
- type: string;
62
- /**
63
- * Delay in milliseconds.
64
- */
65
- delay?: number;
66
- }
67
-
68
- export declare class Backoffs {
69
- static builtinStrategies: BuiltInStrategies;
70
- static normalize(backoff: number | BackoffOptions): BackoffOptions;
71
- static calculate(backoff: BackoffOptions, attemptsMade: number, customStrategies: Strategies, err: Error, job: Job): number;
72
- }
73
-
74
- declare interface BuiltInStrategies {
75
- [index: string]: (delay: number) => BackoffFunction;
76
- }
77
-
78
- export declare type BulkJobOptions = Omit<JobsOptions, 'repeat'>;
79
-
80
- export declare class ChildPool {
81
- retained: {
82
- [key: number]: ChildProcessExt;
83
- };
84
- free: {
85
- [key: string]: ChildProcessExt[];
86
- };
87
- retain(processFile: string): Promise<ChildProcessExt>;
88
- release(child: ChildProcessExt): void;
89
- remove(child: ChildProcessExt): void;
90
- kill(child: ChildProcess, signal?: 'SIGTERM' | 'SIGKILL'): Promise<void>;
91
- clean(): Promise<void>;
92
- getFree(id: string): ChildProcessExt[];
93
- getAllFree(): ChildProcessExt[];
94
- }
95
-
96
- export declare interface ChildProcessExt extends ChildProcess {
97
- processFile?: string;
98
- }
99
-
100
- export declare const clientCommandMessageReg: RegExp;
101
-
102
- export declare enum ClientType {
103
- blocking = "blocking",
104
- normal = "normal"
105
- }
106
-
107
- export declare type ConnectionOptions = RedisOptions | Redis | Cluster;
108
-
109
- export declare function delay(ms: number): Promise<void>;
110
-
111
- export declare const DELAY_TIME_1 = 100;
112
-
113
- export declare const DELAY_TIME_5 = 5000;
114
-
115
- export declare interface DependenciesOpts {
116
- processed?: {
117
- cursor?: number;
118
- count?: number;
119
- };
120
- unprocessed?: {
121
- cursor?: number;
122
- count?: number;
123
- };
124
- }
125
-
126
- export declare enum ErrorCodes {
127
- JobNotExist = -1,
128
- JobLockNotExist = -2,
129
- JobNotInState = -3,
130
- JobPendingDependencies = -4,
131
- ParentJobNotExist = -5
132
- }
133
-
134
- export declare const errorObject: {
135
- [index: string]: any;
136
- };
137
-
138
- export declare interface FlowJob {
139
- name: string;
140
- queueName: string;
141
- data?: any;
142
- prefix?: string;
143
- opts?: Omit<JobsOptions, 'parent'>;
144
- children?: FlowJob[];
145
- }
146
-
147
- export declare interface FlowOpts {
148
- queuesOptions: FlowQueuesOpts;
149
- }
150
-
151
- /**
152
- * This class allows to add jobs with dependencies between them in such
153
- * a way that it is possible to build complex flows.
154
- * Note: A flow is a tree-like structure of jobs that depend on each other.
155
- * Whenever the children of a given parent are completed, the parent
156
- * will be processed, being able to access the children's result data.
157
- * All Jobs can be in different queues, either children or parents,
158
- */
159
- export declare class FlowProducer extends EventEmitter {
160
- opts: QueueBaseOptions;
161
- toKey: (name: string, type: string) => string;
162
- keys: KeysMap;
163
- closing: Promise<void>;
164
- queueKeys: QueueKeys;
165
- protected connection: RedisConnection;
166
- constructor(opts?: QueueBaseOptions);
167
- /**
168
- * Adds a flow.
169
- *
170
- * This call would be atomic, either it fails and no jobs will
171
- * be added to the queues, or it succeeds and all jobs will be added.
172
- *
173
- * @param flow - an object with a tree-like structure where children jobs
174
- * will be processed before their parents.
175
- * @param opts - options that will be applied to the flow object.
176
- */
177
- add(flow: FlowJob, opts?: FlowOpts): Promise<JobNode>;
178
- /**
179
- * Get a flow.
180
- *
181
- * @param opts - an object with options for getting a JobNode.
182
- */
183
- getFlow(opts: NodeOpts): Promise<JobNode>;
184
- get client(): Promise<RedisClient>;
185
- /**
186
- * Adds multiple flows.
187
- *
188
- * A flow is a tree-like structure of jobs that depend on each other.
189
- * Whenever the children of a given parent are completed, the parent
190
- * will be processed, being able to access the children's result data.
191
- *
192
- * All Jobs can be in different queues, either children or parents,
193
- * however this call would be atomic, either it fails and no jobs will
194
- * be added to the queues, or it succeeds and all jobs will be added.
195
- *
196
- * @param flows - an array of objects with a tree-like structure where children jobs
197
- * will be processed before their parents.
198
- */
199
- addBulk(flows: FlowJob[]): Promise<JobNode[]>;
200
- /**
201
- * Add a node (job) of a flow to the queue. This method will recursively
202
- * add all its children as well. Note that a given job can potentially be
203
- * a parent and a child job at the same time depending on where it is located
204
- * in the tree hierarchy.
205
- *
206
- * @param multi - ioredis pipeline
207
- * @param node - the node representing a job to be added to some queue
208
- * @param parent - parent data sent to children to create the "links" to their parent
209
- * @returns
210
- */
211
- private addNode;
212
- /**
213
- * Adds nodes (jobs) of multiple flows to the queue. This method will recursively
214
- * add all its children as well. Note that a given job can potentially be
215
- * a parent and a child job at the same time depending on where it is located
216
- * in the tree hierarchy.
217
- *
218
- * @param multi - ioredis pipeline
219
- * @param nodes - the nodes representing jobs to be added to some queue
220
- * @returns
221
- */
222
- private addNodes;
223
- private getNode;
224
- private addChildren;
225
- private getChildren;
226
- /**
227
- * Helper factory method that creates a queue-like object
228
- * required to create jobs in any queue.
229
- *
230
- * @param node -
231
- * @param queueKeys -
232
- * @returns
233
- */
234
- private queueFromNode;
235
- close(): Promise<void>;
236
- disconnect(): Promise<void>;
237
- }
238
-
239
- export declare type FlowQueuesOpts = Record<string, Omit<QueueOptions, 'connection' | 'prefix'>>;
240
-
241
- export declare interface GetNextJobOptions {
242
- block?: boolean;
243
- }
244
-
245
- export declare function getParentKey(opts: {
246
- id: string;
247
- queue: string;
248
- }): string;
249
-
250
- export declare function isEmpty(obj: object): boolean;
251
-
252
- export declare function isNotConnectionError(error: Error): boolean;
253
-
254
- export declare function isRedisInstance(obj: any): boolean;
255
-
256
- export declare class Job<DataType = any, ReturnType = any, NameType extends string = string> {
257
- private queue;
258
- /**
259
- * The name of the Job
260
- */
261
- name: NameType;
262
- /**
263
- * The payload for this job.
264
- */
265
- data: DataType;
266
- /**
267
- * The options object for this job.
268
- */
269
- opts: JobsOptions;
270
- id?: string;
271
- /**
272
- * The progress a job has performed so far.
273
- */
274
- progress: number | object;
275
- /**
276
- * The value returned by the processor when processing this job.
277
- */
278
- returnvalue: ReturnType;
279
- /**
280
- * Stacktrace for the error (for failed jobs).
281
- */
282
- stacktrace: string[];
283
- /**
284
- * Timestamp when the job was created (unless overridden with job options).
285
- */
286
- timestamp: number;
287
- /**
288
- * Number of attempts after the job has failed.
289
- */
290
- attemptsMade: number;
291
- /**
292
- * Reason for failing.
293
- */
294
- failedReason: string;
295
- /**
296
- * Timestamp for when the job finished (completed or failed).
297
- */
298
- finishedOn?: number;
299
- /**
300
- * Timestamp for when the job was processed.
301
- */
302
- processedOn?: number;
303
- /**
304
- * Fully qualified key (including the queue prefix) pointing to the parent of this job.
305
- */
306
- parentKey?: string;
307
- private toKey;
308
- private discarded;
309
- constructor(queue: MinimalQueue,
310
- /**
311
- * The name of the Job
312
- */
313
- name: NameType,
314
- /**
315
- * The payload for this job.
316
- */
317
- data: DataType,
318
- /**
319
- * The options object for this job.
320
- */
321
- opts?: JobsOptions, id?: string);
322
- /**
323
- * Creates a new job and adds it to the queue.
324
- *
325
- * @param queue - the queue where to add the job.
326
- * @param name - the name of the job.
327
- * @param data - the payload of the job.
328
- * @param opts - the options bag for this job.
329
- * @returns
330
- */
331
- static create<T = any, R = any, N extends string = string>(queue: MinimalQueue, name: N, data: T, opts?: JobsOptions): Promise<Job<T, R, N>>;
332
- /**
333
- * Creates a bulk of jobs and adds them atomically to the given queue.
334
- *
335
- * @param queue -the queue were to add the jobs.
336
- * @param jobs - an array of jobs to be added to the queue.
337
- * @returns
338
- */
339
- static createBulk<T = any, R = any, N extends string = string>(queue: MinimalQueue, jobs: {
340
- name: N;
341
- data: T;
342
- opts?: BulkJobOptions;
343
- }[]): Promise<Job<T, R, N>[]>;
344
- /**
345
- * Instantiates a Job from a JobJsonRaw object (coming from a deserialized JSON object)
346
- *
347
- * @param queue - the queue where the job belongs to.
348
- * @param json - the plain object containing the job.
349
- * @param jobId - an optional job id (overrides the id coming from the JSON object)
350
- * @returns
351
- */
352
- static fromJSON(queue: MinimalQueue, json: JobJsonRaw, jobId?: string): Job<any, any, string>;
353
- /**
354
- * Fetches a Job from the queue given the passed job id.
355
- *
356
- * @param queue - the queue where the job belongs to.
357
- * @param jobId - the job id.
358
- * @returns
359
- */
360
- static fromId(queue: MinimalQueue, jobId: string): Promise<Job | undefined>;
361
- toJSON(): Pick<this, Exclude<keyof this, "queue">>;
362
- /**
363
- * Prepares a job to be serialized for storage in Redis.
364
- * @returns
365
- */
366
- asJSON(): JobJson;
367
- /**
368
- * Updates a job's data
369
- *
370
- * @param data - the data that will replace the current jobs data.
371
- */
372
- update(data: DataType): Promise<void>;
373
- /**
374
- * Updates a job's progress
375
- *
376
- * @param progress - number or object to be saved as progress.
377
- */
378
- updateProgress(progress: number | object): Promise<void>;
379
- /**
380
- * Logs one row of log data.
381
- *
382
- * @param logRow - string with log data to be logged.
383
- */
384
- log(logRow: string): Promise<number>;
385
- /**
386
- * Completely remove the job from the queue.
387
- * Note, this call will throw an exception if the job
388
- * is being processed when the call is performed.
389
- */
390
- remove(): Promise<void>;
391
- /**
392
- * Extend the lock for this job.
393
- *
394
- * @param token - unique token for the lock
395
- * @param duration - lock duration in milliseconds
396
- */
397
- extendLock(token: string, duration: number): Promise<number>;
398
- /**
399
- * Moves a job to the completed queue.
400
- * Returned job to be used with Queue.prototype.nextJobFromJobData.
401
- *
402
- * @param returnValue - The jobs success message.
403
- * @param token - Worker token used to acquire completed job.
404
- * @param fetchNext - True when wanting to fetch the next job.
405
- * @returns Returns the jobData of the next job in the waiting queue.
406
- */
407
- moveToCompleted(returnValue: ReturnType, token: string, fetchNext?: boolean): Promise<[JobJsonRaw, string] | []>;
408
- /**
409
- * Moves a job to the failed queue.
410
- *
411
- * @param err - the jobs error message.
412
- * @param token - token to check job is locked by current worker
413
- * @param fetchNext - true when wanting to fetch the next job
414
- * @returns void
415
- */
416
- moveToFailed(err: Error, token: string, fetchNext?: boolean): Promise<void>;
417
- /**
418
- * @returns true if the job has completed.
419
- */
420
- isCompleted(): Promise<boolean>;
421
- /**
422
- * @returns true if the job has failed.
423
- */
424
- isFailed(): Promise<boolean>;
425
- /**
426
- * @returns true if the job is delayed.
427
- */
428
- isDelayed(): Promise<boolean>;
429
- /**
430
- * @returns true if the job is waiting for children.
431
- */
432
- isWaitingChildren(): Promise<boolean>;
433
- /**
434
- * @returns true of the job is active.
435
- */
436
- isActive(): Promise<boolean>;
437
- /**
438
- * @returns true if the job is waiting.
439
- */
440
- isWaiting(): Promise<boolean>;
441
- get queueName(): string;
442
- /**
443
- * Get current state.
444
- *
445
- * @returns Returns one of these values:
446
- * 'completed', 'failed', 'delayed', 'active', 'waiting', 'waiting-children', 'unknown'.
447
- */
448
- getState(): Promise<string>;
449
- /**
450
- * Change delay of a delayed job.
451
- *
452
- * @param delay - milliseconds to be added to current time.
453
- * @returns void
454
- */
455
- changeDelay(delay: number): Promise<void>;
456
- /**
457
- * Get this jobs children result values if any.
458
- *
459
- * @returns Object mapping children job keys with their values.
460
- */
461
- getChildrenValues<CT = any>(): Promise<{
462
- [jobKey: string]: CT;
463
- }>;
464
- /**
465
- * Get children job keys if this job is a parent and has children.
466
- *
467
- * @returns dependencies separated by processed and unprocessed.
468
- */
469
- getDependencies(opts?: DependenciesOpts): Promise<{
470
- nextProcessedCursor?: number;
471
- processed?: Record<string, any>;
472
- nextUnprocessedCursor?: number;
473
- unprocessed?: string[];
474
- }>;
475
- /**
476
- * Get children job counts if this job is a parent and has children.
477
- *
478
- * @returns dependencies count separated by processed and unprocessed.
479
- */
480
- getDependenciesCount(opts?: {
481
- processed?: boolean;
482
- unprocessed?: boolean;
483
- }): Promise<{
484
- processed?: number;
485
- unprocessed?: number;
486
- }>;
487
- /**
488
- * Returns a promise the resolves when the job has finished. (completed or failed).
489
- */
490
- waitUntilFinished(queueEvents: QueueEvents, ttl?: number): Promise<ReturnType>;
491
- /**
492
- * Moves the job to the delay set.
493
- *
494
- * @param timestamp - timestamp where the job should be moved back to "wait"
495
- * @returns
496
- */
497
- moveToDelayed(timestamp: number): Promise<void>;
498
- /**
499
- * Moves the job to the waiting-children set.
500
- *
501
- * @param token - Token to check job is locked by current worker
502
- * @param opts - The options bag for moving a job to waiting-children.
503
- * @returns true if the job was moved
504
- */
505
- moveToWaitingChildren(token: string, opts?: MoveToChildrenOpts): Promise<boolean | Error>;
506
- /**
507
- * Promotes a delayed job so that it starts to be processed as soon as possible.
508
- */
509
- promote(): Promise<void>;
510
- /**
511
- * Attempts to retry the job. Only a job that has failed can be retried.
512
- *
513
- * @returns If resolved and return code is 1, then the queue emits a waiting event
514
- * otherwise the operation was not a success and throw the corresponding error. If the promise
515
- * rejects, it indicates that the script failed to execute
516
- */
517
- retry(state?: 'completed' | 'failed'): Promise<void>;
518
- /**
519
- * Marks a job to not be retried if it fails (even if attempts has been configured)
520
- */
521
- discard(): void;
522
- private isInZSet;
523
- private isInList;
524
- /**
525
- * Adds the job to Redis.
526
- *
527
- * @param client -
528
- * @param parentOpts -
529
- * @returns
530
- */
531
- addJob(client: RedisClient, parentOpts?: ParentOpts): Promise<string>;
532
- private saveAttempt;
533
- }
534
-
535
- export declare function jobIdForGroup(jobOpts: JobsOptions, data: any, queueOpts: QueueOptions): string;
536
-
537
- export declare interface JobJson {
538
- id: string;
539
- name: string;
540
- data: string;
541
- opts: JobsOptions;
542
- progress: number | object;
543
- attemptsMade: number;
544
- finishedOn?: number;
545
- processedOn?: number;
546
- timestamp: number;
547
- failedReason: string;
548
- stacktrace: string;
549
- returnvalue: string;
550
- parentKey?: string;
551
- }
552
-
553
- export declare interface JobJsonRaw {
554
- id: string;
555
- name: string;
556
- data: string;
557
- opts: string;
558
- progress: string;
559
- attemptsMade: string;
560
- finishedOn?: string;
561
- processedOn?: string;
562
- timestamp: string;
563
- failedReason: string;
564
- stacktrace: string[];
565
- returnvalue: string;
566
- parentKey?: string;
567
- }
568
-
569
- export declare interface JobNode {
570
- job: Job;
571
- children?: JobNode[];
572
- }
573
-
574
- export declare interface JobsOptions {
575
- /**
576
- * Timestamp when the job was created. Defaults to `Date.now()`.
577
- */
578
- timestamp?: number;
579
- /**
580
- * Ranges from 1 (highest priority) to MAX_INT (lowest priority). Note that
581
- * using priorities has a slight impact on performance,
582
- * so do not use it if not required.
583
- */
584
- priority?: number;
585
- /**
586
- * An amount of milliseconds to wait until this job can be processed.
587
- * Note that for accurate delays, worker and producers
588
- * should have their clocks synchronized.
589
- */
590
- delay?: number;
591
- /**
592
- * The total number of attempts to try the job until it completes.
593
- */
594
- attempts?: number;
595
- /**
596
- * Repeat this job, for example based on a `cron` schedule.
597
- */
598
- repeat?: RepeatOptions;
599
- /**
600
- * Rate limiter key to use if rate limiter enabled.
601
- *
602
- * @see {@link https://docs.bullmq.io/guide/rate-limiting}
603
- */
604
- rateLimiterKey?: string;
605
- /**
606
- * Backoff setting for automatic retries if the job fails
607
- */
608
- backoff?: number | BackoffOptions;
609
- /**
610
- * If true, adds the job to the right of the queue instead of the left (default false)
611
- *
612
- * @see {@link https://docs.bullmq.io/guide/jobs/lifo}
613
- */
614
- lifo?: boolean;
615
- /**
616
- * The number of milliseconds after which the job should be
617
- * fail with a timeout error.
618
- */
619
- timeout?: number;
620
- /**
621
- * Override the job ID - by default, the job ID is a unique
622
- * integer, but you can use this setting to override it.
623
- * If you use this option, it is up to you to ensure the
624
- * jobId is unique. If you attempt to add a job with an id that
625
- * already exists, it will not be added.
626
- */
627
- jobId?: string;
628
- /**
629
- * If true, removes the job when it successfully completes
630
- * When given an number, it specifies the maximum amount of
631
- * jobs to keep.
632
- * Default behavior is to keep the job in the completed set.
633
- */
634
- removeOnComplete?: boolean | number;
635
- /**
636
- * If true, removes the job when it fails after all attempts.
637
- * When given an number, it specifies the maximum amount of
638
- * jobs to keep.
639
- */
640
- removeOnFail?: boolean | number;
641
- /**
642
- * Limits the amount of stack trace lines that will be recorded in the stacktrace.
643
- */
644
- stackTraceLimit?: number;
645
- /**
646
- *
647
- */
648
- parent?: {
649
- id: string;
650
- queue: string;
651
- };
652
- /**
653
- * Internal property used by repeatable jobs.
654
- */
655
- prevMillis?: number;
656
- /**
657
- * Limits the size in bytes of the job's data payload (as a JSON serialized string).
658
- */
659
- sizeLimit?: number;
660
- }
661
-
662
- declare type KeysMap = {
663
- [index in string]: string;
664
- };
665
-
666
- /**
667
- * Checks the size of string for ascii/non-ascii characters
668
- * @see https://stackoverflow.com/a/23318053/1347170
669
- * @param str -
670
- */
671
- export declare function lengthInUtf8Bytes(str: string): number;
672
-
673
- export declare const load: (client: RedisClient, pathname: string) => Promise<void>;
674
-
675
- export declare type MinimalQueue = Pick<QueueBase, 'name' | 'client' | 'toKey' | 'keys' | 'opts' | 'closing' | 'waitUntilReady' | 'removeListener' | 'emit' | 'on' | 'redisVersion'>;
676
-
677
- export declare interface MoveToChildrenOpts {
678
- timestamp?: number;
679
- child?: {
680
- id: string;
681
- queue: string;
682
- };
683
- }
684
-
685
- export declare interface NodeOpts {
686
- /**
687
- * Root job queue name.
688
- */
689
- queueName: string;
690
- /**
691
- * Prefix included in job key.
692
- */
693
- prefix?: string;
694
- /**
695
- * Root job id.
696
- */
697
- id: string;
698
- /**
699
- * Maximum depth or levels to visit in the tree.
700
- */
701
- depth?: number;
702
- /**
703
- * Maximum quantity of children per type (processed, unprocessed).
704
- */
705
- maxChildren?: number;
706
- }
707
-
708
- export declare type ParentOpts = {
709
- waitChildrenKey?: string;
710
- parentDependenciesKey?: string;
711
- parentKey?: string;
712
- };
713
-
714
- /**
715
- * An async function that receives `Job`s and handles them.
716
- */
717
- export declare type Processor<T = any, R = any, N extends string = string> = (job: Job<T, R, N>, token?: string) => Promise<R>;
718
-
719
- export declare interface Queue {
720
- on(event: 'cleaned', listener: (jobs: string[], type: string) => void): this;
721
- on(event: string, listener: Function): this;
722
- }
723
-
724
- /**
725
- * Queue
726
- *
727
- * This class provides methods to add jobs to a queue and some othe high-level
728
- * administration such as pausing or deleting queues.
729
- *
730
- */
731
- export declare class Queue<DataType = any, ResultType = any, NameType extends string = string> extends QueueGetters {
732
- token: string;
733
- jobsOpts: JobsOptions;
734
- limiter: {
735
- groupKey: string;
736
- };
737
- private _repeat;
738
- constructor(name: string, opts?: QueueOptions, Connection?: typeof RedisConnection);
739
- /**
740
- * Returns this instance current default job options.
741
- */
742
- get defaultJobOptions(): JobsOptions;
743
- get repeat(): Promise<Repeat>;
744
- /**
745
- * Adds a new job to the queue.
746
- *
747
- * @param name - Name of the job to be added to the queue,.
748
- * @param data - Arbitrary data to append to the job.
749
- * @param opts - Job options that affects how the job is going to be processed.
750
- */
751
- add(name: NameType, data: DataType, opts?: JobsOptions): Promise<Job<DataType, ResultType, NameType>>;
752
- /**
753
- * Adds an array of jobs to the queue.
754
- *
755
- * @param jobs - The array of jobs to add to the queue. Each job is defined by 3
756
- * properties, 'name', 'data' and 'opts'. They follow the same signature as 'Queue.add'.
757
- */
758
- addBulk(jobs: {
759
- name: NameType;
760
- data: DataType;
761
- opts?: BulkJobOptions;
762
- }[]): Promise<Job<DataType, any, NameType>[]>;
763
- /**
764
- * Pauses the processing of this queue globally.
765
- *
766
- * We use an atomic RENAME operation on the wait queue. Since
767
- * we have blocking calls with BRPOPLPUSH on the wait queue, as long as the queue
768
- * is renamed to 'paused', no new jobs will be processed (the current ones
769
- * will run until finalized).
770
- *
771
- * Adding jobs requires a LUA script to check first if the paused list exist
772
- * and in that case it will add it there instead of the wait list.
773
- */
774
- pause(): Promise<void>;
775
- /**
776
- * Resumes the processing of this queue globally.
777
- *
778
- * The method reverses the pause operation by resuming the processing of the
779
- * queue.
780
- */
781
- resume(): Promise<void>;
782
- /**
783
- * Returns true if the queue is currently paused.
784
- */
785
- isPaused(): Promise<boolean>;
786
- /**
787
- * Get all repeatable meta jobs.
788
- *
789
- * @param start - Offset of first job to return.
790
- * @param end - Offset of last job to return.
791
- * @param asc - Determine the order in which jobs are returned based on their
792
- * next execution time.
793
- */
794
- getRepeatableJobs(start?: number, end?: number, asc?: boolean): Promise<{
795
- key: string;
796
- name: string;
797
- id: string;
798
- endDate: number; /**
799
- * Get all repeatable meta jobs.
800
- *
801
- * @param start - Offset of first job to return.
802
- * @param end - Offset of last job to return.
803
- * @param asc - Determine the order in which jobs are returned based on their
804
- * next execution time.
805
- */
806
- tz: string;
807
- cron: string;
808
- next: number;
809
- }[]>;
810
- removeRepeatable(name: NameType, repeatOpts: RepeatOptions, jobId?: string): Promise<any>;
811
- removeRepeatableByKey(key: string): Promise<any>;
812
- /**
813
- * Removes the given job from the queue as well as all its
814
- * dependencies.
815
- *
816
- * @param jobId - The id of the job to remove
817
- * @returns 1 if it managed to remove the job or 0 if the job or
818
- * any of its dependencies was locked.
819
- */
820
- remove(jobId: string): Promise<number>;
821
- /**
822
- * Drains the queue, i.e., removes all jobs that are waiting
823
- * or delayed, but not active, completed or failed.
824
- *
825
- * @param delayed - Pass true if it should also clean the
826
- * delayed jobs.
827
- */
828
- drain(delayed?: boolean): Promise<void>;
829
- /**
830
- * Cleans jobs from a queue. Similar to drain but keeps jobs within a certain
831
- * grace period.
832
- *
833
- * @param grace - The grace period
834
- * @param The - Max number of jobs to clean
835
- * @param {string} [type=completed] - The type of job to clean
836
- * Possible values are completed, wait, active, paused, delayed, failed. Defaults to completed.
837
- */
838
- clean(grace: number, limit: number, type?: 'completed' | 'wait' | 'active' | 'paused' | 'delayed' | 'failed'): Promise<string[]>;
839
- /**
840
- * Completely destroys the queue and all of its contents irreversibly.
841
- * This method will the *pause* the queue and requires that there are no
842
- * active jobs. It is possible to bypass this requirement, i.e. not
843
- * having active jobs using the "force" option.
844
- *
845
- * Note: This operation requires to iterate on all the jobs stored in the queue
846
- * and can be slow for very large queues.
847
- *
848
- * @param { { force: boolean, count: number }} opts. Use force = true to force obliteration even
849
- * with active jobs in the queue. Use count with the maximum number of deleted keys per iteration,
850
- * 1000 is the default.
851
- */
852
- obliterate(opts?: {
853
- force?: boolean;
854
- count?: number;
855
- }): Promise<void>;
856
- /**
857
- * Trim the event stream to an approximately maxLength.
858
- *
859
- * @param maxLength -
860
- */
861
- trimEvents(maxLength: number): Promise<number>;
862
- }
863
-
864
- export declare class QueueBase extends EventEmitter {
865
- readonly name: string;
866
- opts: QueueBaseOptions;
867
- toKey: (type: string) => string;
868
- keys: KeysMap;
869
- closing: Promise<void>;
870
- protected connection: RedisConnection;
871
- constructor(name: string, opts?: QueueBaseOptions, Connection?: typeof RedisConnection);
872
- get client(): Promise<RedisClient>;
873
- get redisVersion(): string;
874
- emit(event: string | symbol, ...args: any[]): boolean;
875
- waitUntilReady(): Promise<RedisClient>;
876
- protected base64Name(): string;
877
- protected clientName(): string;
878
- close(): Promise<void>;
879
- disconnect(): Promise<void>;
880
- }
881
-
882
- /**
883
- * Base Queue options
884
- */
885
- export declare interface QueueBaseOptions {
886
- /**
887
- * Options for connecting to a Redis instance.
888
- */
889
- connection?: ConnectionOptions;
890
- /**
891
- * Specify if the connection is shared.
892
- */
893
- sharedConnection?: boolean;
894
- /**
895
- * Prefix for all queue keys.
896
- */
897
- prefix?: string;
898
- }
899
-
900
- export declare interface QueueEvents {
901
- /**
902
- * Listen to 'active' event.
903
- *
904
- * This event is triggered when a job enters the 'active' state.
905
- *
906
- * @param {'active'} event
907
- * @callback listener@callback listener
908
- */
909
- on(event: 'active', listener: (args: {
910
- jobId: string;
911
- prev?: string;
912
- }, id: string) => void): this;
913
- /**
914
- * Listen to 'added' event.
915
- *
916
- * This event is triggered when a job is created.
917
- *
918
- * @param {'added'} event
919
- * @callback listener@callback listener
920
- */
921
- on(event: 'added', listener: (args: {
922
- jobId: string;
923
- name: string;
924
- data: string;
925
- opts: string;
926
- }, id: string) => void): this;
927
- /**
928
- * Listen to 'completed' event.
929
- *
930
- * This event is triggered when a job has successfully completed.
931
- *
932
- * @param {'completed'} event
933
- * @callback listener@callback listener
934
- */
935
- on(event: 'completed', listener: (args: {
936
- jobId: string;
937
- returnvalue: string;
938
- prev?: string;
939
- }, id: string) => void): this;
940
- /**
941
- * Listen to 'delayed' event.
942
- *
943
- * This event is triggered when a job is delayed.
944
- *
945
- * @param {'delayed'} event
946
- * @callback listener@callback listener
947
- */
948
- on(event: 'delayed', listener: (args: {
949
- jobId: string;
950
- delay: number;
951
- }, id: string) => void): this;
952
- /**
953
- * Listen to 'drained' event.
954
- *
955
- * This event is triggered when the queue has drained the waiting list.
956
- * Note that there could still be delayed jobs waiting their timers to expire
957
- * and this event will still be triggered as long as the waiting list has emptied.
958
- *
959
- * @param {'drained'} event
960
- * @callback listener@callback listener
961
- */
962
- on(event: 'drained', listener: (id: string) => void): this;
963
- /**
964
- * Listen to 'progress' event.
965
- *
966
- * This event is triggered when a job updates it progress, i.e. the
967
- * Job##updateProgress() method is called. This is useful to notify
968
- * progress or any other data from within a processor to the rest of the
969
- * world.
970
- *
971
- * @param {'progress'} event
972
- * @callback listener@callback listener
973
- */
974
- on(event: 'progress', listener: (args: {
975
- jobId: string;
976
- data: number | object;
977
- }, id: string) => void): this;
978
- /**
979
- * Listen to 'waiting' event.
980
- *
981
- * This event is triggered when a job enters the 'waiting' state.
982
- *
983
- * @param {'waiting'} event
984
- * @callback listener@callback listener
985
- */
986
- on(event: 'waiting', listener: (args: {
987
- jobId: string;
988
- }, id: string) => void): this;
989
- /**
990
- * Listen to 'stalled' event.
991
- *
992
- * This event is triggered when a job has been moved from 'active' back
993
- * to 'waiting'/'failed' due to the processor not being able to renew
994
- * the lock on the said job.
995
- *
996
- * @param {'stalled'} event
997
- * @callback listener@callback listener
998
- */
999
- on(event: 'stalled', listener: (args: {
1000
- jobId: string;
1001
- }, id: string) => void): this;
1002
- /**
1003
- * Listen to 'failed' event.
1004
- *
1005
- * This event is triggered when a job has thrown an exception.
1006
- *
1007
- * @param {'failed'} event
1008
- * @callback listener@callback listener
1009
- */
1010
- on(event: 'failed', listener: (args: {
1011
- jobId: string;
1012
- failedReason: string;
1013
- prev?: string;
1014
- }, id: string) => void): this;
1015
- /**
1016
- * Listen to 'removed' event.
1017
- *
1018
- * This event is triggered when a job has been manually
1019
- * removed from the queue.
1020
- *
1021
- * @param {'removed'} event
1022
- * @callback listener@callback listener
1023
- */
1024
- on(event: 'removed', listener: (args: {
1025
- jobId: string;
1026
- }, id: string) => void): this;
1027
- /**
1028
- * Listen to 'waiting-children' event.
1029
- *
1030
- * This event is triggered when a job enters the 'waiting-children' state.
1031
- *
1032
- * @param {'waiting-children'} event
1033
- * @callback listener@callback listener
1034
- */
1035
- on(event: 'waiting-children', listener: (args: {
1036
- jobId: string;
1037
- }, id: string) => void): this;
1038
- on(event: string, listener: Function): this;
1039
- }
1040
-
1041
- /**
1042
- * The QueueEvents class is used for listening to the global events
1043
- * emitted by a given queue.
1044
- *
1045
- * This class requires a dedicated redis connection.
1046
- *
1047
- */
1048
- export declare class QueueEvents extends QueueBase {
1049
- private running;
1050
- constructor(name: string, { connection, autorun, ...opts }?: QueueEventsOptions, Connection?: typeof RedisConnection);
1051
- run(): Promise<void>;
1052
- private consumeEvents;
1053
- close(): Promise<void>;
1054
- }
1055
-
1056
- /**
1057
- * Options for QueueEvents
1058
- */
1059
- export declare interface QueueEventsOptions extends QueueBaseOptions {
1060
- /**
1061
- * Condition to start listening to events at instance creation.
1062
- */
1063
- autorun?: boolean;
1064
- /**
1065
- * Last event Id. If provided it is possible to continue
1066
- * consuming events from a known Id instead of from the last
1067
- * produced event.
1068
- */
1069
- lastEventId?: string;
1070
- /**
1071
- * Timeout for the blocking XREAD call to the events stream.
1072
- */
1073
- blockingTimeout?: number;
1074
- }
1075
-
1076
- export declare class QueueGetters extends QueueBase {
1077
- getJob(jobId: string): Promise<Job | undefined>;
1078
- private commandByType;
1079
- /**
1080
- Returns the number of jobs waiting to be processed.
1081
- */
1082
- count(): Promise<number>;
1083
- /**
1084
- * Job counts by type
1085
- *
1086
- * Queue#getJobCountByTypes('completed') => completed count
1087
- * Queue#getJobCountByTypes('completed,failed') => completed + failed count
1088
- * Queue#getJobCountByTypes('completed', 'failed') => completed + failed count
1089
- * Queue#getJobCountByTypes('completed', 'waiting', 'failed') => completed + waiting + failed count
1090
- */
1091
- getJobCountByTypes(...types: string[]): Promise<number>;
1092
- /**
1093
- * Returns the job counts for each type specified or every list/set in the queue by default.
1094
- *
1095
- * @returns An object, key (type) and value (count)
1096
- */
1097
- getJobCounts(...types: string[]): Promise<{
1098
- [index: string]: number;
1099
- }>;
1100
- getCompletedCount(): Promise<number>;
1101
- getFailedCount(): Promise<number>;
1102
- getDelayedCount(): Promise<number>;
1103
- getActiveCount(): Promise<number>;
1104
- getWaitingCount(): Promise<number>;
1105
- getWaitingChildrenCount(): Promise<number>;
1106
- getWaiting(start?: number, end?: number): Promise<Job<any, any, string>[]>;
1107
- getWaitingChildren(start?: number, end?: number): Promise<Job<any, any, string>[]>;
1108
- getActive(start?: number, end?: number): Promise<Job<any, any, string>[]>;
1109
- getDelayed(start?: number, end?: number): Promise<Job<any, any, string>[]>;
1110
- getCompleted(start?: number, end?: number): Promise<Job<any, any, string>[]>;
1111
- getFailed(start?: number, end?: number): Promise<Job<any, any, string>[]>;
1112
- getRanges(types: string[], start?: number, end?: number, asc?: boolean): Promise<any[]>;
1113
- getJobs(types: string[] | string, start?: number, end?: number, asc?: boolean): Promise<Job<any, any, string>[]>;
1114
- getJobLogs(jobId: string, start?: number, end?: number, asc?: boolean): Promise<{
1115
- logs: [string];
1116
- count: number;
1117
- }>;
1118
- /**
1119
- * Get worker list related to the queue.
1120
- *
1121
- * @returns - Returns an array with workers info.
1122
- */
1123
- getWorkers(): Promise<{
1124
- [index: string]: string;
1125
- }[]>;
1126
- private parseClientList;
1127
- }
1128
-
1129
- declare class QueueKeys {
1130
- readonly prefix: string;
1131
- constructor(prefix?: string);
1132
- getKeys(name: string): KeysMap;
1133
- toKey(name: string, type: string): string;
1134
- getPrefixedQueueName(name: string): string;
1135
- }
1136
-
1137
- /**
1138
- * Options for the Queue class.
1139
- */
1140
- export declare interface QueueOptions extends QueueBaseOptions {
1141
- defaultJobOptions?: JobsOptions;
1142
- /**
1143
- * Options for the rate limiter.
1144
- */
1145
- limiter?: {
1146
- /**
1147
- * Group key to be used by the limiter when
1148
- * limiting by group keys.
1149
- */
1150
- groupKey: string;
1151
- };
1152
- /**
1153
- * Options for the streams used internally in BullMQ.
1154
- */
1155
- streams?: {
1156
- /**
1157
- * Options for the events stream.
1158
- */
1159
- events: {
1160
- /**
1161
- * Max approximated length for streams. Default is 10 000 events.
1162
- */
1163
- maxLen: number;
1164
- };
1165
- };
1166
- }
1167
-
1168
- export declare interface QueueScheduler {
1169
- on(event: 'stalled', listener: (jobId: string, prev: string) => void): this;
1170
- on(event: 'failed', listener: (jobId: string, failedReason: Error, prev: string) => void): this;
1171
- on(event: string, listener: Function): this;
1172
- }
1173
-
1174
- /**
1175
- * This class is just used for some automatic bookkeeping of the queue,
1176
- * such as updating the delay set as well as moving stalled jobs back
1177
- * to the waiting list.
1178
- *
1179
- * Jobs are checked for stallness once every "visibility window" seconds.
1180
- * Jobs are then marked as candidates for being stalled, in the next check,
1181
- * the candidates are marked as stalled and moved to wait.
1182
- * Workers need to clean the candidate list with the jobs that they are working
1183
- * on, failing to update the list results in the job ending being stalled.
1184
- *
1185
- * This class requires a dedicated redis connection, and at least one is needed
1186
- * to be running at a given time, otherwise delays, stalled jobs, retries, repeatable
1187
- * jobs, etc, will not work correctly or at all.
1188
- *
1189
- */
1190
- export declare class QueueScheduler extends QueueBase {
1191
- private nextTimestamp;
1192
- private isBlocked;
1193
- private running;
1194
- constructor(name: string, { connection, autorun, ...opts }?: QueueSchedulerOptions);
1195
- run(): Promise<void>;
1196
- isRunning(): boolean;
1197
- private readDelayedData;
1198
- private updateDelaySet;
1199
- private moveStalledJobsToWait;
1200
- close(): Promise<void>;
1201
- }
1202
-
1203
- /**
1204
- * Options for customizing the behaviour of the scheduler.
1205
- *
1206
- * @see {@link https://docs.bullmq.io/guide/jobs/stalled}
1207
- * @see {@link https://docs.bullmq.io/guide/queuescheduler}
1208
- */
1209
- export declare interface QueueSchedulerOptions extends QueueBaseOptions {
1210
- /**
1211
- * Condition to start scheduler at instance creation.
1212
- */
1213
- autorun?: boolean;
1214
- /**
1215
- * Amount of times a job can be recovered from a stalled state
1216
- * to the `wait` state. If this is exceeded, the job is moved
1217
- * to `failed`.
1218
- */
1219
- maxStalledCount?: number;
1220
- /**
1221
- * Number of milliseconds between stallness checks.
1222
- */
1223
- stalledInterval?: number;
1224
- }
1225
-
1226
- export declare interface RateLimiterOptions {
1227
- /**
1228
- * Max number of jobs to process in the time period
1229
- * specified in `duration`.
1230
- */
1231
- max: number;
1232
- /**
1233
- * Time in milliseconds. During this time, a maximum
1234
- * of `max` jobs will be processed.
1235
- */
1236
- duration: number;
1237
- /**
1238
- * It is possible to define a rate limiter based on group keys,
1239
- * for example you may want to have a rate limiter per customer
1240
- * instead of a global rate limiter for all customers
1241
- *
1242
- * @see {@link https://docs.bullmq.io/guide/rate-limiting}
1243
- */
1244
- groupKey?: string;
1245
- /**
1246
- * This option enables a heuristic so that when a queue is heavily
1247
- * rete limited, it delays the workers so that they do not try
1248
- * to pick jobs when there is no point in doing so.
1249
- * Note: It is not recommended to use this option when using
1250
- * groupKeys unless you have a big amount of workers since
1251
- * you may be delaying workers that could pick jobs in groups that
1252
- * have not been rate limited.
1253
- */
1254
- workerDelay?: boolean;
1255
- }
1256
-
1257
- export declare type RedisClient = Redis | Cluster;
1258
-
1259
- export declare class RedisConnection extends EventEmitter {
1260
- private readonly opts?;
1261
- private readonly shared;
1262
- static minimumVersion: string;
1263
- protected _client: RedisClient;
1264
- private initializing;
1265
- private closing;
1266
- private version;
1267
- private handleClientError;
1268
- constructor(opts?: ConnectionOptions, shared?: boolean);
1269
- private checkOptions;
1270
- /**
1271
- * Waits for a redis client to be ready.
1272
- * @param redis - client
1273
- */
1274
- static waitUntilReady(client: RedisClient): Promise<void>;
1275
- get client(): Promise<RedisClient>;
1276
- protected loadCommands(): Promise<void>;
1277
- private init;
1278
- disconnect(): Promise<void>;
1279
- reconnect(): Promise<void>;
1280
- close(): Promise<void>;
1281
- private getRedisVersion;
1282
- get redisVersion(): string;
1283
- }
1284
-
1285
- export declare type RedisOptions = RedisOptions_2 & {
1286
- skipVersionCheck?: boolean;
1287
- };
1288
-
1289
- export declare function removeAllQueueData(client: RedisClient, queueName: string, prefix?: string): Promise<void | boolean>;
1290
-
1291
- export declare class Repeat extends QueueBase {
1292
- addNextRepeatableJob<T = any, R = any, N extends string = string>(name: N, data: T, opts: JobsOptions, skipCheckExists?: boolean): Promise<Job<T, R, N>>;
1293
- private createNextJob;
1294
- removeRepeatable(name: string, repeat: RepeatOptions, jobId?: string): Promise<any>;
1295
- removeRepeatableByKey(repeatJobKey: string): Promise<any>;
1296
- private keyToData;
1297
- getRepeatableJobs(start?: number, end?: number, asc?: boolean): Promise<{
1298
- key: string;
1299
- name: string;
1300
- id: string;
1301
- endDate: number;
1302
- tz: string;
1303
- cron: string;
1304
- next: number;
1305
- }[]>;
1306
- getRepeatableCount(): Promise<number>;
1307
- }
1308
-
1309
- /**
1310
- * Settings for repeatable jobs
1311
- *
1312
- * @see {@link https://docs.bullmq.io/guide/jobs/repeatable}
1313
- */
1314
- export declare interface RepeatOptions {
1315
- /**
1316
- * A cron pattern
1317
- */
1318
- cron?: string;
1319
- /**
1320
- * Timezone
1321
- */
1322
- tz?: string;
1323
- /**
1324
- * Start date when the repeat job should start repeating (only with `cron`).
1325
- */
1326
- startDate?: Date | string | number;
1327
- /**
1328
- * End date when the repeat job should stop repeating.
1329
- */
1330
- endDate?: Date | string | number;
1331
- /**
1332
- * Number of times the job should repeat at max.
1333
- */
1334
- limit?: number;
1335
- /**
1336
- * Repeat after this amount of milliseconds
1337
- * (`cron` setting cannot be used together with this setting.)
1338
- */
1339
- every?: number;
1340
- /**
1341
- * Repeated job should start right now
1342
- * ( work only with every settings)
1343
- */
1344
- immediately?: boolean;
1345
- /**
1346
- * The start value for the repeat iteration count.
1347
- */
1348
- count?: number;
1349
- prevMillis?: number;
1350
- offset?: number;
1351
- jobId?: string;
1352
- }
1353
-
1354
- /**
1355
- * @see {@link https://docs.bullmq.io/guide/workers/sandboxed-processors}
1356
- */
1357
- export declare interface SandboxedJob<T = any, R = any> extends Omit<JobJson, 'data' | 'opts' | 'progress' | 'returnValue'> {
1358
- data: T;
1359
- opts: JobsOptions;
1360
- progress: (() => object | number) | ((value: object | number) => Promise<void>);
1361
- updateProgress: (value: object | number) => Promise<void>;
1362
- log: (row: any) => void;
1363
- returnValue: R;
1364
- }
1365
-
1366
- /**
1367
- * @see {@link https://docs.bullmq.io/guide/workers/sandboxed-processors}
1368
- */
1369
- 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);
1370
-
1371
- export declare class Scripts {
1372
- static isJobInList(queue: MinimalQueue, listKey: string, jobId: string): Promise<boolean>;
1373
- static addJob(client: RedisClient, queue: MinimalQueue, job: JobJson, opts: JobsOptions, jobId: string, parentOpts?: ParentOpts): Promise<string>;
1374
- static pause(queue: MinimalQueue, pause: boolean): Promise<any>;
1375
- static remove(queue: MinimalQueue, jobId: string): Promise<number>;
1376
- static extendLock(queue: MinimalQueue, jobId: string, token: string, duration: number): Promise<number>;
1377
- static updateProgress(queue: MinimalQueue, job: Job, progress: number | object): Promise<void>;
1378
- static moveToFinishedArgs(queue: MinimalQueue, job: Job, val: any, propVal: string, shouldRemove: boolean | number, target: string, token: string, fetchNext?: boolean): string[];
1379
- static moveToFinished(queue: MinimalQueue, job: Job, val: any, propVal: string, shouldRemove: boolean | number, target: string, token: string, fetchNext: boolean): Promise<[] | [JobJsonRaw, string]>;
1380
- static finishedErrors(code: number, jobId: string, command: string, state?: string): Error;
1381
- static drainArgs(queue: MinimalQueue, delayed: boolean): string[];
1382
- static drain(queue: MinimalQueue, delayed: boolean): Promise<void>;
1383
- static moveToCompleted(queue: MinimalQueue, job: Job, returnvalue: any, removeOnComplete: boolean | number, token: string, fetchNext: boolean): Promise<[] | [JobJsonRaw, string]>;
1384
- static moveToFailedArgs(queue: MinimalQueue, job: Job, failedReason: string, removeOnFailed: boolean | number, token: string, fetchNext?: boolean): string[];
1385
- static isFinished(queue: MinimalQueue, jobId: string, returnValue?: boolean): Promise<number | [number, string]>;
1386
- static getState(queue: MinimalQueue, jobId: string): Promise<string>;
1387
- static changeDelay(queue: MinimalQueue, jobId: string, delay: number): Promise<void>;
1388
- static changeDelayArgs(queue: MinimalQueue, jobId: string, timestamp: number): string[];
1389
- static moveToDelayedArgs(queue: MinimalQueue, jobId: string, timestamp: number): string[];
1390
- static moveToWaitingChildrenArgs(queue: MinimalQueue, jobId: string, token: string, opts?: MoveToChildrenOpts): string[];
1391
- static moveToDelayed(queue: MinimalQueue, jobId: string, timestamp: number): Promise<void>;
1392
- /**
1393
- * Move parent job to waiting-children state.
1394
- *
1395
- * @returns true if job is successfully moved, false if there are pending dependencies.
1396
- * @throws JobNotExist
1397
- * This exception is thrown if jobId is missing.
1398
- * @throws JobLockNotExist
1399
- * This exception is thrown if job lock is missing.
1400
- * @throws JobNotInState
1401
- * This exception is thrown if job is not in active state.
1402
- */
1403
- static moveToWaitingChildren(queue: MinimalQueue, jobId: string, token: string, opts?: MoveToChildrenOpts): Promise<boolean>;
1404
- static cleanJobsInSet(queue: MinimalQueue, set: string, timestamp: number, limit?: number): Promise<any>;
1405
- static retryJobArgs(queue: MinimalQueue, job: Job): string[];
1406
- /**
1407
- * Attempts to reprocess a job
1408
- *
1409
- * @param job -
1410
- * @param {Object} options
1411
- * @param {String} options.state The expected job state. If the job is not found
1412
- * on the provided state, then it's not reprocessed. Supported states: 'failed', 'completed'
1413
- *
1414
- * @returns Returns a promise that evaluates to a return code:
1415
- * 1 means the operation was a success
1416
- * 0 means the job does not exist
1417
- * -1 means the job is currently locked and can't be retried.
1418
- * -2 means the job was not found in the expected set
1419
- */
1420
- static reprocessJob(queue: MinimalQueue, job: Job, state: 'failed' | 'completed'): Promise<void>;
1421
- static moveToActive<T, R, N extends string>(worker: Worker_2<T, R, N>, token: string, jobId?: string): Promise<[] | [number, undefined] | [JobJsonRaw, string]>;
1422
- static updateDelaySet(queue: MinimalQueue, delayedTimestamp: number): Promise<any>;
1423
- static promote(queue: MinimalQueue, jobId: string): Promise<any>;
1424
- static moveStalledJobsToWait(queue: QueueScheduler): Promise<any>;
1425
- static obliterate(queue: MinimalQueue, opts: {
1426
- force: boolean;
1427
- count: number;
1428
- }): Promise<any>;
1429
- }
1430
-
1431
- export declare interface Strategies {
1432
- [index: string]: BackoffFunction;
1433
- }
1434
-
1435
- export declare function tryCatch(fn: (...args: any) => any, ctx: any, args: any[]): any;
1436
-
1437
- declare interface Worker_2 {
1438
- on(event: 'active', listener: (job: Job, prev: string) => void): this;
1439
- on(event: 'completed', listener: (job: Job) => void): this;
1440
- on(event: 'drained', listener: () => void): this;
1441
- on(event: 'error', listener: (failedReason: Error) => void): this;
1442
- on(event: 'failed', listener: (job: Job, error: Error) => void): this;
1443
- on(event: 'progress', listener: (job: Job, progress: number | object) => void): this;
1444
- on(event: string, listener: Function): this;
1445
- }
1446
-
1447
- /**
1448
- *
1449
- * This class represents a worker that is able to process jobs from the queue.
1450
- * As soon as the class is instantiated it will start processing jobs.
1451
- *
1452
- */
1453
- declare class Worker_2<DataType = any, ResultType = any, NameType extends string = string> extends QueueBase {
1454
- opts: WorkerOptions_2;
1455
- private drained;
1456
- private waiting;
1457
- private running;
1458
- private processFn;
1459
- private resumeWorker;
1460
- private paused;
1461
- private _repeat;
1462
- private childPool;
1463
- private timerManager;
1464
- private blockingConnection;
1465
- private processing;
1466
- constructor(name: string, processor?: string | Processor<DataType, ResultType, NameType>, opts?: WorkerOptions_2, Connection?: typeof RedisConnection);
1467
- /**
1468
- *
1469
- * Waits until the worker is ready to start processing jobs.
1470
- * In general only useful when writing tests.
1471
- *
1472
- */
1473
- waitUntilReady(): Promise<RedisClient>;
1474
- get repeat(): Promise<Repeat>;
1475
- run(): Promise<any[]>;
1476
- /**
1477
- * Returns a promise that resolves to the next job in queue.
1478
- * @param token - worker token to be assigned to retrieved job
1479
- * @returns a Job or undefined if no job was available in the queue.
1480
- */
1481
- getNextJob(token: string, { block }?: GetNextJobOptions): Promise<Job<any, any, string>>;
1482
- private moveToActive;
1483
- private waitForJob;
1484
- /**
1485
- *
1486
- * This function is exposed only for testing purposes.
1487
- */
1488
- delay(): Promise<void>;
1489
- private nextJobFromJobData;
1490
- processJob(job: Job<DataType, ResultType, NameType>, token: string): Promise<void | Job<any, any, string>>;
1491
- /**
1492
- *
1493
- * Pauses the processing of this queue only for this worker.
1494
- */
1495
- pause(doNotWaitActive?: boolean): Promise<void>;
1496
- /**
1497
- *
1498
- * Resumes processing of this worker (if paused).
1499
- */
1500
- resume(): void;
1501
- /**
1502
- *
1503
- * Checks if worker is paused.
1504
- *
1505
- * @returns true if worker is paused, false otherwise.
1506
- */
1507
- isPaused(): boolean;
1508
- /**
1509
- *
1510
- * Checks if worker is currently running.
1511
- *
1512
- * @returns true if worker is running, false otherwise.
1513
- */
1514
- isRunning(): boolean;
1515
- /**
1516
- *
1517
- * Closes the worker and related redis connections.
1518
- *
1519
- * This method waits for current jobs to finalize before returning.
1520
- *
1521
- * @param force - Use force boolean parameter if you do not want to wait for
1522
- * current jobs to be processed.
1523
- *
1524
- * @returns Promise that resolves when the worker has been closed.
1525
- */
1526
- close(force?: boolean): Promise<void>;
1527
- /**
1528
- * Returns a promise that resolves when active jobs are cleared
1529
- *
1530
- * @returns
1531
- */
1532
- private whenCurrentJobsFinished;
1533
- private retryIfFailed;
1534
- }
1535
- export { Worker_2 as Worker }
1536
-
1537
- declare interface WorkerOptions_2 extends QueueBaseOptions {
1538
- /**
1539
- * Condition to start processor at instance creation.
1540
- */
1541
- autorun?: boolean;
1542
- /**
1543
- * Amount of jobs that a single worker is allowed to work on
1544
- * in parallel.
1545
- *
1546
- * @see {@link https://docs.bullmq.io/guide/workers/concurrency}
1547
- */
1548
- concurrency?: number;
1549
- /**
1550
- * @see {@link https://docs.bullmq.io/guide/rate-limiting}
1551
- */
1552
- limiter?: RateLimiterOptions;
1553
- skipDelayCheck?: boolean;
1554
- drainDelay?: number;
1555
- lockDuration?: number;
1556
- lockRenewTime?: number;
1557
- runRetryDelay?: number;
1558
- settings?: AdvancedOptions;
1559
- }
1560
- export { WorkerOptions_2 as WorkerOptions }
1561
-
1562
- export { }