bullmq 3.6.1 → 3.6.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.
Files changed (96) hide show
  1. package/dist/cjs/classes/redis-connection.js +1 -1
  2. package/dist/cjs/classes/redis-connection.js.map +1 -1
  3. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -0
  4. package/dist/esm/classes/redis-connection.js +1 -1
  5. package/dist/esm/classes/redis-connection.js.map +1 -1
  6. package/dist/esm/tsconfig.tsbuildinfo +1 -0
  7. package/package.json +4 -3
  8. package/dist/cjs/classes/backoffs.d.ts +0 -11
  9. package/dist/cjs/classes/child-pool.d.ts +0 -22
  10. package/dist/cjs/classes/child-processor.d.ts +0 -24
  11. package/dist/cjs/classes/flow-producer.d.ts +0 -163
  12. package/dist/cjs/classes/index.d.ts +0 -18
  13. package/dist/cjs/classes/job.d.ts +0 -341
  14. package/dist/cjs/classes/process-utils.d.ts +0 -7
  15. package/dist/cjs/classes/queue-base.d.ts +0 -67
  16. package/dist/cjs/classes/queue-events.d.ts +0 -179
  17. package/dist/cjs/classes/queue-getters.d.ts +0 -164
  18. package/dist/cjs/classes/queue-keys.d.ts +0 -10
  19. package/dist/cjs/classes/queue.d.ts +0 -232
  20. package/dist/cjs/classes/redis-connection.d.ts +0 -38
  21. package/dist/cjs/classes/repeat.d.ts +0 -25
  22. package/dist/cjs/classes/sandbox.d.ts +0 -4
  23. package/dist/cjs/classes/scripts.d.ts +0 -101
  24. package/dist/cjs/classes/timer-manager.d.ts +0 -17
  25. package/dist/cjs/classes/unrecoverable-error.d.ts +0 -10
  26. package/dist/cjs/classes/worker.d.ts +0 -196
  27. package/dist/cjs/commands/index.d.ts +0 -4
  28. package/dist/cjs/commands/script-loader.d.ts +0 -120
  29. package/dist/cjs/enums/error-code.enum.d.ts +0 -8
  30. package/dist/cjs/enums/index.d.ts +0 -2
  31. package/dist/cjs/enums/metrics-time.d.ts +0 -10
  32. package/dist/cjs/index.d.ts +0 -6
  33. package/dist/cjs/interfaces/advanced-options.d.ts +0 -13
  34. package/dist/cjs/interfaces/backoff-options.d.ts +0 -15
  35. package/dist/cjs/interfaces/base-job-options.d.ts +0 -92
  36. package/dist/cjs/interfaces/child-command.d.ts +0 -5
  37. package/dist/cjs/interfaces/child-message.d.ts +0 -6
  38. package/dist/cjs/interfaces/connection.d.ts +0 -8
  39. package/dist/cjs/interfaces/flow-job.d.ts +0 -20
  40. package/dist/cjs/interfaces/index.d.ts +0 -24
  41. package/dist/cjs/interfaces/ioredis-events.d.ts +0 -8
  42. package/dist/cjs/interfaces/job-json.d.ts +0 -37
  43. package/dist/cjs/interfaces/keep-jobs.d.ts +0 -17
  44. package/dist/cjs/interfaces/metrics-options.d.ts +0 -12
  45. package/dist/cjs/interfaces/metrics.d.ts +0 -9
  46. package/dist/cjs/interfaces/minimal-job.d.ts +0 -129
  47. package/dist/cjs/interfaces/parent-command.d.ts +0 -10
  48. package/dist/cjs/interfaces/parent-message.d.ts +0 -8
  49. package/dist/cjs/interfaces/parent.d.ts +0 -20
  50. package/dist/cjs/interfaces/queue-options.d.ts +0 -74
  51. package/dist/cjs/interfaces/rate-limiter-options.d.ts +0 -12
  52. package/dist/cjs/interfaces/redis-options.d.ts +0 -8
  53. package/dist/cjs/interfaces/redis-streams.d.ts +0 -4
  54. package/dist/cjs/interfaces/repeat-options.d.ts +0 -33
  55. package/dist/cjs/interfaces/sandboxed-job-processor.d.ts +0 -5
  56. package/dist/cjs/interfaces/sandboxed-job.d.ts +0 -13
  57. package/dist/cjs/interfaces/worker-options.d.ts +0 -51
  58. package/dist/cjs/scripts/addJob-8.d.ts +0 -5
  59. package/dist/cjs/scripts/changeDelay-3.d.ts +0 -5
  60. package/dist/cjs/scripts/cleanJobsInSet-2.d.ts +0 -5
  61. package/dist/cjs/scripts/drain-4.d.ts +0 -5
  62. package/dist/cjs/scripts/extendLock-2.d.ts +0 -5
  63. package/dist/cjs/scripts/getCounts-1.d.ts +0 -5
  64. package/dist/cjs/scripts/getRanges-1.d.ts +0 -5
  65. package/dist/cjs/scripts/getState-7.d.ts +0 -5
  66. package/dist/cjs/scripts/getStateV2-7.d.ts +0 -5
  67. package/dist/cjs/scripts/index.d.ts +0 -29
  68. package/dist/cjs/scripts/isFinished-3.d.ts +0 -5
  69. package/dist/cjs/scripts/isJobInList-1.d.ts +0 -5
  70. package/dist/cjs/scripts/moveJobFromActiveToWait-4.d.ts +0 -5
  71. package/dist/cjs/scripts/moveStalledJobsToWait-8.d.ts +0 -5
  72. package/dist/cjs/scripts/moveToActive-9.d.ts +0 -5
  73. package/dist/cjs/scripts/moveToDelayed-8.d.ts +0 -5
  74. package/dist/cjs/scripts/moveToFinished-12.d.ts +0 -5
  75. package/dist/cjs/scripts/moveToWaitingChildren-4.d.ts +0 -5
  76. package/dist/cjs/scripts/obliterate-2.d.ts +0 -5
  77. package/dist/cjs/scripts/pause-4.d.ts +0 -5
  78. package/dist/cjs/scripts/promote-6.d.ts +0 -5
  79. package/dist/cjs/scripts/releaseLock-1.d.ts +0 -5
  80. package/dist/cjs/scripts/removeJob-1.d.ts +0 -5
  81. package/dist/cjs/scripts/removeRepeatable-2.d.ts +0 -5
  82. package/dist/cjs/scripts/reprocessJob-4.d.ts +0 -5
  83. package/dist/cjs/scripts/retryJob-8.d.ts +0 -5
  84. package/dist/cjs/scripts/retryJobs-6.d.ts +0 -5
  85. package/dist/cjs/scripts/takeLock-1.d.ts +0 -5
  86. package/dist/cjs/scripts/updateData-1.d.ts +0 -5
  87. package/dist/cjs/scripts/updateProgress-2.d.ts +0 -5
  88. package/dist/cjs/types/backoff-strategy.d.ts +0 -2
  89. package/dist/cjs/types/finished-status.d.ts +0 -2
  90. package/dist/cjs/types/index.d.ts +0 -7
  91. package/dist/cjs/types/job-json-sandbox.d.ts +0 -5
  92. package/dist/cjs/types/job-options.d.ts +0 -16
  93. package/dist/cjs/types/job-type.d.ts +0 -3
  94. package/dist/cjs/types/minimal-queue.d.ts +0 -2
  95. package/dist/cjs/types/repeat-strategy.d.ts +0 -2
  96. package/dist/cjs/utils.d.ts +0 -43
