bullmq 1.91.1 → 2.0.0
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-processor.js +0 -20
- package/dist/cjs/classes/child-processor.js.map +1 -1
- package/dist/cjs/classes/index.d.ts +0 -2
- package/dist/cjs/classes/index.js +0 -2
- package/dist/cjs/classes/index.js.map +1 -1
- package/dist/cjs/classes/queue-getters.d.ts +1 -0
- package/dist/cjs/classes/queue-getters.js +27 -2
- package/dist/cjs/classes/queue-getters.js.map +1 -1
- package/dist/cjs/classes/redis-connection.d.ts +2 -1
- package/dist/cjs/classes/redis-connection.js +5 -0
- package/dist/cjs/classes/redis-connection.js.map +1 -1
- package/dist/cjs/classes/scripts.js +6 -4
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/classes/worker.d.ts +11 -0
- package/dist/cjs/classes/worker.js +54 -21
- package/dist/cjs/classes/worker.js.map +1 -1
- package/dist/{esm/commands/addJob-9.lua → cjs/commands/addJob-8.lua} +10 -2
- package/dist/cjs/commands/includes/checkStalledJobs.lua +136 -0
- package/dist/cjs/commands/includes/getNextDelayedTimestamp.lua +13 -0
- package/dist/cjs/commands/includes/moveJobFromWaitToActive.lua +1 -4
- package/dist/cjs/commands/includes/promoteDelayedJobs.lua +57 -0
- package/dist/cjs/commands/moveStalledJobsToWait-8.lua +4 -102
- package/dist/cjs/commands/moveToActive-9.lua +67 -0
- package/dist/cjs/commands/moveToFinished-12.lua +20 -5
- package/dist/cjs/commands/promote-6.lua +6 -0
- package/dist/cjs/interfaces/index.d.ts +0 -1
- package/dist/cjs/interfaces/index.js +0 -1
- package/dist/cjs/interfaces/index.js.map +1 -1
- package/dist/cjs/interfaces/sandboxed-job.d.ts +0 -1
- package/dist/cjs/interfaces/worker-options.d.ts +10 -0
- package/dist/esm/classes/child-processor.js +0 -20
- package/dist/esm/classes/child-processor.js.map +1 -1
- package/dist/esm/classes/index.d.ts +0 -2
- package/dist/esm/classes/index.js +0 -2
- package/dist/esm/classes/index.js.map +1 -1
- package/dist/esm/classes/queue-getters.d.ts +1 -0
- package/dist/esm/classes/queue-getters.js +27 -2
- package/dist/esm/classes/queue-getters.js.map +1 -1
- package/dist/esm/classes/redis-connection.d.ts +2 -1
- package/dist/esm/classes/redis-connection.js +5 -0
- package/dist/esm/classes/redis-connection.js.map +1 -1
- package/dist/esm/classes/scripts.js +6 -4
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/classes/worker.d.ts +11 -0
- package/dist/esm/classes/worker.js +54 -21
- package/dist/esm/classes/worker.js.map +1 -1
- package/dist/{cjs/commands/addJob-9.lua → esm/commands/addJob-8.lua} +10 -2
- package/dist/esm/commands/includes/checkStalledJobs.lua +136 -0
- package/dist/esm/commands/includes/getNextDelayedTimestamp.lua +13 -0
- package/dist/esm/commands/includes/moveJobFromWaitToActive.lua +1 -4
- package/dist/esm/commands/includes/promoteDelayedJobs.lua +57 -0
- package/dist/esm/commands/moveStalledJobsToWait-8.lua +4 -102
- package/dist/esm/commands/moveToActive-9.lua +67 -0
- package/dist/esm/commands/moveToFinished-12.lua +20 -5
- package/dist/esm/commands/promote-6.lua +6 -0
- package/dist/esm/interfaces/index.d.ts +0 -1
- package/dist/esm/interfaces/index.js +0 -1
- package/dist/esm/interfaces/index.js.map +1 -1
- package/dist/esm/interfaces/sandboxed-job.d.ts +0 -1
- package/dist/esm/interfaces/worker-options.d.ts +10 -0
- package/package.json +1 -1
- package/dist/cjs/classes/compat.d.ts +0 -320
- package/dist/cjs/classes/compat.js +0 -682
- package/dist/cjs/classes/compat.js.map +0 -1
- package/dist/cjs/classes/queue-scheduler.d.ts +0 -75
- package/dist/cjs/classes/queue-scheduler.js +0 -199
- package/dist/cjs/classes/queue-scheduler.js.map +0 -1
- package/dist/cjs/commands/moveToActive-8.lua +0 -54
- package/dist/cjs/interfaces/queue-scheduler-options.d.ts +0 -23
- package/dist/cjs/interfaces/queue-scheduler-options.js +0 -3
- package/dist/cjs/interfaces/queue-scheduler-options.js.map +0 -1
- package/dist/esm/classes/compat.d.ts +0 -320
- package/dist/esm/classes/compat.js +0 -678
- package/dist/esm/classes/compat.js.map +0 -1
- package/dist/esm/classes/queue-scheduler.d.ts +0 -75
- package/dist/esm/classes/queue-scheduler.js +0 -195
- package/dist/esm/classes/queue-scheduler.js.map +0 -1
- package/dist/esm/commands/moveToActive-8.lua +0 -54
- package/dist/esm/interfaces/queue-scheduler-options.d.ts +0 -23
- package/dist/esm/interfaces/queue-scheduler-options.js +0 -2
- package/dist/esm/interfaces/queue-scheduler-options.js.map +0 -1
@@ -1,682 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
// Type definitions for bull 3.10
|
3
|
-
// Project: https://github.com/OptimalBits/bull
|
4
|
-
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
|
5
|
-
// Cameron Crothers <https://github.com/JProgrammer>
|
6
|
-
// Marshall Cottrell <https://github.com/marshall007>
|
7
|
-
// Weeco <https://github.com/weeco>
|
8
|
-
// Gabriel Terwesten <https://github.com/blaugold>
|
9
|
-
// Oleg Repin <https://github.com/iamolegga>
|
10
|
-
// David Koblas <https://github.com/koblas>
|
11
|
-
// Bond Akinmade <https://github.com/bondz>
|
12
|
-
// Wuha Team <https://github.com/wuha-team>
|
13
|
-
// Alec Brunelle <https://github.com/aleccool213>
|
14
|
-
// Dan Manastireanu <https://github.com/danmana>
|
15
|
-
// Kjell-Morten Bratsberg Thorsen <https://github.com/kjellmorten>
|
16
|
-
// Christian D. <https://github.com/pc-jedi>
|
17
|
-
// Silas Rech <https://github.com/lenovouser>
|
18
|
-
// DoYoung Ha <https://github.com/hados99>
|
19
|
-
// Borys Kupar <https://github.com/borys-kupar>
|
20
|
-
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
21
|
-
// TypeScript Version: 2.8
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
23
|
-
exports.Queue3 = void 0;
|
24
|
-
const events_1 = require("events");
|
25
|
-
const queue_scheduler_1 = require("./queue-scheduler");
|
26
|
-
const queue_1 = require("./queue");
|
27
|
-
const worker_1 = require("./worker");
|
28
|
-
const queue_events_1 = require("./queue-events");
|
29
|
-
/**
|
30
|
-
* @deprecated Use Queue class instead {@link https://docs.bullmq.io/guide/queues}
|
31
|
-
*/
|
32
|
-
class Queue3 extends events_1.EventEmitter {
|
33
|
-
/**
|
34
|
-
* This is the Queue constructor.
|
35
|
-
* It creates a new Queue that is persisted in Redis.
|
36
|
-
* Every time the same queue is instantiated it tries to process all the old jobs
|
37
|
-
* that may exist from a previous unfinished session.
|
38
|
-
*/
|
39
|
-
constructor(name, opts) {
|
40
|
-
super();
|
41
|
-
this.opts = opts;
|
42
|
-
this.name = name;
|
43
|
-
this.queue = new queue_1.Queue(this.name, this.opts);
|
44
|
-
}
|
45
|
-
/**
|
46
|
-
* Returns a promise that resolves when Redis is connected and the queue is ready to accept jobs.
|
47
|
-
* This replaces the `ready` event emitted on Queue in previous versions.
|
48
|
-
*/
|
49
|
-
async isReady() {
|
50
|
-
await this.queue.client;
|
51
|
-
if (this.queueEvents) {
|
52
|
-
await this.queueEvents.client;
|
53
|
-
}
|
54
|
-
return this;
|
55
|
-
}
|
56
|
-
/**
|
57
|
-
* Defines a processing function for the jobs placed into a given Queue.
|
58
|
-
*
|
59
|
-
* The callback is called every time a job is placed in the queue.
|
60
|
-
* It is passed an instance of the job as first argument.
|
61
|
-
*
|
62
|
-
* If the callback signature contains the second optional done argument,
|
63
|
-
* the callback will be passed a done callback to be called after the job has been completed.
|
64
|
-
* The done callback can be called with an Error instance, to signal that the job did not complete successfully,
|
65
|
-
* or with a result as second argument (e.g.: done(null, result);) when the job is successful.
|
66
|
-
* Errors will be passed as a second argument to the "failed" event; results,
|
67
|
-
* as a second argument to the "completed" event.
|
68
|
-
*
|
69
|
-
* If, however, the callback signature does not contain the done argument,
|
70
|
-
* a promise must be returned to signal job completion.
|
71
|
-
* If the promise is rejected, the error will be passed as a second argument to the "failed" event.
|
72
|
-
* If it is resolved, its value will be the "completed" event's second argument.
|
73
|
-
*/
|
74
|
-
async process(processor) {
|
75
|
-
if (this.worker) {
|
76
|
-
throw new Error('Queue3.process() cannot be called twice');
|
77
|
-
}
|
78
|
-
this.worker = new worker_1.Worker(this.name, processor, this.opts);
|
79
|
-
this.queueScheduler = new queue_scheduler_1.QueueScheduler(this.name, this.opts);
|
80
|
-
await this.worker.client;
|
81
|
-
}
|
82
|
-
add(jobName, data, opts) {
|
83
|
-
return this.queue.add(jobName, data, opts);
|
84
|
-
}
|
85
|
-
/**
|
86
|
-
* Returns a promise that resolves when the queue is paused.
|
87
|
-
*
|
88
|
-
* A paused queue will not process new jobs until resumed, but current jobs being processed will continue until
|
89
|
-
* they are finalized. The pause can be either global or local. If global, all workers in all queue instances
|
90
|
-
* for a given queue will be paused. If local, just this worker will stop processing new jobs after the current
|
91
|
-
* lock expires. This can be useful to stop a worker from taking new jobs prior to shutting down.
|
92
|
-
*
|
93
|
-
* Pausing a queue that is already paused does nothing.
|
94
|
-
*/
|
95
|
-
async pause() {
|
96
|
-
return this.queue.pause();
|
97
|
-
}
|
98
|
-
async pauseWorker(doNotWaitActive) {
|
99
|
-
if (!this.worker) {
|
100
|
-
throw new Error('Worker is not initialized, call process() first');
|
101
|
-
}
|
102
|
-
return this.worker.pause(doNotWaitActive);
|
103
|
-
}
|
104
|
-
/**
|
105
|
-
* Returns a promise that resolves when the queue is resumed after being paused.
|
106
|
-
*
|
107
|
-
* The resume can be either local or global. If global, all workers in all queue instances for a given queue
|
108
|
-
* will be resumed. If local, only this worker will be resumed. Note that resuming a queue globally will not
|
109
|
-
* resume workers that have been paused locally; for those, resume(true) must be called directly on their
|
110
|
-
* instances.
|
111
|
-
*
|
112
|
-
* Resuming a queue that is not paused does nothing.
|
113
|
-
*/
|
114
|
-
async resume() {
|
115
|
-
return this.queue.resume();
|
116
|
-
}
|
117
|
-
async resumeWorker() {
|
118
|
-
if (!this.worker) {
|
119
|
-
throw new Error('Worker is not initialized, call process() first');
|
120
|
-
}
|
121
|
-
return this.worker.resume();
|
122
|
-
}
|
123
|
-
isWorkerPaused() {
|
124
|
-
return this.worker && this.worker.isPaused();
|
125
|
-
}
|
126
|
-
/**
|
127
|
-
* Returns a promise that returns the number of jobs in the queue, waiting or paused.
|
128
|
-
* Since there may be other processes adding or processing jobs,
|
129
|
-
* this value may be true only for a very small amount of time.
|
130
|
-
*/
|
131
|
-
count() {
|
132
|
-
return this.queue.count();
|
133
|
-
}
|
134
|
-
/**
|
135
|
-
* Empties a queue deleting all the input lists and associated jobs.
|
136
|
-
*/
|
137
|
-
async empty() {
|
138
|
-
await this.queue.drain();
|
139
|
-
}
|
140
|
-
/**
|
141
|
-
* Closes the underlying redis client. Use this to perform a graceful shutdown.
|
142
|
-
*
|
143
|
-
* `close` can be called from anywhere, with one caveat:
|
144
|
-
* if called from within a job handler the queue won't close until after the job has been processed
|
145
|
-
*/
|
146
|
-
close() {
|
147
|
-
const promises = [];
|
148
|
-
if (this.queueScheduler) {
|
149
|
-
promises.push(this.queueScheduler.close());
|
150
|
-
}
|
151
|
-
if (this.queue) {
|
152
|
-
promises.push(this.queue.close());
|
153
|
-
}
|
154
|
-
if (this.queueEvents) {
|
155
|
-
promises.push(this.queueEvents.close());
|
156
|
-
}
|
157
|
-
if (this.worker) {
|
158
|
-
promises.push(this.worker.close());
|
159
|
-
}
|
160
|
-
return Promise.all(promises);
|
161
|
-
}
|
162
|
-
/**
|
163
|
-
* Returns a promise that will return the job instance associated with the jobId parameter.
|
164
|
-
* If the specified job cannot be located, the promise callback parameter will be set to null.
|
165
|
-
*/
|
166
|
-
getJob(jobId) {
|
167
|
-
return this.queue.getJob(jobId);
|
168
|
-
}
|
169
|
-
/**
|
170
|
-
* Returns a promise that will return an array with the waiting jobs between start and end.
|
171
|
-
*/
|
172
|
-
getWaiting(start = 0, end = -1) {
|
173
|
-
return this.queue.getWaiting(start, end);
|
174
|
-
}
|
175
|
-
/**
|
176
|
-
* Returns a promise that will return an array with the active jobs between start and end.
|
177
|
-
*/
|
178
|
-
getActive(start = 0, end = -1) {
|
179
|
-
return this.queue.getActive(start, end);
|
180
|
-
}
|
181
|
-
/**
|
182
|
-
* Returns a promise that will return an array with the delayed jobs between start and end.
|
183
|
-
*/
|
184
|
-
getDelayed(start = 0, end = -1) {
|
185
|
-
return this.queue.getDelayed(start, end);
|
186
|
-
}
|
187
|
-
/**
|
188
|
-
* Returns a promise that will return an array with the completed jobs between start and end.
|
189
|
-
*/
|
190
|
-
getCompleted(start = 0, end = -1) {
|
191
|
-
return this.queue.getCompleted(start, end);
|
192
|
-
}
|
193
|
-
/**
|
194
|
-
* Returns a promise that will return an array with the failed jobs between start and end.
|
195
|
-
*/
|
196
|
-
async getFailed(start = 0, end = -1) {
|
197
|
-
return this.queue.getFailed(start, end);
|
198
|
-
}
|
199
|
-
/**
|
200
|
-
* Returns JobInformation of repeatable jobs (ordered descending). Provide a start and/or an end
|
201
|
-
* index to limit the number of results. Start defaults to 0, end to -1 and asc to false.
|
202
|
-
*/
|
203
|
-
async getRepeatableJobs(start = 0, end = -1, asc = false) {
|
204
|
-
const repeat = await this.queue.repeat;
|
205
|
-
return repeat.getRepeatableJobs(start, end, asc);
|
206
|
-
}
|
207
|
-
/**
|
208
|
-
* ???
|
209
|
-
*/
|
210
|
-
async nextRepeatableJob(name, data, opts, skipCheckExists) {
|
211
|
-
const repeat = await this.queue.repeat;
|
212
|
-
return repeat.addNextRepeatableJob(name, data, opts, skipCheckExists);
|
213
|
-
}
|
214
|
-
/**
|
215
|
-
* Removes a given repeatable job. The RepeatOptions and JobId needs to be the same as the ones
|
216
|
-
* used for the job when it was added.
|
217
|
-
*
|
218
|
-
* name: The name of the to be removed job
|
219
|
-
*/
|
220
|
-
async removeRepeatable(name, opts) {
|
221
|
-
const repeat = await this.queue.repeat;
|
222
|
-
const removed = await repeat.removeRepeatable(name, opts, opts.jobId);
|
223
|
-
return !removed;
|
224
|
-
}
|
225
|
-
/**
|
226
|
-
* Removes a given repeatable job by key.
|
227
|
-
*/
|
228
|
-
async removeRepeatableByKey(repeatJobKey) {
|
229
|
-
const repeat = await this.queue.repeat;
|
230
|
-
const client = await repeat.client;
|
231
|
-
const tokens = repeatJobKey.split(':');
|
232
|
-
const data = {
|
233
|
-
key: repeatJobKey,
|
234
|
-
name: tokens[0],
|
235
|
-
id: tokens[1] || null,
|
236
|
-
endDate: parseInt(tokens[2]) || null,
|
237
|
-
tz: tokens[3] || null,
|
238
|
-
cron: tokens[4],
|
239
|
-
};
|
240
|
-
const queueKey = repeat.toKey('');
|
241
|
-
return client.removeRepeatable(repeat.keys.repeat, repeat.keys.delayed, data.id, repeatJobKey, queueKey);
|
242
|
-
}
|
243
|
-
/**
|
244
|
-
* Returns a promise that will return an array of job instances of the given types.
|
245
|
-
* Optional parameters for range and ordering are provided.
|
246
|
-
*/
|
247
|
-
getJobs(types, start = 0, end = -1, asc = false) {
|
248
|
-
return this.queue.getJobs(types, start, end, asc);
|
249
|
-
}
|
250
|
-
async getNextJob() {
|
251
|
-
throw new Error('Not supported');
|
252
|
-
}
|
253
|
-
/**
|
254
|
-
* Returns a object with the logs according to the start and end arguments. The returned count
|
255
|
-
* value is the total amount of logs, useful for implementing pagination.
|
256
|
-
*/
|
257
|
-
getJobLogs(jobId, start = 0, end = -1) {
|
258
|
-
return this.queue.getJobLogs(jobId, start, end);
|
259
|
-
}
|
260
|
-
/**
|
261
|
-
* Returns a promise that resolves with the job counts for the given queue.
|
262
|
-
*/
|
263
|
-
getJobCounts(...types) {
|
264
|
-
return this.queue.getJobCounts(...types);
|
265
|
-
}
|
266
|
-
/**
|
267
|
-
* Returns a promise that resolves with the job counts for the given queue of the given types.
|
268
|
-
*/
|
269
|
-
async getJobCountByTypes(...types) {
|
270
|
-
return this.queue.getJobCountByTypes(...types);
|
271
|
-
}
|
272
|
-
/**
|
273
|
-
* Returns a promise that resolves with the quantity of completed jobs.
|
274
|
-
*/
|
275
|
-
getCompletedCount() {
|
276
|
-
return this.queue.getCompletedCount();
|
277
|
-
}
|
278
|
-
/**
|
279
|
-
* Returns a promise that resolves with the quantity of failed jobs.
|
280
|
-
*/
|
281
|
-
getFailedCount() {
|
282
|
-
return this.queue.getFailedCount();
|
283
|
-
}
|
284
|
-
/**
|
285
|
-
* Returns a promise that resolves with the quantity of delayed jobs.
|
286
|
-
*/
|
287
|
-
getDelayedCount() {
|
288
|
-
return this.queue.getDelayedCount();
|
289
|
-
}
|
290
|
-
/**
|
291
|
-
* Returns a promise that resolves with the quantity of waiting jobs.
|
292
|
-
*/
|
293
|
-
getWaitingCount() {
|
294
|
-
return this.queue.getWaitingCount();
|
295
|
-
}
|
296
|
-
/**
|
297
|
-
* Returns a promise that resolves with the quantity of paused jobs.
|
298
|
-
*/
|
299
|
-
getPausedCount() {
|
300
|
-
return this.queue.getJobCountByTypes('paused');
|
301
|
-
}
|
302
|
-
/**
|
303
|
-
* Returns a promise that resolves with the quantity of active jobs.
|
304
|
-
*/
|
305
|
-
getActiveCount() {
|
306
|
-
return this.queue.getActiveCount();
|
307
|
-
}
|
308
|
-
/**
|
309
|
-
* Returns a promise that resolves to the quantity of repeatable jobs.
|
310
|
-
*/
|
311
|
-
async getRepeatableCount() {
|
312
|
-
const repeat = await this.queue.repeat;
|
313
|
-
return repeat.getRepeatableCount();
|
314
|
-
}
|
315
|
-
/**
|
316
|
-
* Tells the queue remove all jobs created outside of a grace period in milliseconds.
|
317
|
-
* You can clean the jobs with the following states: completed, wait (typo for waiting), active, delayed, and failed.
|
318
|
-
* @param grace - Grace period in milliseconds.
|
319
|
-
* @param limit - Maximum amount of jobs to clean per call. If not provided will clean all matching jobs.
|
320
|
-
* @param type - Status of the job to clean. Values are completed, wait,
|
321
|
-
* active, paused, delayed, and failed. Defaults to completed.
|
322
|
-
*/
|
323
|
-
clean(grace, limit, type = 'completed') {
|
324
|
-
return this.queue.clean(grace, limit, type);
|
325
|
-
}
|
326
|
-
on(event, listener) {
|
327
|
-
return this.attachListener(false, event, listener);
|
328
|
-
}
|
329
|
-
once(event, listener) {
|
330
|
-
return this.attachListener(true, event, listener);
|
331
|
-
}
|
332
|
-
off(event, listener) {
|
333
|
-
return this.detachListener(event, listener);
|
334
|
-
}
|
335
|
-
removeListener(event, listener) {
|
336
|
-
if (!listener) {
|
337
|
-
throw new Error('listener is required');
|
338
|
-
}
|
339
|
-
return this.detachListener(event, listener);
|
340
|
-
}
|
341
|
-
removeAllListeners(event) {
|
342
|
-
return this.detachListener(event);
|
343
|
-
}
|
344
|
-
/**
|
345
|
-
* Set clientName to Redis.client
|
346
|
-
*/
|
347
|
-
setWorkerName() {
|
348
|
-
throw new Error('Not supported');
|
349
|
-
}
|
350
|
-
/**
|
351
|
-
* Returns Redis clients array which belongs to current Queue
|
352
|
-
*/
|
353
|
-
getWorkers() {
|
354
|
-
return this.queue.getWorkers();
|
355
|
-
}
|
356
|
-
/**
|
357
|
-
* Returns Queue name in base64 encoded format
|
358
|
-
*/
|
359
|
-
base64Name() {
|
360
|
-
return this.queue.base64Name();
|
361
|
-
}
|
362
|
-
/**
|
363
|
-
* Returns Queue name with keyPrefix (default: 'bull')
|
364
|
-
*/
|
365
|
-
clientName() {
|
366
|
-
return this.queue.clientName();
|
367
|
-
}
|
368
|
-
/**
|
369
|
-
* Returns Redis clients array which belongs to current Queue from string with all redis clients
|
370
|
-
*
|
371
|
-
* @param list - String with all redis clients
|
372
|
-
*/
|
373
|
-
parseClientList(list) {
|
374
|
-
return this.queue.parseClientList(list);
|
375
|
-
}
|
376
|
-
retryJob(job) {
|
377
|
-
return job.retry();
|
378
|
-
}
|
379
|
-
getQueueEvents() {
|
380
|
-
if (!this.queueEvents) {
|
381
|
-
this.queueEvents = new queue_events_1.QueueEvents(this.name, this.opts);
|
382
|
-
}
|
383
|
-
return this.queueEvents;
|
384
|
-
}
|
385
|
-
ensureWorkerCreated() {
|
386
|
-
if (!this.worker) {
|
387
|
-
throw new Error('You should create internal ' +
|
388
|
-
'worker by calling progress() ' +
|
389
|
-
'prior to attach listeners to worker events');
|
390
|
-
}
|
391
|
-
}
|
392
|
-
attachListener(once, event, listener) {
|
393
|
-
switch (event) {
|
394
|
-
case 'active':
|
395
|
-
this.ensureWorkerCreated();
|
396
|
-
if (once) {
|
397
|
-
this.worker.once('active', listener);
|
398
|
-
}
|
399
|
-
else {
|
400
|
-
this.worker.on('active', listener);
|
401
|
-
}
|
402
|
-
break;
|
403
|
-
case 'completed':
|
404
|
-
this.ensureWorkerCreated();
|
405
|
-
if (once) {
|
406
|
-
this.worker.once('completed', listener);
|
407
|
-
}
|
408
|
-
else {
|
409
|
-
this.worker.on('completed', listener);
|
410
|
-
}
|
411
|
-
break;
|
412
|
-
case 'drained':
|
413
|
-
this.ensureWorkerCreated();
|
414
|
-
if (once) {
|
415
|
-
this.worker.once('drained', listener);
|
416
|
-
}
|
417
|
-
else {
|
418
|
-
this.worker.on('drained', listener);
|
419
|
-
}
|
420
|
-
break;
|
421
|
-
case 'failed':
|
422
|
-
this.ensureWorkerCreated();
|
423
|
-
if (once) {
|
424
|
-
this.worker.once('failed', listener);
|
425
|
-
}
|
426
|
-
else {
|
427
|
-
this.worker.on('failed', listener);
|
428
|
-
}
|
429
|
-
break;
|
430
|
-
case 'paused':
|
431
|
-
if (once) {
|
432
|
-
this.queue.once('paused', listener);
|
433
|
-
}
|
434
|
-
else {
|
435
|
-
this.queue.on('paused', listener);
|
436
|
-
}
|
437
|
-
break;
|
438
|
-
case 'resumed':
|
439
|
-
if (once) {
|
440
|
-
this.queue.once('resumed', listener);
|
441
|
-
}
|
442
|
-
else {
|
443
|
-
this.queue.on('resumed', listener);
|
444
|
-
}
|
445
|
-
break;
|
446
|
-
case 'progress':
|
447
|
-
if (once) {
|
448
|
-
this.queue.once('progress', listener);
|
449
|
-
}
|
450
|
-
else {
|
451
|
-
this.queue.on('progress', listener);
|
452
|
-
}
|
453
|
-
break;
|
454
|
-
case 'waiting':
|
455
|
-
if (once) {
|
456
|
-
this.queue.once('waiting', listener);
|
457
|
-
}
|
458
|
-
else {
|
459
|
-
this.queue.on('waiting', listener);
|
460
|
-
}
|
461
|
-
break;
|
462
|
-
case 'global:active':
|
463
|
-
if (once) {
|
464
|
-
this.getQueueEvents().once('active', listener);
|
465
|
-
}
|
466
|
-
else {
|
467
|
-
this.getQueueEvents().on('active', listener);
|
468
|
-
}
|
469
|
-
break;
|
470
|
-
case 'global:completed':
|
471
|
-
if (once) {
|
472
|
-
this.getQueueEvents().once('completed', listener);
|
473
|
-
}
|
474
|
-
else {
|
475
|
-
this.getQueueEvents().on('completed', listener);
|
476
|
-
}
|
477
|
-
break;
|
478
|
-
case 'global:drained':
|
479
|
-
if (once) {
|
480
|
-
this.getQueueEvents().once('drained', listener);
|
481
|
-
}
|
482
|
-
else {
|
483
|
-
this.getQueueEvents().on('drained', listener);
|
484
|
-
}
|
485
|
-
break;
|
486
|
-
case 'global:failed':
|
487
|
-
if (once) {
|
488
|
-
this.getQueueEvents().once('failed', listener);
|
489
|
-
}
|
490
|
-
else {
|
491
|
-
this.getQueueEvents().on('failed', listener);
|
492
|
-
}
|
493
|
-
break;
|
494
|
-
case 'global:paused':
|
495
|
-
if (once) {
|
496
|
-
this.getQueueEvents().once('paused', listener);
|
497
|
-
}
|
498
|
-
else {
|
499
|
-
this.getQueueEvents().on('paused', listener);
|
500
|
-
}
|
501
|
-
break;
|
502
|
-
case 'global:resumed':
|
503
|
-
if (once) {
|
504
|
-
this.getQueueEvents().once('resumed', listener);
|
505
|
-
}
|
506
|
-
else {
|
507
|
-
this.getQueueEvents().on('resumed', listener);
|
508
|
-
}
|
509
|
-
break;
|
510
|
-
case 'global:progress':
|
511
|
-
if (once) {
|
512
|
-
this.getQueueEvents().once('progress', listener);
|
513
|
-
}
|
514
|
-
else {
|
515
|
-
this.getQueueEvents().on('progress', listener);
|
516
|
-
}
|
517
|
-
break;
|
518
|
-
case 'global:waiting':
|
519
|
-
if (once) {
|
520
|
-
this.getQueueEvents().once('waiting', listener);
|
521
|
-
}
|
522
|
-
else {
|
523
|
-
this.getQueueEvents().on('waiting', listener);
|
524
|
-
}
|
525
|
-
break;
|
526
|
-
default:
|
527
|
-
throw new Error(`Listening on '${String(event)}' event is not supported`);
|
528
|
-
}
|
529
|
-
return this;
|
530
|
-
}
|
531
|
-
detachListener(event, listener) {
|
532
|
-
switch (event) {
|
533
|
-
case 'active':
|
534
|
-
if (this.worker) {
|
535
|
-
if (listener) {
|
536
|
-
this.worker.removeListener('active', listener);
|
537
|
-
}
|
538
|
-
else {
|
539
|
-
this.worker.removeAllListeners('active');
|
540
|
-
}
|
541
|
-
}
|
542
|
-
break;
|
543
|
-
case 'completed':
|
544
|
-
if (this.worker) {
|
545
|
-
if (listener) {
|
546
|
-
this.worker.removeListener('completed', listener);
|
547
|
-
}
|
548
|
-
else {
|
549
|
-
this.worker.removeAllListeners('completed');
|
550
|
-
}
|
551
|
-
}
|
552
|
-
break;
|
553
|
-
case 'drained':
|
554
|
-
if (this.worker) {
|
555
|
-
if (listener) {
|
556
|
-
this.worker.removeListener('drained', listener);
|
557
|
-
}
|
558
|
-
else {
|
559
|
-
this.worker.removeAllListeners('drained');
|
560
|
-
}
|
561
|
-
}
|
562
|
-
break;
|
563
|
-
case 'failed':
|
564
|
-
if (this.worker) {
|
565
|
-
if (listener) {
|
566
|
-
this.worker.removeListener('failed', listener);
|
567
|
-
}
|
568
|
-
else {
|
569
|
-
this.worker.removeAllListeners('failed');
|
570
|
-
}
|
571
|
-
}
|
572
|
-
break;
|
573
|
-
case 'paused':
|
574
|
-
if (listener) {
|
575
|
-
this.queue.removeListener('paused', listener);
|
576
|
-
}
|
577
|
-
else {
|
578
|
-
this.queue.removeAllListeners('paused');
|
579
|
-
}
|
580
|
-
break;
|
581
|
-
case 'resumed':
|
582
|
-
if (listener) {
|
583
|
-
this.queue.removeListener('resumed', listener);
|
584
|
-
}
|
585
|
-
else {
|
586
|
-
this.queue.removeAllListeners('resumed');
|
587
|
-
}
|
588
|
-
break;
|
589
|
-
case 'progress':
|
590
|
-
if (listener) {
|
591
|
-
this.queue.removeListener('progress', listener);
|
592
|
-
}
|
593
|
-
else {
|
594
|
-
this.queue.removeAllListeners('progress');
|
595
|
-
}
|
596
|
-
break;
|
597
|
-
case 'waiting':
|
598
|
-
if (listener) {
|
599
|
-
this.queue.removeListener('waiting', listener);
|
600
|
-
}
|
601
|
-
else {
|
602
|
-
this.queue.removeAllListeners('waiting');
|
603
|
-
}
|
604
|
-
break;
|
605
|
-
case 'global:active':
|
606
|
-
if (this.queueEvents) {
|
607
|
-
if (listener) {
|
608
|
-
this.queueEvents.removeListener('active', listener);
|
609
|
-
}
|
610
|
-
else {
|
611
|
-
this.queueEvents.removeAllListeners('active');
|
612
|
-
}
|
613
|
-
}
|
614
|
-
break;
|
615
|
-
case 'global:completed':
|
616
|
-
if (this.queueEvents) {
|
617
|
-
if (listener) {
|
618
|
-
this.queueEvents.removeListener('completed', listener);
|
619
|
-
}
|
620
|
-
else {
|
621
|
-
this.queueEvents.removeAllListeners('completed');
|
622
|
-
}
|
623
|
-
}
|
624
|
-
break;
|
625
|
-
case 'global:drained':
|
626
|
-
if (this.queueEvents) {
|
627
|
-
if (listener) {
|
628
|
-
this.queueEvents.removeListener('drained', listener);
|
629
|
-
}
|
630
|
-
else {
|
631
|
-
this.queueEvents.removeAllListeners('drained');
|
632
|
-
}
|
633
|
-
}
|
634
|
-
break;
|
635
|
-
case 'global:failed':
|
636
|
-
if (this.queueEvents) {
|
637
|
-
if (listener) {
|
638
|
-
this.queueEvents.removeListener('failed', listener);
|
639
|
-
}
|
640
|
-
else {
|
641
|
-
this.queueEvents.removeAllListeners('failed');
|
642
|
-
}
|
643
|
-
}
|
644
|
-
break;
|
645
|
-
case 'global:paused':
|
646
|
-
if (this.queueEvents) {
|
647
|
-
if (listener) {
|
648
|
-
this.queueEvents.removeListener('paused', listener);
|
649
|
-
}
|
650
|
-
else {
|
651
|
-
this.queueEvents.removeAllListeners('paused');
|
652
|
-
}
|
653
|
-
}
|
654
|
-
break;
|
655
|
-
case 'global:resumed':
|
656
|
-
if (this.queueEvents) {
|
657
|
-
if (listener) {
|
658
|
-
this.queueEvents.removeListener('resumed', listener);
|
659
|
-
}
|
660
|
-
else {
|
661
|
-
this.queueEvents.removeAllListeners('resumed');
|
662
|
-
}
|
663
|
-
}
|
664
|
-
break;
|
665
|
-
case 'global:waiting':
|
666
|
-
if (this.queueEvents) {
|
667
|
-
if (listener) {
|
668
|
-
this.queueEvents.removeListener('waiting', listener);
|
669
|
-
}
|
670
|
-
else {
|
671
|
-
this.queueEvents.removeAllListeners('waiting');
|
672
|
-
}
|
673
|
-
}
|
674
|
-
break;
|
675
|
-
default:
|
676
|
-
break;
|
677
|
-
}
|
678
|
-
return this;
|
679
|
-
}
|
680
|
-
}
|
681
|
-
exports.Queue3 = Queue3;
|
682
|
-
//# sourceMappingURL=compat.js.map
|