bullmq 3.6.0 → 3.6.2
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/redis-connection.js +2 -2
- package/dist/cjs/classes/redis-connection.js.map +1 -1
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -0
- package/dist/esm/classes/redis-connection.js +2 -2
- package/dist/esm/classes/redis-connection.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/dist/{cjs → types}/classes/backoffs.d.ts +0 -0
- package/dist/{cjs → types}/classes/child-pool.d.ts +0 -0
- package/dist/{cjs → types}/classes/child-processor.d.ts +0 -0
- package/dist/{cjs → types}/classes/flow-producer.d.ts +0 -0
- package/dist/{cjs → types}/classes/index.d.ts +0 -0
- package/dist/{cjs → types}/classes/job.d.ts +0 -0
- package/dist/{cjs → types}/classes/master.d.ts +0 -0
- package/dist/{cjs → types}/classes/process-utils.d.ts +0 -0
- package/dist/{cjs → types}/classes/queue-base.d.ts +0 -0
- package/dist/{cjs → types}/classes/queue-events.d.ts +0 -0
- package/dist/{cjs → types}/classes/queue-getters.d.ts +0 -0
- package/dist/{cjs → types}/classes/queue-keys.d.ts +0 -0
- package/dist/{cjs → types}/classes/queue.d.ts +0 -0
- package/dist/{cjs → types}/classes/redis-connection.d.ts +0 -0
- package/dist/{cjs → types}/classes/repeat.d.ts +0 -0
- package/dist/{cjs → types}/classes/sandbox.d.ts +0 -0
- package/dist/{cjs → types}/classes/scripts.d.ts +0 -0
- package/dist/{cjs → types}/classes/timer-manager.d.ts +0 -0
- package/dist/{cjs → types}/classes/unrecoverable-error.d.ts +0 -0
- package/dist/{cjs → types}/classes/worker.d.ts +0 -0
- package/dist/{cjs → types}/commands/index.d.ts +0 -0
- package/dist/{cjs → types}/commands/script-loader.d.ts +0 -0
- package/dist/{cjs → types}/enums/error-code.enum.d.ts +0 -0
- package/dist/{cjs → types}/enums/index.d.ts +0 -0
- package/dist/{cjs → types}/enums/metrics-time.d.ts +0 -0
- package/dist/{cjs → types}/index.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/advanced-options.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/backoff-options.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/base-job-options.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/child-command.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/child-message.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/connection.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/flow-job.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/index.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/ioredis-events.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/job-json.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/keep-jobs.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/metrics-options.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/metrics.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/minimal-job.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/parent-command.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/parent-message.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/parent.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/queue-options.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/rate-limiter-options.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/redis-options.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/redis-streams.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/repeat-options.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/sandboxed-job-processor.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/sandboxed-job.d.ts +0 -0
- package/dist/{cjs → types}/interfaces/worker-options.d.ts +0 -0
- package/dist/{cjs → types}/scripts/addJob-8.d.ts +0 -0
- package/dist/{cjs → types}/scripts/changeDelay-3.d.ts +0 -0
- package/dist/{cjs → types}/scripts/cleanJobsInSet-2.d.ts +0 -0
- package/dist/{cjs → types}/scripts/drain-4.d.ts +0 -0
- package/dist/{cjs → types}/scripts/extendLock-2.d.ts +0 -0
- package/dist/{cjs → types}/scripts/getCounts-1.d.ts +0 -0
- package/dist/{cjs → types}/scripts/getRanges-1.d.ts +0 -0
- package/dist/{cjs → types}/scripts/getState-7.d.ts +0 -0
- package/dist/{cjs → types}/scripts/getStateV2-7.d.ts +0 -0
- package/dist/{cjs → types}/scripts/index.d.ts +0 -0
- package/dist/{cjs → types}/scripts/isFinished-3.d.ts +0 -0
- package/dist/{cjs → types}/scripts/isJobInList-1.d.ts +0 -0
- package/dist/{cjs → types}/scripts/moveJobFromActiveToWait-4.d.ts +0 -0
- package/dist/{cjs → types}/scripts/moveStalledJobsToWait-8.d.ts +0 -0
- package/dist/{cjs → types}/scripts/moveToActive-9.d.ts +0 -0
- package/dist/{cjs → types}/scripts/moveToDelayed-8.d.ts +0 -0
- package/dist/{cjs → types}/scripts/moveToFinished-12.d.ts +0 -0
- package/dist/{cjs → types}/scripts/moveToWaitingChildren-4.d.ts +0 -0
- package/dist/{cjs → types}/scripts/obliterate-2.d.ts +0 -0
- package/dist/{cjs → types}/scripts/pause-4.d.ts +0 -0
- package/dist/{cjs → types}/scripts/promote-6.d.ts +0 -0
- package/dist/{cjs → types}/scripts/releaseLock-1.d.ts +0 -0
- package/dist/{cjs → types}/scripts/removeJob-1.d.ts +0 -0
- package/dist/{cjs → types}/scripts/removeRepeatable-2.d.ts +0 -0
- package/dist/{cjs → types}/scripts/reprocessJob-4.d.ts +0 -0
- package/dist/{cjs → types}/scripts/retryJob-8.d.ts +0 -0
- package/dist/{cjs → types}/scripts/retryJobs-6.d.ts +0 -0
- package/dist/{cjs → types}/scripts/takeLock-1.d.ts +0 -0
- package/dist/{cjs → types}/scripts/updateData-1.d.ts +0 -0
- package/dist/{cjs → types}/scripts/updateProgress-2.d.ts +0 -0
- package/dist/{cjs → types}/types/backoff-strategy.d.ts +0 -0
- package/dist/{cjs → types}/types/finished-status.d.ts +0 -0
- package/dist/{cjs → types}/types/index.d.ts +0 -0
- package/dist/{cjs → types}/types/job-json-sandbox.d.ts +0 -0
- package/dist/{cjs → types}/types/job-options.d.ts +0 -0
- package/dist/{cjs → types}/types/job-type.d.ts +0 -0
- package/dist/{cjs → types}/types/minimal-queue.d.ts +0 -0
- package/dist/{cjs → types}/types/repeat-strategy.d.ts +0 -0
- package/dist/{cjs → types}/utils.d.ts +0 -0
- package/package.json +3 -3
- package/dist/esm/classes/backoffs.d.ts +0 -11
- package/dist/esm/classes/child-pool.d.ts +0 -22
- package/dist/esm/classes/child-processor.d.ts +0 -24
- package/dist/esm/classes/flow-producer.d.ts +0 -163
- package/dist/esm/classes/index.d.ts +0 -18
- package/dist/esm/classes/job.d.ts +0 -341
- package/dist/esm/classes/master.d.ts +0 -1
- package/dist/esm/classes/process-utils.d.ts +0 -7
- package/dist/esm/classes/queue-base.d.ts +0 -67
- package/dist/esm/classes/queue-events.d.ts +0 -179
- package/dist/esm/classes/queue-getters.d.ts +0 -164
- package/dist/esm/classes/queue-keys.d.ts +0 -10
- package/dist/esm/classes/queue.d.ts +0 -232
- package/dist/esm/classes/redis-connection.d.ts +0 -38
- package/dist/esm/classes/repeat.d.ts +0 -25
- package/dist/esm/classes/sandbox.d.ts +0 -4
- package/dist/esm/classes/scripts.d.ts +0 -101
- package/dist/esm/classes/timer-manager.d.ts +0 -17
- package/dist/esm/classes/unrecoverable-error.d.ts +0 -10
- package/dist/esm/classes/worker.d.ts +0 -196
- package/dist/esm/commands/index.d.ts +0 -4
- package/dist/esm/commands/script-loader.d.ts +0 -120
- package/dist/esm/enums/error-code.enum.d.ts +0 -8
- package/dist/esm/enums/index.d.ts +0 -2
- package/dist/esm/enums/metrics-time.d.ts +0 -10
- package/dist/esm/index.d.ts +0 -6
- package/dist/esm/interfaces/advanced-options.d.ts +0 -13
- package/dist/esm/interfaces/backoff-options.d.ts +0 -15
- package/dist/esm/interfaces/base-job-options.d.ts +0 -92
- package/dist/esm/interfaces/child-command.d.ts +0 -5
- package/dist/esm/interfaces/child-message.d.ts +0 -6
- package/dist/esm/interfaces/connection.d.ts +0 -8
- package/dist/esm/interfaces/flow-job.d.ts +0 -20
- package/dist/esm/interfaces/index.d.ts +0 -24
- package/dist/esm/interfaces/ioredis-events.d.ts +0 -8
- package/dist/esm/interfaces/job-json.d.ts +0 -37
- package/dist/esm/interfaces/keep-jobs.d.ts +0 -17
- package/dist/esm/interfaces/metrics-options.d.ts +0 -12
- package/dist/esm/interfaces/metrics.d.ts +0 -9
- package/dist/esm/interfaces/minimal-job.d.ts +0 -129
- package/dist/esm/interfaces/parent-command.d.ts +0 -10
- package/dist/esm/interfaces/parent-message.d.ts +0 -8
- package/dist/esm/interfaces/parent.d.ts +0 -20
- package/dist/esm/interfaces/queue-options.d.ts +0 -74
- package/dist/esm/interfaces/rate-limiter-options.d.ts +0 -12
- package/dist/esm/interfaces/redis-options.d.ts +0 -8
- package/dist/esm/interfaces/redis-streams.d.ts +0 -4
- package/dist/esm/interfaces/repeat-options.d.ts +0 -33
- package/dist/esm/interfaces/sandboxed-job-processor.d.ts +0 -5
- package/dist/esm/interfaces/sandboxed-job.d.ts +0 -13
- package/dist/esm/interfaces/worker-options.d.ts +0 -51
- package/dist/esm/scripts/addJob-8.d.ts +0 -5
- package/dist/esm/scripts/changeDelay-3.d.ts +0 -5
- package/dist/esm/scripts/cleanJobsInSet-2.d.ts +0 -5
- package/dist/esm/scripts/drain-4.d.ts +0 -5
- package/dist/esm/scripts/extendLock-2.d.ts +0 -5
- package/dist/esm/scripts/getCounts-1.d.ts +0 -5
- package/dist/esm/scripts/getRanges-1.d.ts +0 -5
- package/dist/esm/scripts/getState-7.d.ts +0 -5
- package/dist/esm/scripts/getStateV2-7.d.ts +0 -5
- package/dist/esm/scripts/index.d.ts +0 -29
- package/dist/esm/scripts/isFinished-3.d.ts +0 -5
- package/dist/esm/scripts/isJobInList-1.d.ts +0 -5
- package/dist/esm/scripts/moveJobFromActiveToWait-4.d.ts +0 -5
- package/dist/esm/scripts/moveStalledJobsToWait-8.d.ts +0 -5
- package/dist/esm/scripts/moveToActive-9.d.ts +0 -5
- package/dist/esm/scripts/moveToDelayed-8.d.ts +0 -5
- package/dist/esm/scripts/moveToFinished-12.d.ts +0 -5
- package/dist/esm/scripts/moveToWaitingChildren-4.d.ts +0 -5
- package/dist/esm/scripts/obliterate-2.d.ts +0 -5
- package/dist/esm/scripts/pause-4.d.ts +0 -5
- package/dist/esm/scripts/promote-6.d.ts +0 -5
- package/dist/esm/scripts/releaseLock-1.d.ts +0 -5
- package/dist/esm/scripts/removeJob-1.d.ts +0 -5
- package/dist/esm/scripts/removeRepeatable-2.d.ts +0 -5
- package/dist/esm/scripts/reprocessJob-4.d.ts +0 -5
- package/dist/esm/scripts/retryJob-8.d.ts +0 -5
- package/dist/esm/scripts/retryJobs-6.d.ts +0 -5
- package/dist/esm/scripts/takeLock-1.d.ts +0 -5
- package/dist/esm/scripts/updateData-1.d.ts +0 -5
- package/dist/esm/scripts/updateProgress-2.d.ts +0 -5
- package/dist/esm/types/backoff-strategy.d.ts +0 -2
- package/dist/esm/types/finished-status.d.ts +0 -2
- package/dist/esm/types/index.d.ts +0 -7
- package/dist/esm/types/job-json-sandbox.d.ts +0 -5
- package/dist/esm/types/job-options.d.ts +0 -16
- package/dist/esm/types/job-type.d.ts +0 -3
- package/dist/esm/types/minimal-queue.d.ts +0 -2
- package/dist/esm/types/repeat-strategy.d.ts +0 -2
- package/dist/esm/utils.d.ts +0 -43
@@ -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
|
-
}
|
@@ -1,179 +0,0 @@
|
|
1
|
-
import { IoredisListener, QueueEventsOptions } from '../interfaces';
|
2
|
-
import { QueueBase } from './queue-base';
|
3
|
-
import { RedisConnection } from './redis-connection';
|
4
|
-
export interface QueueEventsListener extends IoredisListener {
|
5
|
-
/**
|
6
|
-
* Listen to 'active' event.
|
7
|
-
*
|
8
|
-
* This event is triggered when a job enters the 'active' state.
|
9
|
-
*/
|
10
|
-
active: (args: {
|
11
|
-
jobId: string;
|
12
|
-
prev?: string;
|
13
|
-
}, id: string) => void;
|
14
|
-
/**
|
15
|
-
* Listen to 'added' event.
|
16
|
-
*
|
17
|
-
* This event is triggered when a job is created.
|
18
|
-
*/
|
19
|
-
added: (args: {
|
20
|
-
jobId: string;
|
21
|
-
name: string;
|
22
|
-
}, id: string) => void;
|
23
|
-
/**
|
24
|
-
* Listen to 'cleaned' event.
|
25
|
-
*
|
26
|
-
* This event is triggered when a cleaned method is triggered.
|
27
|
-
*/
|
28
|
-
cleaned: (args: {
|
29
|
-
count: string;
|
30
|
-
}, id: string) => void;
|
31
|
-
/**
|
32
|
-
* Listen to 'completed' event.
|
33
|
-
*
|
34
|
-
* This event is triggered when a job has successfully completed.
|
35
|
-
*/
|
36
|
-
completed: (args: {
|
37
|
-
jobId: string;
|
38
|
-
returnvalue: string;
|
39
|
-
prev?: string;
|
40
|
-
}, id: string) => void;
|
41
|
-
/**
|
42
|
-
* Listen to 'delayed' event.
|
43
|
-
*
|
44
|
-
* This event is triggered when a job is delayed.
|
45
|
-
*/
|
46
|
-
delayed: (args: {
|
47
|
-
jobId: string;
|
48
|
-
delay: number;
|
49
|
-
}, id: string) => void;
|
50
|
-
/**
|
51
|
-
* Listen to 'drained' event.
|
52
|
-
*
|
53
|
-
* This event is triggered when the queue has drained the waiting list.
|
54
|
-
* Note that there could still be delayed jobs waiting their timers to expire
|
55
|
-
* and this event will still be triggered as long as the waiting list has emptied.
|
56
|
-
*/
|
57
|
-
drained: (id: string) => void;
|
58
|
-
/**
|
59
|
-
* Listen to 'duplicated' event.
|
60
|
-
*
|
61
|
-
* This event is triggered when a job is not created because it already exist.
|
62
|
-
*/
|
63
|
-
duplicated: (args: {
|
64
|
-
jobId: string;
|
65
|
-
}, id: string) => void;
|
66
|
-
/**
|
67
|
-
* Listen to 'error' event.
|
68
|
-
*
|
69
|
-
* This event is triggered when an exception is thrown.
|
70
|
-
*/
|
71
|
-
error: (args: Error) => void;
|
72
|
-
/**
|
73
|
-
* Listen to 'failed' event.
|
74
|
-
*
|
75
|
-
* This event is triggered when a job has thrown an exception.
|
76
|
-
*/
|
77
|
-
failed: (args: {
|
78
|
-
jobId: string;
|
79
|
-
failedReason: string;
|
80
|
-
prev?: string;
|
81
|
-
}, id: string) => void;
|
82
|
-
/**
|
83
|
-
* Listen to 'paused' event.
|
84
|
-
*
|
85
|
-
* This event is triggered when a queue is paused.
|
86
|
-
*/
|
87
|
-
paused: (args: {}, id: string) => void;
|
88
|
-
/**
|
89
|
-
* Listen to 'progress' event.
|
90
|
-
*
|
91
|
-
* This event is triggered when a job updates it progress, i.e. the
|
92
|
-
* Job##updateProgress() method is called. This is useful to notify
|
93
|
-
* progress or any other data from within a processor to the rest of the
|
94
|
-
* world.
|
95
|
-
*/
|
96
|
-
progress: (args: {
|
97
|
-
jobId: string;
|
98
|
-
data: number | object;
|
99
|
-
}, id: string) => void;
|
100
|
-
/**
|
101
|
-
* Listen to 'removed' event.
|
102
|
-
*
|
103
|
-
* This event is triggered when a job has been manually
|
104
|
-
* removed from the queue.
|
105
|
-
*/
|
106
|
-
removed: (args: {
|
107
|
-
jobId: string;
|
108
|
-
prev: string;
|
109
|
-
}, id: string) => void;
|
110
|
-
/**
|
111
|
-
* Listen to 'resumed' event.
|
112
|
-
*
|
113
|
-
* This event is triggered when a queue is resumed.
|
114
|
-
*/
|
115
|
-
resumed: (args: {}, id: string) => void;
|
116
|
-
/**
|
117
|
-
* Listen to 'retries-exhausted' event.
|
118
|
-
*
|
119
|
-
* This event is triggered when a job has retried the maximum attempts.
|
120
|
-
*/
|
121
|
-
'retries-exhausted': (args: {
|
122
|
-
jobId: string;
|
123
|
-
attemptsMade: string;
|
124
|
-
}, id: string) => void;
|
125
|
-
/**
|
126
|
-
* Listen to 'stalled' event.
|
127
|
-
*
|
128
|
-
* This event is triggered when a job has been moved from 'active' back
|
129
|
-
* to 'waiting'/'failed' due to the processor not being able to renew
|
130
|
-
* the lock on the said job.
|
131
|
-
*/
|
132
|
-
stalled: (args: {
|
133
|
-
jobId: string;
|
134
|
-
}, id: string) => void;
|
135
|
-
/**
|
136
|
-
* Listen to 'waiting' event.
|
137
|
-
*
|
138
|
-
* This event is triggered when a job enters the 'waiting' state.
|
139
|
-
*/
|
140
|
-
waiting: (args: {
|
141
|
-
jobId: string;
|
142
|
-
prev?: string;
|
143
|
-
}, id: string) => void;
|
144
|
-
/**
|
145
|
-
* Listen to 'waiting-children' event.
|
146
|
-
*
|
147
|
-
* This event is triggered when a job enters the 'waiting-children' state.
|
148
|
-
*/
|
149
|
-
'waiting-children': (args: {
|
150
|
-
jobId: string;
|
151
|
-
}, id: string) => void;
|
152
|
-
}
|
153
|
-
/**
|
154
|
-
* The QueueEvents class is used for listening to the global events
|
155
|
-
* emitted by a given queue.
|
156
|
-
*
|
157
|
-
* This class requires a dedicated redis connection.
|
158
|
-
*
|
159
|
-
*/
|
160
|
-
export declare class QueueEvents extends QueueBase {
|
161
|
-
private running;
|
162
|
-
constructor(name: string, { connection, autorun, ...opts }?: QueueEventsOptions, Connection?: typeof RedisConnection);
|
163
|
-
emit<U extends keyof QueueEventsListener>(event: U, ...args: Parameters<QueueEventsListener[U]>): boolean;
|
164
|
-
off<U extends keyof QueueEventsListener>(eventName: U, listener: QueueEventsListener[U]): this;
|
165
|
-
on<U extends keyof QueueEventsListener>(event: U, listener: QueueEventsListener[U]): this;
|
166
|
-
once<U extends keyof QueueEventsListener>(event: U, listener: QueueEventsListener[U]): this;
|
167
|
-
/**
|
168
|
-
* Manually starts running the event consumming loop. This shall be used if you do not
|
169
|
-
* use the default "autorun" option on the constructor.
|
170
|
-
*/
|
171
|
-
run(): Promise<void>;
|
172
|
-
private consumeEvents;
|
173
|
-
/**
|
174
|
-
* Stops consuming events and close the underlying Redis connection if necessary.
|
175
|
-
*
|
176
|
-
* @returns
|
177
|
-
*/
|
178
|
-
close(): Promise<void>;
|
179
|
-
}
|
@@ -1,164 +0,0 @@
|
|
1
|
-
import { QueueBase } from './queue-base';
|
2
|
-
import { Job } from './job';
|
3
|
-
import { JobState, JobType } from '../types';
|
4
|
-
import { Metrics } from '../interfaces';
|
5
|
-
/**
|
6
|
-
*
|
7
|
-
* @class QueueGetters
|
8
|
-
* @extends QueueBase
|
9
|
-
*
|
10
|
-
* @description Provides different getters for different aspects of a queue.
|
11
|
-
*/
|
12
|
-
export declare class QueueGetters<DataType, ResultType, NameType extends string> extends QueueBase {
|
13
|
-
getJob(jobId: string): Promise<Job<DataType, ResultType, NameType> | undefined>;
|
14
|
-
private commandByType;
|
15
|
-
/**
|
16
|
-
* Helper to easily extend Job class calls.
|
17
|
-
*/
|
18
|
-
protected get Job(): typeof Job;
|
19
|
-
private sanitizeJobTypes;
|
20
|
-
/**
|
21
|
-
Returns the number of jobs waiting to be processed. This includes jobs that are "waiting" or "delayed".
|
22
|
-
*/
|
23
|
-
count(): Promise<number>;
|
24
|
-
/**
|
25
|
-
* Job counts by type
|
26
|
-
*
|
27
|
-
* Queue#getJobCountByTypes('completed') => completed count
|
28
|
-
* Queue#getJobCountByTypes('completed,failed') => completed + failed count
|
29
|
-
* Queue#getJobCountByTypes('completed', 'failed') => completed + failed count
|
30
|
-
* Queue#getJobCountByTypes('completed', 'waiting', 'failed') => completed + waiting + failed count
|
31
|
-
*/
|
32
|
-
getJobCountByTypes(...types: JobType[]): Promise<number>;
|
33
|
-
/**
|
34
|
-
* Returns the job counts for each type specified or every list/set in the queue by default.
|
35
|
-
*
|
36
|
-
* @returns An object, key (type) and value (count)
|
37
|
-
*/
|
38
|
-
getJobCounts(...types: JobType[]): Promise<{
|
39
|
-
[index: string]: number;
|
40
|
-
}>;
|
41
|
-
/**
|
42
|
-
* Get current job state.
|
43
|
-
*
|
44
|
-
* @returns Returns one of these values:
|
45
|
-
* 'completed', 'failed', 'delayed', 'active', 'waiting', 'waiting-children', 'unknown'.
|
46
|
-
*/
|
47
|
-
getJobState(jobId: string): Promise<JobState | 'unknown'>;
|
48
|
-
/**
|
49
|
-
* Returns the number of jobs in completed status.
|
50
|
-
*/
|
51
|
-
getCompletedCount(): Promise<number>;
|
52
|
-
/**
|
53
|
-
* Returns the number of jobs in failed status.
|
54
|
-
*/
|
55
|
-
getFailedCount(): Promise<number>;
|
56
|
-
/**
|
57
|
-
* Returns the number of jobs in delayed status.
|
58
|
-
*/
|
59
|
-
getDelayedCount(): Promise<number>;
|
60
|
-
/**
|
61
|
-
* Returns the number of jobs in active status.
|
62
|
-
*/
|
63
|
-
getActiveCount(): Promise<number>;
|
64
|
-
/**
|
65
|
-
* Returns the number of jobs in waiting or paused statuses.
|
66
|
-
*/
|
67
|
-
getWaitingCount(): Promise<number>;
|
68
|
-
/**
|
69
|
-
* Returns the number of jobs in waiting-children status.
|
70
|
-
*/
|
71
|
-
getWaitingChildrenCount(): Promise<number>;
|
72
|
-
/**
|
73
|
-
* Returns the jobs that are in the "waiting" status.
|
74
|
-
* @param start - zero based index from where to start returning jobs.
|
75
|
-
* @param end - zero based index where to stop returning jobs.
|
76
|
-
*/
|
77
|
-
getWaiting(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
78
|
-
/**
|
79
|
-
* Returns the jobs that are in the "waiting" status.
|
80
|
-
* @param start - zero based index from where to start returning jobs.
|
81
|
-
* @param end - zero based index where to stop returning jobs.
|
82
|
-
*/
|
83
|
-
getWaitingChildren(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
84
|
-
/**
|
85
|
-
* Returns the jobs that are in the "active" status.
|
86
|
-
* @param start - zero based index from where to start returning jobs.
|
87
|
-
* @param end - zero based index where to stop returning jobs.
|
88
|
-
*/
|
89
|
-
getActive(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
90
|
-
/**
|
91
|
-
* Returns the jobs that are in the "delayed" status.
|
92
|
-
* @param start - zero based index from where to start returning jobs.
|
93
|
-
* @param end - zero based index where to stop returning jobs.
|
94
|
-
*/
|
95
|
-
getDelayed(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
96
|
-
/**
|
97
|
-
* Returns the jobs that are in the "completed" status.
|
98
|
-
* @param start - zero based index from where to start returning jobs.
|
99
|
-
* @param end - zero based index where to stop returning jobs.
|
100
|
-
*/
|
101
|
-
getCompleted(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
102
|
-
/**
|
103
|
-
* Returns the jobs that are in the "failed" status.
|
104
|
-
* @param start - zero based index from where to start returning jobs.
|
105
|
-
* @param end - zero based index where to stop returning jobs.
|
106
|
-
*/
|
107
|
-
getFailed(start?: number, end?: number): Promise<Job<DataType, ResultType, NameType>[]>;
|
108
|
-
getRanges(types: JobType[], start?: number, end?: number, asc?: boolean): Promise<string[]>;
|
109
|
-
/**
|
110
|
-
* Returns the jobs that are on the given statuses (note that JobType is synonym for job status)
|
111
|
-
* @param types - the statuses of the jobs to return.
|
112
|
-
* @param start - zero based index from where to start returning jobs.
|
113
|
-
* @param end - zero based index where to stop returning jobs.
|
114
|
-
* @param asc - if true, the jobs will be returned in ascending order.
|
115
|
-
*/
|
116
|
-
getJobs(types?: JobType[] | JobType, start?: number, end?: number, asc?: boolean): Promise<Job<DataType, ResultType, NameType>[]>;
|
117
|
-
/**
|
118
|
-
* Returns the logs for a given Job.
|
119
|
-
* @param jobId - the id of the job to get the logs for.
|
120
|
-
* @param start - zero based index from where to start returning jobs.
|
121
|
-
* @param end - zero based index where to stop returning jobs.
|
122
|
-
* @param asc - if true, the jobs will be returned in ascending order.
|
123
|
-
*/
|
124
|
-
getJobLogs(jobId: string, start?: number, end?: number, asc?: boolean): Promise<{
|
125
|
-
logs: string[];
|
126
|
-
count: number;
|
127
|
-
}>;
|
128
|
-
private baseGetClients;
|
129
|
-
/**
|
130
|
-
* Get the worker list related to the queue. i.e. all the known
|
131
|
-
* workers that are available to process jobs for this queue.
|
132
|
-
* Note: GCP does not support SETNAME, so this call will not work
|
133
|
-
*
|
134
|
-
* @returns - Returns an array with workers info.
|
135
|
-
*/
|
136
|
-
getWorkers(): Promise<{
|
137
|
-
[index: string]: string;
|
138
|
-
}[]>;
|
139
|
-
/**
|
140
|
-
* Get queue events list related to the queue.
|
141
|
-
* Note: GCP does not support SETNAME, so this call will not work
|
142
|
-
*
|
143
|
-
* @returns - Returns an array with queue events info.
|
144
|
-
*/
|
145
|
-
getQueueEvents(): Promise<{
|
146
|
-
[index: string]: string;
|
147
|
-
}[]>;
|
148
|
-
/**
|
149
|
-
* Get queue metrics related to the queue.
|
150
|
-
*
|
151
|
-
* This method returns the gathered metrics for the queue.
|
152
|
-
* The metrics are represented as an array of job counts
|
153
|
-
* per unit of time (1 minute).
|
154
|
-
*
|
155
|
-
* @param start - Start point of the metrics, where 0
|
156
|
-
* is the newest point to be returned.
|
157
|
-
* @param end - End point of the metrics, where -1 is the
|
158
|
-
* oldest point to be returned.
|
159
|
-
*
|
160
|
-
* @returns - Returns an object with queue metrics.
|
161
|
-
*/
|
162
|
-
getMetrics(type: 'completed' | 'failed', start?: number, end?: number): Promise<Metrics>;
|
163
|
-
private parseClientList;
|
164
|
-
}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
export type KeysMap = {
|
2
|
-
[index in string]: string;
|
3
|
-
};
|
4
|
-
export declare class QueueKeys {
|
5
|
-
readonly prefix: string;
|
6
|
-
constructor(prefix?: string);
|
7
|
-
getKeys(name: string): KeysMap;
|
8
|
-
toKey(name: string, type: string): string;
|
9
|
-
getPrefixedQueueName(name: string): string;
|
10
|
-
}
|
@@ -1,232 +0,0 @@
|
|
1
|
-
import { BaseJobOptions, BulkJobOptions, IoredisListener, QueueOptions, RepeatOptions } from '../interfaces';
|
2
|
-
import { FinishedStatus, JobsOptions } from '../types';
|
3
|
-
import { Job } from './job';
|
4
|
-
import { QueueGetters } from './queue-getters';
|
5
|
-
import { Repeat } from './repeat';
|
6
|
-
import { RedisConnection } from './redis-connection';
|
7
|
-
export interface ObliterateOpts {
|
8
|
-
/**
|
9
|
-
* Use force = true to force obliteration even with active jobs in the queue
|
10
|
-
* @defaultValue false
|
11
|
-
*/
|
12
|
-
force?: boolean;
|
13
|
-
/**
|
14
|
-
* Use count with the maximum number of deleted keys per iteration
|
15
|
-
* @defaultValue 1000
|
16
|
-
*/
|
17
|
-
count?: number;
|
18
|
-
}
|
19
|
-
export interface QueueListener<DataType, ResultType, NameType extends string> extends IoredisListener {
|
20
|
-
/**
|
21
|
-
* Listen to 'cleaned' event.
|
22
|
-
*
|
23
|
-
* This event is triggered when the queue calls clean method.
|
24
|
-
*/
|
25
|
-
cleaned: (jobs: string[], type: string) => void;
|
26
|
-
/**
|
27
|
-
* Listen to 'error' event.
|
28
|
-
*
|
29
|
-
* This event is triggered when an error is thrown.
|
30
|
-
*/
|
31
|
-
error: (err: Error) => void;
|
32
|
-
/**
|
33
|
-
* Listen to 'paused' event.
|
34
|
-
*
|
35
|
-
* This event is triggered when the queue is paused.
|
36
|
-
*/
|
37
|
-
paused: () => void;
|
38
|
-
/**
|
39
|
-
* Listen to 'progress' event.
|
40
|
-
*
|
41
|
-
* This event is triggered when the job updates its progress.
|
42
|
-
*/
|
43
|
-
progress: (job: Job<DataType, ResultType, NameType>, progress: number | object) => void;
|
44
|
-
/**
|
45
|
-
* Listen to 'removed' event.
|
46
|
-
*
|
47
|
-
* This event is triggered when a job is removed.
|
48
|
-
*/
|
49
|
-
removed: (job: Job<DataType, ResultType, NameType>) => void;
|
50
|
-
/**
|
51
|
-
* Listen to 'resumed' event.
|
52
|
-
*
|
53
|
-
* This event is triggered when the queue is resumed.
|
54
|
-
*/
|
55
|
-
resumed: () => void;
|
56
|
-
/**
|
57
|
-
* Listen to 'waiting' event.
|
58
|
-
*
|
59
|
-
* This event is triggered when the queue creates a new job.
|
60
|
-
*/
|
61
|
-
waiting: (job: Job<DataType, ResultType, NameType>) => void;
|
62
|
-
}
|
63
|
-
/**
|
64
|
-
* Queue
|
65
|
-
*
|
66
|
-
* This class provides methods to add jobs to a queue and some othe high-level
|
67
|
-
* administration such as pausing or deleting queues.
|
68
|
-
*
|
69
|
-
*/
|
70
|
-
export declare class Queue<DataType = any, ResultType = any, NameType extends string = string> extends QueueGetters<DataType, ResultType, NameType> {
|
71
|
-
token: string;
|
72
|
-
jobsOpts: BaseJobOptions;
|
73
|
-
private _repeat;
|
74
|
-
constructor(name: string, opts?: QueueOptions, Connection?: typeof RedisConnection);
|
75
|
-
emit<U extends keyof QueueListener<DataType, ResultType, NameType>>(event: U, ...args: Parameters<QueueListener<DataType, ResultType, NameType>[U]>): boolean;
|
76
|
-
off<U extends keyof QueueListener<DataType, ResultType, NameType>>(eventName: U, listener: QueueListener<DataType, ResultType, NameType>[U]): this;
|
77
|
-
on<U extends keyof QueueListener<DataType, ResultType, NameType>>(event: U, listener: QueueListener<DataType, ResultType, NameType>[U]): this;
|
78
|
-
once<U extends keyof QueueListener<DataType, ResultType, NameType>>(event: U, listener: QueueListener<DataType, ResultType, NameType>[U]): this;
|
79
|
-
/**
|
80
|
-
* Returns this instance current default job options.
|
81
|
-
*/
|
82
|
-
get defaultJobOptions(): JobsOptions;
|
83
|
-
get repeat(): Promise<Repeat>;
|
84
|
-
/**
|
85
|
-
* Adds a new job to the queue.
|
86
|
-
*
|
87
|
-
* @param name - Name of the job to be added to the queue,.
|
88
|
-
* @param data - Arbitrary data to append to the job.
|
89
|
-
* @param opts - Job options that affects how the job is going to be processed.
|
90
|
-
*/
|
91
|
-
add(name: NameType, data: DataType, opts?: JobsOptions): Promise<Job<DataType, ResultType, NameType>>;
|
92
|
-
/**
|
93
|
-
* Adds an array of jobs to the queue. This method may be faster than adding
|
94
|
-
* one job at a time in a sequence.
|
95
|
-
*
|
96
|
-
* @param jobs - The array of jobs to add to the queue. Each job is defined by 3
|
97
|
-
* properties, 'name', 'data' and 'opts'. They follow the same signature as 'Queue.add'.
|
98
|
-
*/
|
99
|
-
addBulk(jobs: {
|
100
|
-
name: NameType;
|
101
|
-
data: DataType;
|
102
|
-
opts?: BulkJobOptions;
|
103
|
-
}[]): Promise<Job<DataType, ResultType, NameType>[]>;
|
104
|
-
/**
|
105
|
-
* Pauses the processing of this queue globally.
|
106
|
-
*
|
107
|
-
* We use an atomic RENAME operation on the wait queue. Since
|
108
|
-
* we have blocking calls with BRPOPLPUSH on the wait queue, as long as the queue
|
109
|
-
* is renamed to 'paused', no new jobs will be processed (the current ones
|
110
|
-
* will run until finalized).
|
111
|
-
*
|
112
|
-
* Adding jobs requires a LUA script to check first if the paused list exist
|
113
|
-
* and in that case it will add it there instead of the wait list.
|
114
|
-
*/
|
115
|
-
pause(): Promise<void>;
|
116
|
-
/**
|
117
|
-
* Close the queue instance.
|
118
|
-
*
|
119
|
-
*/
|
120
|
-
close(): Promise<void>;
|
121
|
-
/**
|
122
|
-
* Resumes the processing of this queue globally.
|
123
|
-
*
|
124
|
-
* The method reverses the pause operation by resuming the processing of the
|
125
|
-
* queue.
|
126
|
-
*/
|
127
|
-
resume(): Promise<void>;
|
128
|
-
/**
|
129
|
-
* Returns true if the queue is currently paused.
|
130
|
-
*/
|
131
|
-
isPaused(): Promise<boolean>;
|
132
|
-
/**
|
133
|
-
* Get all repeatable meta jobs.
|
134
|
-
*
|
135
|
-
* @param start - Offset of first job to return.
|
136
|
-
* @param end - Offset of last job to return.
|
137
|
-
* @param asc - Determine the order in which jobs are returned based on their
|
138
|
-
* next execution time.
|
139
|
-
*/
|
140
|
-
getRepeatableJobs(start?: number, end?: number, asc?: boolean): Promise<{
|
141
|
-
key: string;
|
142
|
-
name: string;
|
143
|
-
id: string;
|
144
|
-
endDate: number;
|
145
|
-
tz: string;
|
146
|
-
pattern: string;
|
147
|
-
next: number;
|
148
|
-
}[]>;
|
149
|
-
/**
|
150
|
-
* Removes a repeatable job.
|
151
|
-
*
|
152
|
-
* Note: you need to use the exact same repeatOpts when deleting a repeatable job
|
153
|
-
* than when adding it.
|
154
|
-
*
|
155
|
-
* @see removeRepeatableByKey
|
156
|
-
*
|
157
|
-
* @param name -
|
158
|
-
* @param repeatOpts -
|
159
|
-
* @param jobId -
|
160
|
-
* @returns
|
161
|
-
*/
|
162
|
-
removeRepeatable(name: NameType, repeatOpts: RepeatOptions, jobId?: string): Promise<boolean>;
|
163
|
-
/**
|
164
|
-
* Removes a repeatable job by its key. Note that the key is the one used
|
165
|
-
* to store the repeatable job metadata and not one of the job iterations
|
166
|
-
* themselves. You can use "getRepeatableJobs" in order to get the keys.
|
167
|
-
*
|
168
|
-
* @see getRepeatableJobs
|
169
|
-
*
|
170
|
-
* @param key - to the repeatable job.
|
171
|
-
* @returns
|
172
|
-
*/
|
173
|
-
removeRepeatableByKey(key: string): Promise<boolean>;
|
174
|
-
/**
|
175
|
-
* Removes the given job from the queue as well as all its
|
176
|
-
* dependencies.
|
177
|
-
*
|
178
|
-
* @param jobId - The id of the job to remove
|
179
|
-
* @returns 1 if it managed to remove the job or 0 if the job or
|
180
|
-
* any of its dependencies were locked.
|
181
|
-
*/
|
182
|
-
remove(jobId: string): Promise<number>;
|
183
|
-
/**
|
184
|
-
* Drains the queue, i.e., removes all jobs that are waiting
|
185
|
-
* or delayed, but not active, completed or failed.
|
186
|
-
*
|
187
|
-
* @param delayed - Pass true if it should also clean the
|
188
|
-
* delayed jobs.
|
189
|
-
*/
|
190
|
-
drain(delayed?: boolean): Promise<void>;
|
191
|
-
/**
|
192
|
-
* Cleans jobs from a queue. Similar to drain but keeps jobs within a certain
|
193
|
-
* grace period.
|
194
|
-
*
|
195
|
-
* @param grace - The grace period
|
196
|
-
* @param limit - Max number of jobs to clean
|
197
|
-
* @param type - The type of job to clean
|
198
|
-
* Possible values are completed, wait, active, paused, delayed, failed. Defaults to completed.
|
199
|
-
* @returns Id jobs from the deleted records
|
200
|
-
*/
|
201
|
-
clean(grace: number, limit: number, type?: 'completed' | 'wait' | 'active' | 'paused' | 'delayed' | 'failed'): Promise<string[]>;
|
202
|
-
/**
|
203
|
-
* Completely destroys the queue and all of its contents irreversibly.
|
204
|
-
* This method will the *pause* the queue and requires that there are no
|
205
|
-
* active jobs. It is possible to bypass this requirement, i.e. not
|
206
|
-
* having active jobs using the "force" option.
|
207
|
-
*
|
208
|
-
* Note: This operation requires to iterate on all the jobs stored in the queue
|
209
|
-
* and can be slow for very large queues.
|
210
|
-
*
|
211
|
-
* @param opts - Obliterate options.
|
212
|
-
*/
|
213
|
-
obliterate(opts?: ObliterateOpts): Promise<void>;
|
214
|
-
/**
|
215
|
-
* Retry all the failed jobs.
|
216
|
-
*
|
217
|
-
* @param opts - contains number to limit how many jobs will be moved to wait status per iteration,
|
218
|
-
* state (failed, completed) failed by default or from which timestamp.
|
219
|
-
* @returns
|
220
|
-
*/
|
221
|
-
retryJobs(opts?: {
|
222
|
-
count?: number;
|
223
|
-
state?: FinishedStatus;
|
224
|
-
timestamp?: number;
|
225
|
-
}): Promise<void>;
|
226
|
-
/**
|
227
|
-
* Trim the event stream to an approximately maxLength.
|
228
|
-
*
|
229
|
-
* @param maxLength -
|
230
|
-
*/
|
231
|
-
trimEvents(maxLength: number): Promise<number>;
|
232
|
-
}
|
@@ -1,38 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { EventEmitter } from 'events';
|
3
|
-
import { ConnectionOptions, RedisClient } from '../interfaces';
|
4
|
-
export interface RawCommand {
|
5
|
-
content: string;
|
6
|
-
name: string;
|
7
|
-
keys: number;
|
8
|
-
}
|
9
|
-
export declare class RedisConnection extends EventEmitter {
|
10
|
-
private readonly shared;
|
11
|
-
private readonly blocking;
|
12
|
-
static minimumVersion: string;
|
13
|
-
static recommendedMinimumVersion: string;
|
14
|
-
closing: boolean;
|
15
|
-
protected _client: RedisClient;
|
16
|
-
private readonly opts;
|
17
|
-
private initializing;
|
18
|
-
private version;
|
19
|
-
private handleClientError;
|
20
|
-
private handleClientClose;
|
21
|
-
private handleClientReady;
|
22
|
-
constructor(opts?: ConnectionOptions, shared?: boolean, blocking?: boolean);
|
23
|
-
private checkBlockingOptions;
|
24
|
-
private checkUpstashHost;
|
25
|
-
/**
|
26
|
-
* Waits for a redis client to be ready.
|
27
|
-
* @param redis - client
|
28
|
-
*/
|
29
|
-
static waitUntilReady(client: RedisClient): Promise<void>;
|
30
|
-
get client(): Promise<RedisClient>;
|
31
|
-
protected loadCommands(providedScripts?: Record<string, RawCommand>): void;
|
32
|
-
private init;
|
33
|
-
disconnect(): Promise<void>;
|
34
|
-
reconnect(): Promise<void>;
|
35
|
-
close(): Promise<void>;
|
36
|
-
private getRedisVersion;
|
37
|
-
get redisVersion(): string;
|
38
|
-
}
|