@@ -1,163 +0,0 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- import { ChainableCommander } from 'ioredis';
4
- import { FlowJob, FlowQueuesOpts, FlowOpts, IoredisListener, QueueBaseOptions, RedisClient } from '../interfaces';
5
- import { Job } from './job';
6
- import { KeysMap, QueueKeys } from './queue-keys';
7
- import { RedisConnection } from './redis-connection';
8
- export interface AddNodeOpts {
9
- multi: ChainableCommander;
10
- node: FlowJob;
11
- parent?: {
12
- parentOpts: {
13
- id: string;
14
- queue: string;
15
- };
16
- parentDependenciesKey: string;
17
- };
18
- /**
19
- * Queues options that will be applied in each node depending on queue name presence.
20
- */
21
- queuesOpts?: FlowQueuesOpts;
22
- }
23
- export interface AddChildrenOpts {
24
- multi: ChainableCommander;
25
- nodes: FlowJob[];
26
- parent: {
27
- parentOpts: {
28
- id: string;
29
- queue: string;
30
- };
31
- parentDependenciesKey: string;
32
- };
33
- queuesOpts?: FlowQueuesOpts;
34
- }
35
- export interface NodeOpts {
36
- /**
37
- * Root job queue name.
38
- */
39
- queueName: string;
40
- /**
41
- * Prefix included in job key.
42
- */
43
- prefix?: string;
44
- /**
45
- * Root job id.
46
- */
47
- id: string;
48
- /**
49
- * Maximum depth or levels to visit in the tree.
50
- */
51
- depth?: number;
52
- /**
53
- * Maximum quantity of children per type (processed, unprocessed).
54
- */
55
- maxChildren?: number;
56
- }
57
- export interface JobNode {
58
- job: Job;
59
- children?: JobNode[];
60
- }
61
- export interface FlowProducerListener extends IoredisListener {
62
- /**
63
- * Listen to 'error' event.
64
- *
65
- * This event is triggered when an error is throw.
66
- */
67
- error: (failedReason: Error) => void;
68
- }
69
- /**
70
- * This class allows to add jobs with dependencies between them in such
71
- * a way that it is possible to build complex flows.
72
- * Note: A flow is a tree-like structure of jobs that depend on each other.
73
- * Whenever the children of a given parent are completed, the parent
74
- * will be processed, being able to access the children's result data.
75
- * All Jobs can be in different queues, either children or parents,
76
- */
77
- export declare class FlowProducer extends EventEmitter {
78
- opts: QueueBaseOptions;
79
- toKey: (name: string, type: string) => string;
80
- keys: KeysMap;
81
- closing: Promise<void>;
82
- queueKeys: QueueKeys;
83
- protected connection: RedisConnection;
84
- constructor(opts?: QueueBaseOptions, Connection?: typeof RedisConnection);
85
- emit<U extends keyof FlowProducerListener>(event: U, ...args: Parameters<FlowProducerListener[U]>): boolean;
86
- off<U extends keyof FlowProducerListener>(eventName: U, listener: FlowProducerListener[U]): this;
87
- on<U extends keyof FlowProducerListener>(event: U, listener: FlowProducerListener[U]): this;
88
- once<U extends keyof FlowProducerListener>(event: U, listener: FlowProducerListener[U]): this;
89
- /**
90
- * Adds a flow.
91
- *
92
- * This call would be atomic, either it fails and no jobs will
93
- * be added to the queues, or it succeeds and all jobs will be added.
94
- *
95
- * @param flow - an object with a tree-like structure where children jobs
96
- * will be processed before their parents.
97
- * @param opts - options that will be applied to the flow object.
98
- */
99
- add(flow: FlowJob, opts?: FlowOpts): Promise<JobNode>;
100
- /**
101
- * Get a flow.
102
- *
103
- * @param opts - an object with options for getting a JobNode.
104
- */
105
- getFlow(opts: NodeOpts): Promise<JobNode>;
106
- get client(): Promise<RedisClient>;
107
- /**
108
- * Helper to easily extend Job class calls.
109
- */
110
- protected get Job(): typeof Job;
111
- /**
112
- * Adds multiple flows.
113
- *
114
- * A flow is a tree-like structure of jobs that depend on each other.
115
- * Whenever the children of a given parent are completed, the parent
116
- * will be processed, being able to access the children's result data.
117
- *
118
- * All Jobs can be in different queues, either children or parents,
119
- * however this call would be atomic, either it fails and no jobs will
120
- * be added to the queues, or it succeeds and all jobs will be added.
121
- *
122
- * @param flows - an array of objects with a tree-like structure where children jobs
123
- * will be processed before their parents.
124
- */
125
- addBulk(flows: FlowJob[]): Promise<JobNode[]>;
126
- /**
127
- * Add a node (job) of a flow to the queue. This method will recursively
128
- * add all its children as well. Note that a given job can potentially be
129
- * a parent and a child job at the same time depending on where it is located
130
- * in the tree hierarchy.
131
- *
132
- * @param multi - ioredis ChainableCommander
133
- * @param node - the node representing a job to be added to some queue
134
- * @param parent - parent data sent to children to create the "links" to their parent
135
- * @returns
136
- */
137
- protected addNode({ multi, node, parent, queuesOpts }: AddNodeOpts): JobNode;
138
- /**
139
- * Adds nodes (jobs) of multiple flows to the queue. This method will recursively
140
- * add all its children as well. Note that a given job can potentially be
141
- * a parent and a child job at the same time depending on where it is located
142
- * in the tree hierarchy.
143
- *
144
- * @param multi - ioredis ChainableCommander
145
- * @param nodes - the nodes representing jobs to be added to some queue
146
- * @returns
147
- */
148
- protected addNodes(multi: ChainableCommander, nodes: FlowJob[]): JobNode[];
149
- private getNode;
150
- private addChildren;
151
- private getChildren;
152
- /**
153
- * Helper factory method that creates a queue-like object
154
- * required to create jobs in any queue.
155
- *
156
- * @param node -
157
- * @param queueKeys -
158
- * @returns
159
- */
160
- private queueFromNode;
161
- close(): Promise<void>;
162
- disconnect(): Promise<void>;
163
- }
@@ -1,18 +0,0 @@
1
- export * from './backoffs';
2
- export * from './child-pool';
3
- export * from './child-processor';
4
- export * from './flow-producer';
5
- export * from './job';
6
- export * from './process-utils';
7
- export * from './queue-base';
8
- export * from './queue-events';
9
- export * from './queue-getters';
10
- export * from './queue-keys';
11
- export * from './queue';
12
- export * from './redis-connection';
13
- export * from './repeat';
14
- export * from './sandbox';
15
- export * from './scripts';
16
- export * from './timer-manager';
17
- export * from './unrecoverable-error';
18
- export * from './worker';
@@ -1,341 +0,0 @@
1
- import { ChainableCommander } from 'ioredis';
2
- import { BulkJobOptions, DependenciesOpts, JobJson, JobJsonRaw, MinimalJob, MoveToWaitingChildrenOpts, ParentKeys, ParentOpts, RedisClient } from '../interfaces';
3
- import { FinishedStatus, JobsOptions, JobState, JobJsonSandbox, MinimalQueue } from '../types';
4
- import { Scripts } from './scripts';
5
- /**
6
- * Job
7
- *
8
- * This class represents a Job in the queue. Normally job are implicitly created when
9
- * you add a job to the queue with methods such as Queue.addJob( ... )
10
- *
11
- * A Job instance is also passed to the Worker's process function.
12
- *
13
- * @class Job
14
- */
15
- export declare class Job<DataType = any, ReturnType = any, NameType extends string = string> implements MinimalJob<DataType, ReturnType, NameType> {
16
- protected queue: MinimalQueue;
17
- /**
18
- * The name of the Job
19
- */
20
- name: NameType;
21
- /**
22
- * The payload for this job.
23
- */
24
- data: DataType;
25
- /**
26
- * The options object for this job.
27
- */
28
- opts: JobsOptions;
29
- id?: string;
30
- /**
31
- * The progress a job has performed so far.
32
- * @defaultValue 0
33
- */
34
- progress: number | object;
35
- /**
36
- * The value returned by the processor when processing this job.
37
- * @defaultValue null
38
- */
39
- returnvalue: ReturnType;
40
- /**
41
- * Stacktrace for the error (for failed jobs).
42
- * @defaultValue null
43
- */
44
- stacktrace: string[];
45
- /**
46
- * An amount of milliseconds to wait until this job can be processed.
47
- * @defaultValue 0
48
- */
49
- delay: number;
50
- /**
51
- * Timestamp when the job was created (unless overridden with job options).
52
- */
53
- timestamp: number;
54
- /**
55
- * Number of attempts after the job has failed.
56
- * @defaultValue 0
57
- */
58
- attemptsMade: number;
59
- /**
60
- * Reason for failing.
61
- */
62
- failedReason: string;
63
- /**
64
- * Timestamp for when the job finished (completed or failed).
65
- */
66
- finishedOn?: number;
67
- /**
68
- * Timestamp for when the job was processed.
69
- */
70
- processedOn?: number;
71
- /**
72
- * Fully qualified key (including the queue prefix) pointing to the parent of this job.
73
- */
74
- parentKey?: string;
75
- /**
76
- * Object that contains parentId (id) and parent queueKey.
77
- */
78
- parent?: ParentKeys;
79
- /**
80
- * Base repeat job key.
81
- */
82
- repeatJobKey?: string;
83
- protected toKey: (type: string) => string;
84
- protected discarded: boolean;
85
- protected scripts: Scripts;
86
- constructor(queue: MinimalQueue,
87
- /**
88
- * The name of the Job
89
- */
90
- name: NameType,
91
- /**
92
- * The payload for this job.
93
- */
94
- data: DataType,
95
- /**
96
- * The options object for this job.
97
- */
98
- opts?: JobsOptions, id?: string);
99
- /**
100
- * Creates a new job and adds it to the queue.
101
- *
102
- * @param queue - the queue where to add the job.
103
- * @param name - the name of the job.
104
- * @param data - the payload of the job.
105
- * @param opts - the options bag for this job.
106
- * @returns
107
- */
108
- static create<T = any, R = any, N extends string = string>(queue: MinimalQueue, name: N, data: T, opts?: JobsOptions): Promise<Job<T, R, N>>;
109
- /**
110
- * Creates a bulk of jobs and adds them atomically to the given queue.
111
- *
112
- * @param queue -the queue were to add the jobs.
113
- * @param jobs - an array of jobs to be added to the queue.
114
- * @returns
115
- */
116
- static createBulk<T = any, R = any, N extends string = string>(queue: MinimalQueue, jobs: {
117
- name: N;
118
- data: T;
119
- opts?: BulkJobOptions;
120
- }[]): Promise<Job<T, R, N>[]>;
121
- /**
122
- * Instantiates a Job from a JobJsonRaw object (coming from a deserialized JSON object)
123
- *
124
- * @param queue - the queue where the job belongs to.
125
- * @param json - the plain object containing the job.
126
- * @param jobId - an optional job id (overrides the id coming from the JSON object)
127
- * @returns
128
- */
129
- static fromJSON<T = any, R = any, N extends string = string>(queue: MinimalQueue, json: JobJsonRaw, jobId?: string): Job<T, R, N>;
130
- private static optsFromJSON;
131
- /**
132
- * Fetches a Job from the queue given the passed job id.
133
- *
134
- * @param queue - the queue where the job belongs to.
135
- * @param jobId - the job id.
136
- * @returns
137
- */
138
- static fromId<T = any, R = any, N extends string = string>(queue: MinimalQueue, jobId: string): Promise<Job<T, R, N> | undefined>;
139
- toJSON(): Omit<this, "toJSON" | "scripts" | "addJob" | "changeDelay" | "extendLock" | "getState" | "moveToDelayed" | "moveToWaitingChildren" | "promote" | "updateProgress" | "discard" | "queue" | "asJSON" | "asJSONSandbox" | "update" | "log" | "clearLogs" | "remove" | "moveToCompleted" | "moveToFailed" | "isCompleted" | "isFailed" | "isDelayed" | "isWaitingChildren" | "isActive" | "isWaiting" | "queueName" | "prefix" | "queueQualifiedName" | "getChildrenValues" | "getDependencies" | "getDependenciesCount" | "waitUntilFinished" | "retry">;
140
- /**
141
- * Prepares a job to be serialized for storage in Redis.
142
- * @returns
143
- */
144
- asJSON(): JobJson;
145
- private optsAsJSON;
146
- /**
147
- * Prepares a job to be passed to Sandbox.
148
- * @returns
149
- */
150
- asJSONSandbox(): JobJsonSandbox;
151
- /**
152
- * Updates a job's data
153
- *
154
- * @param data - the data that will replace the current jobs data.
155
- */
156
- update(data: DataType): Promise<void>;
157
- /**
158
- * Updates a job's progress
159
- *
160
- * @param progress - number or object to be saved as progress.
161
- */
162
- updateProgress(progress: number | object): Promise<void>;
163
- /**
164
- * Logs one row of log data.
165
- *
166
- * @param logRow - string with log data to be logged.
167
- */
168
- log(logRow: string): Promise<number>;
169
- /**
170
- * Clears job's logs
171
- *
172
- * @param keepLogs - the amount of log entries to preserve
173
- */
174
- clearLogs(keepLogs?: number): Promise<void>;
175
- /**
176
- * Completely remove the job from the queue.
177
- * Note, this call will throw an exception if the job
178
- * is being processed when the call is performed.
179
- */
180
- remove(): Promise<void>;
181
- /**
182
- * Extend the lock for this job.
183
- *
184
- * @param token - unique token for the lock
185
- * @param duration - lock duration in milliseconds
186
- */
187
- extendLock(token: string, duration: number): Promise<number>;
188
- /**
189
- * Moves a job to the completed queue.
190
- * Returned job to be used with Queue.prototype.nextJobFromJobData.
191
- *
192
- * @param returnValue - The jobs success message.
193
- * @param token - Worker token used to acquire completed job.
194
- * @param fetchNext - True when wanting to fetch the next job.
195
- * @returns Returns the jobData of the next job in the waiting queue.
196
- */
197
- moveToCompleted(returnValue: ReturnType, token: string, fetchNext?: boolean): Promise<any[]>;
198
- /**
199
- * Moves a job to the failed queue.
200
- *
201
- * @param err - the jobs error message.
202
- * @param token - token to check job is locked by current worker
203
- * @param fetchNext - true when wanting to fetch the next job
204
- * @returns void
205
- */
206
- moveToFailed<E extends Error>(err: E, token: string, fetchNext?: boolean): Promise<void>;
207
- /**
208
- * @returns true if the job has completed.
209
- */
210
- isCompleted(): Promise<boolean>;
211
- /**
212
- * @returns true if the job has failed.
213
- */
214
- isFailed(): Promise<boolean>;
215
- /**
216
- * @returns true if the job is delayed.
217
- */
218
- isDelayed(): Promise<boolean>;
219
- /**
220
- * @returns true if the job is waiting for children.
221
- */
222
- isWaitingChildren(): Promise<boolean>;
223
- /**
224
- * @returns true of the job is active.
225
- */
226
- isActive(): Promise<boolean>;
227
- /**
228
- * @returns true if the job is waiting.
229
- */
230
- isWaiting(): Promise<boolean>;
231
- /**
232
- * @returns the queue name this job belongs to.
233
- */
234
- get queueName(): string;
235
- /**
236
- * @returns the prefix that is used.
237
- */
238
- get prefix(): string;
239
- /**
240
- * @returns it includes the prefix, the namespace separator :, and queue name.
241
- * @see https://www.gnu.org/software/gawk/manual/html_node/Qualified-Names.html
242
- */
243
- get queueQualifiedName(): string;
244
- /**
245
- * Get current state.
246
- *
247
- * @returns Returns one of these values:
248
- * 'completed', 'failed', 'delayed', 'active', 'waiting', 'waiting-children', 'unknown'.
249
- */
250
- getState(): Promise<JobState | 'unknown'>;
251
- /**
252
- * Change delay of a delayed job.
253
- *
254
- * @param delay - milliseconds to be added to current time.
255
- * @returns void
256
- */
257
- changeDelay(delay: number): Promise<void>;
258
- /**
259
- * Get this jobs children result values if any.
260
- *
261
- * @returns Object mapping children job keys with their values.
262
- */
263
- getChildrenValues<CT = any>(): Promise<{
264
- [jobKey: string]: CT;
265
- }>;
266
- /**
267
- * Get children job keys if this job is a parent and has children.
268
- *
269
- * @returns dependencies separated by processed and unprocessed.
270
- */
271
- getDependencies(opts?: DependenciesOpts): Promise<{
272
- nextProcessedCursor?: number;
273
- processed?: Record<string, any>;
274
- nextUnprocessedCursor?: number;
275
- unprocessed?: string[];
276
- }>;
277
- /**
278
- * Get children job counts if this job is a parent and has children.
279
- *
280
- * @returns dependencies count separated by processed and unprocessed.
281
- */
282
- getDependenciesCount(opts?: {
283
- processed?: boolean;
284
- unprocessed?: boolean;
285
- }): Promise<{
286
- processed?: number;
287
- unprocessed?: number;
288
- }>;
289
- /**
290
- * Returns a promise the resolves when the job has completed (containing the return value of the job),
291
- * or rejects when the job has failed (containing the failedReason).
292
- *
293
- * @param queueEvents - Instance of QueueEvents.
294
- * @param ttl - Time in milliseconds to wait for job to finish before timing out.
295
- */
296
- waitUntilFinished(queueEvents: MinimalQueue, ttl?: number): Promise<ReturnType>;
297
- /**
298
- * Moves the job to the delay set.
299
- *
300
- * @param timestamp - timestamp where the job should be moved back to "wait"
301
- * @param token - token to check job is locked by current worker
302
- * @returns
303
- */
304
- moveToDelayed(timestamp: number, token?: string): Promise<void>;
305
- /**
306
- * Moves the job to the waiting-children set.
307
- *
308
- * @param token - Token to check job is locked by current worker
309
- * @param opts - The options bag for moving a job to waiting-children.
310
- * @returns true if the job was moved
311
- */
312
- moveToWaitingChildren(token: string, opts?: MoveToWaitingChildrenOpts): Promise<boolean>;
313
- /**
314
- * Promotes a delayed job so that it starts to be processed as soon as possible.
315
- */
316
- promote(): Promise<void>;
317
- /**
318
- * Attempts to retry the job. Only a job that has failed or completed can be retried.
319
- *
320
- * @param state - completed / failed
321
- * @returns If resolved and return code is 1, then the queue emits a waiting event
322
- * otherwise the operation was not a success and throw the corresponding error. If the promise
323
- * rejects, it indicates that the script failed to execute
324
- */
325
- retry(state?: FinishedStatus): Promise<void>;
326
- /**
327
- * Marks a job to not be retried if it fails (even if attempts has been configured)
328
- */
329
- discard(): void;
330
- private isInZSet;
331
- private isInList;
332
- /**
333
- * Adds the job to Redis.
334
- *
335
- * @param client -
336
- * @param parentOpts -
337
- * @returns
338
- */
339
- addJob(client: RedisClient, parentOpts?: ParentOpts): Promise<string>;
340
- protected saveStacktrace(multi: ChainableCommander, err: Error): void;
341
- }
@@ -1,7 +0,0 @@
1
- /// <reference types="node" />
2
- import { ChildProcess } from 'child_process';
3
- /**
4
- * Sends a kill signal to a child resolving when the child has exited,
5
- * resorting to SIGKILL if the given timeout is reached
6
- */
7
- export declare function killAsync(child: ChildProcess, signal?: 'SIGTERM' | 'SIGKILL', timeoutMs?: number): Promise<void>;
@@ -1,67 +0,0 @@
1
- /// <reference types="node" />
2
- import { EventEmitter } from 'events';
3
- import { QueueBaseOptions, RedisClient } from '../interfaces';
4
- import { MinimalQueue } from '../types';
5
- import { RedisConnection } from './redis-connection';
6
- import { Job } from './job';
7
- import { KeysMap } from './queue-keys';
8
- import { Scripts } from './scripts';
9
- /**
10
- * @class QueueBase
11
- * @extends EventEmitter
12
- *
13
- * @description Base class for all classes that need to interact with queues.
14
- * This class is normally not used directly, but extended by the other classes.
15
- *
16
- */
17
- export declare class QueueBase extends EventEmitter implements MinimalQueue {
18
- readonly name: string;
19
- opts: QueueBaseOptions;
20
- toKey: (type: string) => string;
21
- keys: KeysMap;
22
- closing: Promise<void>;
23
- protected scripts: Scripts;
24
- protected connection: RedisConnection;
25
- /**
26
- *
27
- * @param name - The name of the queue.
28
- * @param opts - Options for the queue.
29
- * @param Connection - An optional "Connection" class used to instantiate a Connection. This is useful for
30
- * testing with mockups and/or extending the Connection class and passing an alternate implementation.
31
- */
32
- constructor(name: string, opts?: QueueBaseOptions, Connection?: typeof RedisConnection);
33
- /**
34
- * Returns a promise that resolves to a redis client. Normally used only by subclasses.
35
- */
36
- get client(): Promise<RedisClient>;
37
- /**
38
- * Returns the version of the Redis instance the client is connected to,
39
- */
40
- get redisVersion(): string;
41
- /**
42
- * Helper to easily extend Job class calls.
43
- */
44
- protected get Job(): typeof Job;
45
- /**
46
- * Emits an event. Normally used by subclasses to emit events.
47
- *
48
- * @param event - The emitted event.
49
- * @param args -
50
- * @returns
51
- */
52
- emit(event: string | symbol, ...args: any[]): boolean;
53
- waitUntilReady(): Promise<RedisClient>;
54
- protected base64Name(): string;
55
- protected clientName(suffix?: string): string;
56
- /**
57
- *
58
- * @returns Closes the connection and returns a promise that resolves when the connection is closed.
59
- */
60
- close(): Promise<void>;
61
- /**
62
- *
63
- * Force disconnects a connection.
64
- */
65
- disconnect(): Promise<void>;
66
- protected checkConnectionError<T>(fn: () => Promise<T>, delayInMs?: number): Promise<T>;
67
- }