bullmq 1.75.1 → 1.76.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/bullmq.d.ts +416 -3
- package/dist/cjs/classes/index.d.ts +10 -4
- package/dist/cjs/classes/index.js +10 -4
- package/dist/cjs/classes/index.js.map +1 -1
- package/dist/cjs/classes/queue-getters.d.ts +16 -0
- package/dist/cjs/classes/queue-getters.js +39 -0
- package/dist/cjs/classes/queue-getters.js.map +1 -1
- package/dist/cjs/classes/scripts.js +4 -1
- package/dist/cjs/classes/scripts.js.map +1 -1
- package/dist/cjs/commands/includes/collectMetrics.lua +42 -0
- package/dist/cjs/commands/{moveToFinished-8.lua → moveToFinished-9.lua} +17 -8
- package/dist/cjs/commands/obliterate-2.lua +13 -4
- package/dist/cjs/enums/index.d.ts +1 -0
- package/dist/cjs/enums/index.js +1 -0
- package/dist/cjs/enums/index.js.map +1 -1
- package/dist/cjs/enums/metrics-time.d.ts +10 -0
- package/dist/cjs/enums/metrics-time.js +15 -0
- package/dist/cjs/enums/metrics-time.js.map +1 -0
- package/dist/cjs/interfaces/index.d.ts +2 -0
- package/dist/cjs/interfaces/index.js +2 -0
- package/dist/cjs/interfaces/index.js.map +1 -1
- package/dist/cjs/interfaces/metrics-options.d.ts +12 -0
- package/dist/cjs/interfaces/metrics-options.js +3 -0
- package/dist/cjs/interfaces/metrics-options.js.map +1 -0
- package/dist/cjs/interfaces/metrics.d.ts +9 -0
- package/dist/cjs/interfaces/metrics.js +3 -0
- package/dist/cjs/interfaces/metrics.js.map +1 -0
- package/dist/cjs/interfaces/worker-options.d.ts +7 -0
- package/dist/esm/classes/index.d.ts +10 -4
- package/dist/esm/classes/index.js +10 -4
- package/dist/esm/classes/index.js.map +1 -1
- package/dist/esm/classes/queue-getters.d.ts +16 -0
- package/dist/esm/classes/queue-getters.js +39 -0
- package/dist/esm/classes/queue-getters.js.map +1 -1
- package/dist/esm/classes/scripts.js +4 -1
- package/dist/esm/classes/scripts.js.map +1 -1
- package/dist/esm/commands/includes/collectMetrics.lua +42 -0
- package/dist/esm/commands/{moveToFinished-8.lua → moveToFinished-9.lua} +17 -8
- package/dist/esm/commands/obliterate-2.lua +13 -4
- package/dist/esm/enums/index.d.ts +1 -0
- package/dist/esm/enums/index.js +1 -0
- package/dist/esm/enums/index.js.map +1 -1
- package/dist/esm/enums/metrics-time.d.ts +10 -0
- package/dist/esm/enums/metrics-time.js +12 -0
- package/dist/esm/enums/metrics-time.js.map +1 -0
- package/dist/esm/interfaces/index.d.ts +2 -0
- package/dist/esm/interfaces/index.js +2 -0
- package/dist/esm/interfaces/index.js.map +1 -1
- package/dist/esm/interfaces/metrics-options.d.ts +12 -0
- package/dist/esm/interfaces/metrics-options.js +1 -0
- package/dist/esm/interfaces/metrics-options.js.map +1 -0
- package/dist/esm/interfaces/metrics.d.ts +9 -0
- package/dist/esm/interfaces/metrics.js +1 -0
- package/dist/esm/interfaces/metrics.js.map +1 -0
- package/dist/esm/interfaces/worker-options.d.ts +7 -0
- package/package.json +1 -1
package/dist/bullmq.d.ts
CHANGED
@@ -8,6 +8,8 @@ import { Pipeline } from 'ioredis';
|
|
8
8
|
import { Redis } from 'ioredis';
|
9
9
|
import { RedisOptions as RedisOptions_2 } from 'ioredis';
|
10
10
|
|
11
|
+
export declare type ActiveEventCallback3<T = any> = (job: Job, jobPromise?: JobPromise3) => void;
|
12
|
+
|
11
13
|
export declare interface AddChildrenOpts {
|
12
14
|
multi: Pipeline;
|
13
15
|
nodes: FlowJob[];
|
@@ -112,8 +114,34 @@ export declare interface ChildProcessExt extends ChildProcess {
|
|
112
114
|
processFile?: string;
|
113
115
|
}
|
114
116
|
|
117
|
+
/**
|
118
|
+
* ChildProcessor
|
119
|
+
*
|
120
|
+
* This class acts as the interface between a child process and it parent process
|
121
|
+
* so that jobs can be processed in different processes than the parent.
|
122
|
+
*
|
123
|
+
*/
|
124
|
+
export declare class ChildProcessor {
|
125
|
+
status: ChildStatus;
|
126
|
+
processor: any;
|
127
|
+
currentJobPromise: Promise<unknown> | undefined;
|
128
|
+
init(processorFile: string): Promise<void>;
|
129
|
+
start(jobJson: JobJson): Promise<void>;
|
130
|
+
stop(): Promise<void>;
|
131
|
+
waitForCurrentJobAndExit(): Promise<void>;
|
132
|
+
}
|
133
|
+
|
115
134
|
export declare const childSend: (proc: NodeJS.Process, msg: ChildMessage) => Promise<void>;
|
116
135
|
|
136
|
+
declare enum ChildStatus {
|
137
|
+
Idle = 0,
|
138
|
+
Started = 1,
|
139
|
+
Terminating = 2,
|
140
|
+
Errored = 3
|
141
|
+
}
|
142
|
+
|
143
|
+
export declare type CleanedEventCallback3<T = any> = (jobs: Array<Job>, status: JobStatusClean3) => void;
|
144
|
+
|
117
145
|
export declare const clientCommandMessageReg: RegExp;
|
118
146
|
|
119
147
|
export declare enum ClientType {
|
@@ -129,6 +157,10 @@ export declare interface Command {
|
|
129
157
|
};
|
130
158
|
}
|
131
159
|
|
160
|
+
declare type CommonOptions = QueueSchedulerOptions & QueueOptions & WorkerOptions & QueueEventsOptions;
|
161
|
+
|
162
|
+
export declare type CompletedEventCallback3<T = any> = (job: Job, result: any) => void;
|
163
|
+
|
132
164
|
export declare type ConnectionOptions = RedisOptions | Redis | Cluster;
|
133
165
|
|
134
166
|
export declare function delay(ms: number): Promise<void>;
|
@@ -160,10 +192,16 @@ export declare enum ErrorCode {
|
|
160
192
|
ParentJobNotExist = -5
|
161
193
|
}
|
162
194
|
|
195
|
+
export declare type ErrorEventCallback3 = (error: Error) => void;
|
196
|
+
|
163
197
|
export declare const errorObject: {
|
164
198
|
[index: string]: any;
|
165
199
|
};
|
166
200
|
|
201
|
+
export declare type EventCallback3 = () => void;
|
202
|
+
|
203
|
+
export declare type FailedEventCallback3<T = any> = (job: Job, error: Error) => void;
|
204
|
+
|
167
205
|
export declare type FinishedPropValAttribute = 'returnvalue' | 'failedReason';
|
168
206
|
|
169
207
|
export declare type FinishedStatus = 'completed' | 'failed';
|
@@ -599,6 +637,16 @@ export declare type JobData = [JobJsonRaw | number, string?];
|
|
599
637
|
|
600
638
|
export declare function jobIdForGroup(jobOpts: JobsOptions, data: any, queueOpts: QueueOptions): string;
|
601
639
|
|
640
|
+
export declare interface JobInformation3 {
|
641
|
+
key: string;
|
642
|
+
name: string;
|
643
|
+
id?: string;
|
644
|
+
endDate?: number;
|
645
|
+
tz?: string;
|
646
|
+
cron: string;
|
647
|
+
next: number;
|
648
|
+
}
|
649
|
+
|
602
650
|
export declare interface JobJson {
|
603
651
|
id: string;
|
604
652
|
name: string;
|
@@ -643,6 +691,13 @@ export declare interface JobNode {
|
|
643
691
|
children?: JobNode[];
|
644
692
|
}
|
645
693
|
|
694
|
+
export declare interface JobPromise3 {
|
695
|
+
/**
|
696
|
+
* Abort this job
|
697
|
+
*/
|
698
|
+
cancel(): void;
|
699
|
+
}
|
700
|
+
|
646
701
|
export declare interface JobsOptions {
|
647
702
|
/**
|
648
703
|
* Timestamp when the job was created. Defaults to `Date.now()`.
|
@@ -737,6 +792,8 @@ export declare interface JobsOptions {
|
|
737
792
|
|
738
793
|
export declare type JobState = FinishedStatus | 'active' | 'delayed' | 'waiting' | 'waiting-children';
|
739
794
|
|
795
|
+
export declare type JobStatusClean3 = 'completed' | 'wait' | 'active' | 'delayed' | 'paused' | 'failed';
|
796
|
+
|
740
797
|
export declare type JobType = JobState | 'paused' | 'repeat' | 'wait';
|
741
798
|
|
742
799
|
/**
|
@@ -757,10 +814,16 @@ export declare interface KeepJobs {
|
|
757
814
|
count?: number;
|
758
815
|
}
|
759
816
|
|
760
|
-
declare type KeysMap = {
|
817
|
+
export declare type KeysMap = {
|
761
818
|
[index in string]: string;
|
762
819
|
};
|
763
820
|
|
821
|
+
/**
|
822
|
+
* Sends a kill signal to a child resolving when the child has exited,
|
823
|
+
* resorting to SIGKILL if the given timeout is reached
|
824
|
+
*/
|
825
|
+
export declare function killAsync(child: ChildProcess, signal?: 'SIGTERM' | 'SIGKILL', timeoutMs?: number): Promise<void>;
|
826
|
+
|
764
827
|
/**
|
765
828
|
* Checks the size of string for ascii/non-ascii characters
|
766
829
|
* @see https://stackoverflow.com/a/23318053/1347170
|
@@ -768,6 +831,40 @@ declare type KeysMap = {
|
|
768
831
|
*/
|
769
832
|
export declare function lengthInUtf8Bytes(str: string): number;
|
770
833
|
|
834
|
+
export declare interface Metrics {
|
835
|
+
meta: {
|
836
|
+
count: number;
|
837
|
+
prevTS: number;
|
838
|
+
prevCount: number;
|
839
|
+
};
|
840
|
+
data: number[];
|
841
|
+
count: number;
|
842
|
+
}
|
843
|
+
|
844
|
+
/**
|
845
|
+
*
|
846
|
+
*
|
847
|
+
*/
|
848
|
+
export declare interface MetricsOptions {
|
849
|
+
/**
|
850
|
+
* Enable gathering metrics for finished jobs.
|
851
|
+
* Output refers to all finished jobs, completed or
|
852
|
+
* failed.
|
853
|
+
*/
|
854
|
+
maxDataPoints?: number;
|
855
|
+
}
|
856
|
+
|
857
|
+
export declare enum MetricsTime {
|
858
|
+
ONE_MINUTE = 1,
|
859
|
+
FIVE_MINUTES = 5,
|
860
|
+
FIFTEEN_MINUTES = 15,
|
861
|
+
THIRTY_MINUTES = 30,
|
862
|
+
ONE_HOUR = 60,
|
863
|
+
ONE_WEEK = 10080,
|
864
|
+
TWO_WEEKS = 20160,
|
865
|
+
ONE_MONTH = 80640
|
866
|
+
}
|
867
|
+
|
771
868
|
export declare type MinimalQueue = Pick<QueueBase, 'name' | 'client' | 'toKey' | 'keys' | 'opts' | 'closing' | 'waitUntilReady' | 'removeListener' | 'emit' | 'on' | 'redisVersion'>;
|
772
869
|
|
773
870
|
export declare interface MoveToChildrenOpts {
|
@@ -866,6 +963,8 @@ declare interface procSendLike {
|
|
866
963
|
}, callback?: (error: Error) => void): boolean;
|
867
964
|
}
|
868
965
|
|
966
|
+
export declare type ProgressEventCallback3<T = any> = (job: Job, progress: any) => void;
|
967
|
+
|
869
968
|
/**
|
870
969
|
* Queue
|
871
970
|
*
|
@@ -1011,6 +1110,293 @@ export declare class Queue<DataType = any, ResultType = any, NameType extends st
|
|
1011
1110
|
trimEvents(maxLength: number): Promise<number>;
|
1012
1111
|
}
|
1013
1112
|
|
1113
|
+
/**
|
1114
|
+
* @deprecated Use Queue class instead {@link https://docs.bullmq.io/guide/queues}
|
1115
|
+
*/
|
1116
|
+
export declare class Queue3<T = any> extends EventEmitter {
|
1117
|
+
/**
|
1118
|
+
* The name of the queue
|
1119
|
+
*/
|
1120
|
+
name: string;
|
1121
|
+
queueEvents: QueueEvents;
|
1122
|
+
private opts;
|
1123
|
+
private readonly queue;
|
1124
|
+
private worker;
|
1125
|
+
private queueScheduler;
|
1126
|
+
/**
|
1127
|
+
* This is the Queue constructor.
|
1128
|
+
* It creates a new Queue that is persisted in Redis.
|
1129
|
+
* Every time the same queue is instantiated it tries to process all the old jobs
|
1130
|
+
* that may exist from a previous unfinished session.
|
1131
|
+
*/
|
1132
|
+
constructor(name: string, opts?: CommonOptions);
|
1133
|
+
/**
|
1134
|
+
* Returns a promise that resolves when Redis is connected and the queue is ready to accept jobs.
|
1135
|
+
* This replaces the `ready` event emitted on Queue in previous versions.
|
1136
|
+
*/
|
1137
|
+
isReady(): Promise<this>;
|
1138
|
+
/**
|
1139
|
+
* Defines a processing function for the jobs placed into a given Queue.
|
1140
|
+
*
|
1141
|
+
* The callback is called every time a job is placed in the queue.
|
1142
|
+
* It is passed an instance of the job as first argument.
|
1143
|
+
*
|
1144
|
+
* If the callback signature contains the second optional done argument,
|
1145
|
+
* the callback will be passed a done callback to be called after the job has been completed.
|
1146
|
+
* The done callback can be called with an Error instance, to signal that the job did not complete successfully,
|
1147
|
+
* or with a result as second argument (e.g.: done(null, result);) when the job is successful.
|
1148
|
+
* Errors will be passed as a second argument to the "failed" event; results,
|
1149
|
+
* as a second argument to the "completed" event.
|
1150
|
+
*
|
1151
|
+
* If, however, the callback signature does not contain the done argument,
|
1152
|
+
* a promise must be returned to signal job completion.
|
1153
|
+
* If the promise is rejected, the error will be passed as a second argument to the "failed" event.
|
1154
|
+
* If it is resolved, its value will be the "completed" event's second argument.
|
1155
|
+
*/
|
1156
|
+
process(processor: string | Processor<T>): Promise<void>;
|
1157
|
+
add(jobName: string, data: any, opts?: JobsOptions): Promise<Job>;
|
1158
|
+
/**
|
1159
|
+
* Returns a promise that resolves when the queue is paused.
|
1160
|
+
*
|
1161
|
+
* A paused queue will not process new jobs until resumed, but current jobs being processed will continue until
|
1162
|
+
* they are finalized. The pause can be either global or local. If global, all workers in all queue instances
|
1163
|
+
* for a given queue will be paused. If local, just this worker will stop processing new jobs after the current
|
1164
|
+
* lock expires. This can be useful to stop a worker from taking new jobs prior to shutting down.
|
1165
|
+
*
|
1166
|
+
* Pausing a queue that is already paused does nothing.
|
1167
|
+
*/
|
1168
|
+
pause(): Promise<void>;
|
1169
|
+
pauseWorker(doNotWaitActive?: boolean): Promise<void>;
|
1170
|
+
/**
|
1171
|
+
* Returns a promise that resolves when the queue is resumed after being paused.
|
1172
|
+
*
|
1173
|
+
* The resume can be either local or global. If global, all workers in all queue instances for a given queue
|
1174
|
+
* will be resumed. If local, only this worker will be resumed. Note that resuming a queue globally will not
|
1175
|
+
* resume workers that have been paused locally; for those, resume(true) must be called directly on their
|
1176
|
+
* instances.
|
1177
|
+
*
|
1178
|
+
* Resuming a queue that is not paused does nothing.
|
1179
|
+
*/
|
1180
|
+
resume(): Promise<void>;
|
1181
|
+
resumeWorker(): Promise<void>;
|
1182
|
+
isWorkerPaused(): boolean;
|
1183
|
+
/**
|
1184
|
+
* Returns a promise that returns the number of jobs in the queue, waiting or paused.
|
1185
|
+
* Since there may be other processes adding or processing jobs,
|
1186
|
+
* this value may be true only for a very small amount of time.
|
1187
|
+
*/
|
1188
|
+
count(): Promise<number>;
|
1189
|
+
/**
|
1190
|
+
* Empties a queue deleting all the input lists and associated jobs.
|
1191
|
+
*/
|
1192
|
+
empty(): Promise<void>;
|
1193
|
+
/**
|
1194
|
+
* Closes the underlying redis client. Use this to perform a graceful shutdown.
|
1195
|
+
*
|
1196
|
+
* `close` can be called from anywhere, with one caveat:
|
1197
|
+
* if called from within a job handler the queue won't close until after the job has been processed
|
1198
|
+
*/
|
1199
|
+
close(): Promise<any>;
|
1200
|
+
/**
|
1201
|
+
* Returns a promise that will return the job instance associated with the jobId parameter.
|
1202
|
+
* If the specified job cannot be located, the promise callback parameter will be set to null.
|
1203
|
+
*/
|
1204
|
+
getJob(jobId: string): Promise<Job | null>;
|
1205
|
+
/**
|
1206
|
+
* Returns a promise that will return an array with the waiting jobs between start and end.
|
1207
|
+
*/
|
1208
|
+
getWaiting(start?: number, end?: number): Promise<Array<Job>>;
|
1209
|
+
/**
|
1210
|
+
* Returns a promise that will return an array with the active jobs between start and end.
|
1211
|
+
*/
|
1212
|
+
getActive(start?: number, end?: number): Promise<Array<Job>>;
|
1213
|
+
/**
|
1214
|
+
* Returns a promise that will return an array with the delayed jobs between start and end.
|
1215
|
+
*/
|
1216
|
+
getDelayed(start?: number, end?: number): Promise<Array<Job>>;
|
1217
|
+
/**
|
1218
|
+
* Returns a promise that will return an array with the completed jobs between start and end.
|
1219
|
+
*/
|
1220
|
+
getCompleted(start?: number, end?: number): Promise<Array<Job>>;
|
1221
|
+
/**
|
1222
|
+
* Returns a promise that will return an array with the failed jobs between start and end.
|
1223
|
+
*/
|
1224
|
+
getFailed(start?: number, end?: number): Promise<Array<Job>>;
|
1225
|
+
/**
|
1226
|
+
* Returns JobInformation of repeatable jobs (ordered descending). Provide a start and/or an end
|
1227
|
+
* index to limit the number of results. Start defaults to 0, end to -1 and asc to false.
|
1228
|
+
*/
|
1229
|
+
getRepeatableJobs(start?: number, end?: number, asc?: boolean): Promise<JobInformation3[]>;
|
1230
|
+
/**
|
1231
|
+
* ???
|
1232
|
+
*/
|
1233
|
+
nextRepeatableJob(name: string, data: any, opts?: JobsOptions, skipCheckExists?: boolean): Promise<Job>;
|
1234
|
+
/**
|
1235
|
+
* Removes a given repeatable job. The RepeatOptions and JobId needs to be the same as the ones
|
1236
|
+
* used for the job when it was added.
|
1237
|
+
*
|
1238
|
+
* name: The name of the to be removed job
|
1239
|
+
*/
|
1240
|
+
removeRepeatable(name: string, opts: RepeatOptions): Promise<void>;
|
1241
|
+
/**
|
1242
|
+
* Removes a given repeatable job by key.
|
1243
|
+
*/
|
1244
|
+
removeRepeatableByKey(repeatJobKey: string): Promise<void>;
|
1245
|
+
/**
|
1246
|
+
* Returns a promise that will return an array of job instances of the given types.
|
1247
|
+
* Optional parameters for range and ordering are provided.
|
1248
|
+
*/
|
1249
|
+
getJobs(types: JobType[] | JobType, start?: number, end?: number, asc?: boolean): Promise<Array<Job>>;
|
1250
|
+
getNextJob(): Promise<Job>;
|
1251
|
+
/**
|
1252
|
+
* Returns a object with the logs according to the start and end arguments. The returned count
|
1253
|
+
* value is the total amount of logs, useful for implementing pagination.
|
1254
|
+
*/
|
1255
|
+
getJobLogs(jobId: string, start?: number, end?: number): Promise<{
|
1256
|
+
logs: string[];
|
1257
|
+
count: number;
|
1258
|
+
}>;
|
1259
|
+
/**
|
1260
|
+
* Returns a promise that resolves with the job counts for the given queue.
|
1261
|
+
*/
|
1262
|
+
getJobCounts(...types: JobType[]): Promise<{
|
1263
|
+
[index: string]: number;
|
1264
|
+
}>;
|
1265
|
+
/**
|
1266
|
+
* Returns a promise that resolves with the job counts for the given queue of the given types.
|
1267
|
+
*/
|
1268
|
+
getJobCountByTypes(...types: JobType[]): Promise<number>;
|
1269
|
+
/**
|
1270
|
+
* Returns a promise that resolves with the quantity of completed jobs.
|
1271
|
+
*/
|
1272
|
+
getCompletedCount(): Promise<number>;
|
1273
|
+
/**
|
1274
|
+
* Returns a promise that resolves with the quantity of failed jobs.
|
1275
|
+
*/
|
1276
|
+
getFailedCount(): Promise<number>;
|
1277
|
+
/**
|
1278
|
+
* Returns a promise that resolves with the quantity of delayed jobs.
|
1279
|
+
*/
|
1280
|
+
getDelayedCount(): Promise<number>;
|
1281
|
+
/**
|
1282
|
+
* Returns a promise that resolves with the quantity of waiting jobs.
|
1283
|
+
*/
|
1284
|
+
getWaitingCount(): Promise<number>;
|
1285
|
+
/**
|
1286
|
+
* Returns a promise that resolves with the quantity of paused jobs.
|
1287
|
+
*/
|
1288
|
+
getPausedCount(): Promise<number>;
|
1289
|
+
/**
|
1290
|
+
* Returns a promise that resolves with the quantity of active jobs.
|
1291
|
+
*/
|
1292
|
+
getActiveCount(): Promise<number>;
|
1293
|
+
/**
|
1294
|
+
* Returns a promise that resolves to the quantity of repeatable jobs.
|
1295
|
+
*/
|
1296
|
+
getRepeatableCount(): Promise<number>;
|
1297
|
+
/**
|
1298
|
+
* Tells the queue remove all jobs created outside of a grace period in milliseconds.
|
1299
|
+
* You can clean the jobs with the following states: completed, wait (typo for waiting), active, delayed, and failed.
|
1300
|
+
* @param grace - Grace period in milliseconds.
|
1301
|
+
* @param limit - Maximum amount of jobs to clean per call. If not provided will clean all matching jobs.
|
1302
|
+
* @param type - Status of the job to clean. Values are completed, wait,
|
1303
|
+
* active, paused, delayed, and failed. Defaults to completed.
|
1304
|
+
*/
|
1305
|
+
clean(grace: number, limit: number, type?: 'completed' | 'wait' | 'active' | 'paused' | 'delayed' | 'failed'): Promise<string[]>;
|
1306
|
+
/**
|
1307
|
+
* Listens to queue events
|
1308
|
+
*/
|
1309
|
+
on(event: string, callback: (...args: any[]) => void): this;
|
1310
|
+
/**
|
1311
|
+
* An error occurred
|
1312
|
+
*/
|
1313
|
+
on(event: 'error', callback: ErrorEventCallback3): this;
|
1314
|
+
/**
|
1315
|
+
* A Job is waiting to be processed as soon as a worker is idling.
|
1316
|
+
*/
|
1317
|
+
on(event: 'waiting', callback: WaitingEventCallback3): this;
|
1318
|
+
/**
|
1319
|
+
* A job has started. You can use `jobPromise.cancel()` to abort it
|
1320
|
+
*/
|
1321
|
+
on(event: 'active', callback: ActiveEventCallback3<T>): this;
|
1322
|
+
/**
|
1323
|
+
* A job has been marked as stalled.
|
1324
|
+
* This is useful for debugging job workers that crash or pause the event loop.
|
1325
|
+
*/
|
1326
|
+
on(event: 'stalled', callback: StalledEventCallback3<T>): this;
|
1327
|
+
/**
|
1328
|
+
* A job's progress was updated
|
1329
|
+
*/
|
1330
|
+
on(event: 'progress', callback: ProgressEventCallback3<T>): this;
|
1331
|
+
/**
|
1332
|
+
* A job successfully completed with a `result`
|
1333
|
+
*/
|
1334
|
+
on(event: 'completed', callback: CompletedEventCallback3<T>): this;
|
1335
|
+
/**
|
1336
|
+
* A job failed with `err` as the reason
|
1337
|
+
*/
|
1338
|
+
on(event: 'failed', callback: FailedEventCallback3<T>): this;
|
1339
|
+
/**
|
1340
|
+
* The queue has been paused
|
1341
|
+
*/
|
1342
|
+
on(event: 'paused', callback: EventCallback3): this;
|
1343
|
+
/**
|
1344
|
+
* The queue has been resumed
|
1345
|
+
*/
|
1346
|
+
on(event: 'resumed', callback: EventCallback3): this;
|
1347
|
+
/**
|
1348
|
+
* A job successfully removed.
|
1349
|
+
*/
|
1350
|
+
on(event: 'removed', callback: RemovedEventCallback3<T>): this;
|
1351
|
+
/**
|
1352
|
+
* Old jobs have been cleaned from the queue.
|
1353
|
+
* `jobs` is an array of jobs that were removed, and `type` is the type of those jobs.
|
1354
|
+
*
|
1355
|
+
* @see Queue#clean() for details
|
1356
|
+
*/
|
1357
|
+
on(event: 'cleaned', callback: CleanedEventCallback3<T>): this;
|
1358
|
+
/**
|
1359
|
+
* Emitted every time the queue has processed all the waiting jobs
|
1360
|
+
* (even if there can be some delayed jobs not yet processed)
|
1361
|
+
*/
|
1362
|
+
on(event: 'drained', callback: EventCallback3): this;
|
1363
|
+
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
1364
|
+
off(event: string | symbol, listener?: (...args: any[]) => void): this;
|
1365
|
+
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
1366
|
+
removeAllListeners(event: string | symbol): this;
|
1367
|
+
/**
|
1368
|
+
* Set clientName to Redis.client
|
1369
|
+
*/
|
1370
|
+
setWorkerName(): Promise<any>;
|
1371
|
+
/**
|
1372
|
+
* Returns Redis clients array which belongs to current Queue
|
1373
|
+
*/
|
1374
|
+
getWorkers(): Promise<{
|
1375
|
+
[key: string]: string;
|
1376
|
+
}[]>;
|
1377
|
+
/**
|
1378
|
+
* Returns Queue name in base64 encoded format
|
1379
|
+
*/
|
1380
|
+
base64Name(): string;
|
1381
|
+
/**
|
1382
|
+
* Returns Queue name with keyPrefix (default: 'bull')
|
1383
|
+
*/
|
1384
|
+
clientName(): string;
|
1385
|
+
/**
|
1386
|
+
* Returns Redis clients array which belongs to current Queue from string with all redis clients
|
1387
|
+
*
|
1388
|
+
* @param list - String with all redis clients
|
1389
|
+
*/
|
1390
|
+
parseClientList(list: string): {
|
1391
|
+
[key: string]: string;
|
1392
|
+
}[];
|
1393
|
+
retryJob(job: Job): Promise<void>;
|
1394
|
+
private getQueueEvents;
|
1395
|
+
private ensureWorkerCreated;
|
1396
|
+
private attachListener;
|
1397
|
+
detachListener(event: string | symbol, listener?: (...args: any[]) => void): this;
|
1398
|
+
}
|
1399
|
+
|
1014
1400
|
export declare class QueueBase extends EventEmitter {
|
1015
1401
|
readonly name: string;
|
1016
1402
|
opts: QueueBaseOptions;
|
@@ -1286,10 +1672,25 @@ export declare class QueueGetters<DataType, ResultType, NameType extends string>
|
|
1286
1672
|
getQueueSchedulers(): Promise<{
|
1287
1673
|
[index: string]: string;
|
1288
1674
|
}[]>;
|
1675
|
+
/**
|
1676
|
+
* Get queue metrics related to the queue.
|
1677
|
+
*
|
1678
|
+
* This method returns the gathered metrics for the queue.
|
1679
|
+
* The metrics are represented as an array of job counts
|
1680
|
+
* per unit of time (1 minute).
|
1681
|
+
*
|
1682
|
+
* @param start - Start point of the metrics, where 0
|
1683
|
+
* is the newest point to be returned.
|
1684
|
+
* @param end - End poinf of the metrics, where -1 is the
|
1685
|
+
* oldest point to be returned.
|
1686
|
+
*
|
1687
|
+
* @returns - Returns an object with queue metrics.
|
1688
|
+
*/
|
1689
|
+
getMetrics(type: 'completed' | 'failed', start?: number, end?: number): Promise<Metrics>;
|
1289
1690
|
private parseClientList;
|
1290
1691
|
}
|
1291
1692
|
|
1292
|
-
declare class QueueKeys {
|
1693
|
+
export declare class QueueKeys {
|
1293
1694
|
readonly prefix: string;
|
1294
1695
|
constructor(prefix?: string);
|
1295
1696
|
getKeys(name: string): KeysMap;
|
@@ -1513,6 +1914,8 @@ export declare type RedisOptions = (RedisOptions_2 | ClusterOptions) & {
|
|
1513
1914
|
|
1514
1915
|
export declare function removeAllQueueData(client: RedisClient, queueName: string, prefix?: string): Promise<void | boolean>;
|
1515
1916
|
|
1917
|
+
export declare type RemovedEventCallback3<T = any> = (job: Job) => void;
|
1918
|
+
|
1516
1919
|
export declare class Repeat extends QueueBase {
|
1517
1920
|
addNextRepeatableJob<T = any, R = any, N extends string = string>(name: N, data: T, opts: JobsOptions, skipCheckExists?: boolean): Promise<Job<T, R, N>>;
|
1518
1921
|
private createNextJob;
|
@@ -1793,6 +2196,8 @@ export declare class Scripts {
|
|
1793
2196
|
}): Promise<number>;
|
1794
2197
|
}
|
1795
2198
|
|
2199
|
+
export declare type StalledEventCallback3<T = any> = (job: Job) => void;
|
2200
|
+
|
1796
2201
|
export declare interface Strategies {
|
1797
2202
|
[index: string]: BackoffFunction;
|
1798
2203
|
}
|
@@ -1805,7 +2210,7 @@ export declare type StreamReadRaw = [StreamName, EntryRaw[]][];
|
|
1805
2210
|
* Keeps track on timers created with setTimeout to help clearTimeout
|
1806
2211
|
* for all timers when no more delayed actions needed
|
1807
2212
|
*/
|
1808
|
-
declare class TimerManager {
|
2213
|
+
export declare class TimerManager {
|
1809
2214
|
private readonly timers;
|
1810
2215
|
/**
|
1811
2216
|
* Creates a new timer and returns its ID.
|
@@ -1832,6 +2237,8 @@ export declare class UnrecoverableError extends Error {
|
|
1832
2237
|
constructor(message?: string);
|
1833
2238
|
}
|
1834
2239
|
|
2240
|
+
export declare type WaitingEventCallback3 = (jobId: string) => void;
|
2241
|
+
|
1835
2242
|
/**
|
1836
2243
|
*
|
1837
2244
|
* This class represents a worker that is able to process jobs from the queue.
|
@@ -2009,9 +2416,15 @@ export declare interface WorkerOptions extends QueueBaseOptions {
|
|
2009
2416
|
*/
|
2010
2417
|
concurrency?: number;
|
2011
2418
|
/**
|
2419
|
+
* Enable rate limiter
|
2012
2420
|
* @see {@link https://docs.bullmq.io/guide/rate-limiting}
|
2013
2421
|
*/
|
2014
2422
|
limiter?: RateLimiterOptions;
|
2423
|
+
/**
|
2424
|
+
* Enable collect metrics.
|
2425
|
+
* @see {@link https://docs.bullmq.io/guide/metrics}
|
2426
|
+
*/
|
2427
|
+
metrics?: MetricsOptions;
|
2015
2428
|
skipDelayCheck?: boolean;
|
2016
2429
|
drainDelay?: number;
|
2017
2430
|
lockDuration?: number;
|
@@ -1,15 +1,21 @@
|
|
1
1
|
export * from './backoffs';
|
2
|
+
export * from './child-pool';
|
3
|
+
export * from './child-processor';
|
4
|
+
export * from './compat';
|
5
|
+
export * from './flow-producer';
|
2
6
|
export * from './job';
|
7
|
+
export * from './master';
|
8
|
+
export * from './process-utils';
|
3
9
|
export * from './queue-base';
|
4
10
|
export * from './queue-events';
|
5
11
|
export * from './queue-getters';
|
12
|
+
export * from './queue-keys';
|
6
13
|
export * from './queue-scheduler';
|
7
14
|
export * from './queue';
|
8
15
|
export * from './redis-connection';
|
9
16
|
export * from './repeat';
|
10
|
-
export * from './scripts';
|
11
|
-
export * from './worker';
|
12
|
-
export * from './child-pool';
|
13
17
|
export * from './sandbox';
|
14
|
-
export * from './
|
18
|
+
export * from './scripts';
|
19
|
+
export * from './timer-manager';
|
15
20
|
export * from './unrecoverable-error';
|
21
|
+
export * from './worker';
|
@@ -2,18 +2,24 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
4
|
tslib_1.__exportStar(require("./backoffs"), exports);
|
5
|
+
tslib_1.__exportStar(require("./child-pool"), exports);
|
6
|
+
tslib_1.__exportStar(require("./child-processor"), exports);
|
7
|
+
tslib_1.__exportStar(require("./compat"), exports);
|
8
|
+
tslib_1.__exportStar(require("./flow-producer"), exports);
|
5
9
|
tslib_1.__exportStar(require("./job"), exports);
|
10
|
+
tslib_1.__exportStar(require("./master"), exports);
|
11
|
+
tslib_1.__exportStar(require("./process-utils"), exports);
|
6
12
|
tslib_1.__exportStar(require("./queue-base"), exports);
|
7
13
|
tslib_1.__exportStar(require("./queue-events"), exports);
|
8
14
|
tslib_1.__exportStar(require("./queue-getters"), exports);
|
15
|
+
tslib_1.__exportStar(require("./queue-keys"), exports);
|
9
16
|
tslib_1.__exportStar(require("./queue-scheduler"), exports);
|
10
17
|
tslib_1.__exportStar(require("./queue"), exports);
|
11
18
|
tslib_1.__exportStar(require("./redis-connection"), exports);
|
12
19
|
tslib_1.__exportStar(require("./repeat"), exports);
|
13
|
-
tslib_1.__exportStar(require("./scripts"), exports);
|
14
|
-
tslib_1.__exportStar(require("./worker"), exports);
|
15
|
-
tslib_1.__exportStar(require("./child-pool"), exports);
|
16
20
|
tslib_1.__exportStar(require("./sandbox"), exports);
|
17
|
-
tslib_1.__exportStar(require("./
|
21
|
+
tslib_1.__exportStar(require("./scripts"), exports);
|
22
|
+
tslib_1.__exportStar(require("./timer-manager"), exports);
|
18
23
|
tslib_1.__exportStar(require("./unrecoverable-error"), exports);
|
24
|
+
tslib_1.__exportStar(require("./worker"), exports);
|
19
25
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/classes/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,gDAAsB;AACtB,uDAA6B;AAC7B,yDAA+B;AAC/B,0DAAgC;AAChC,4DAAkC;AAClC,kDAAwB;AACxB,6DAAmC;AACnC,mDAAyB;AACzB,oDAA0B;AAC1B,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/classes/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,uDAA6B;AAC7B,4DAAkC;AAClC,mDAAyB;AACzB,0DAAgC;AAChC,gDAAsB;AACtB,mDAAyB;AACzB,0DAAgC;AAChC,uDAA6B;AAC7B,yDAA+B;AAC/B,0DAAgC;AAChC,uDAA6B;AAC7B,4DAAkC;AAClC,kDAAwB;AACxB,6DAAmC;AACnC,mDAAyB;AACzB,oDAA0B;AAC1B,oDAA0B;AAC1B,0DAAgC;AAChC,gEAAsC;AACtC,mDAAyB"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { QueueBase } from './queue-base';
|
2
2
|
import { Job } from './job';
|
3
3
|
import { JobType } from '../types';
|
4
|
+
import { Metrics } from '../interfaces';
|
4
5
|
export declare class QueueGetters<DataType, ResultType, NameType extends string> extends QueueBase {
|
5
6
|
getJob(jobId: string): Promise<Job<DataType, ResultType, NameType> | undefined>;
|
6
7
|
private commandByType;
|
@@ -59,5 +60,20 @@ export declare class QueueGetters<DataType, ResultType, NameType extends string>
|
|
59
60
|
getQueueSchedulers(): Promise<{
|
60
61
|
[index: string]: string;
|
61
62
|
}[]>;
|
63
|
+
/**
|
64
|
+
* Get queue metrics related to the queue.
|
65
|
+
*
|
66
|
+
* This method returns the gathered metrics for the queue.
|
67
|
+
* The metrics are represented as an array of job counts
|
68
|
+
* per unit of time (1 minute).
|
69
|
+
*
|
70
|
+
* @param start - Start point of the metrics, where 0
|
71
|
+
* is the newest point to be returned.
|
72
|
+
* @param end - End poinf of the metrics, where -1 is the
|
73
|
+
* oldest point to be returned.
|
74
|
+
*
|
75
|
+
* @returns - Returns an object with queue metrics.
|
76
|
+
*/
|
77
|
+
getMetrics(type: 'completed' | 'failed', start?: number, end?: number): Promise<Metrics>;
|
62
78
|
private parseClientList;
|
63
79
|
}
|
@@ -214,6 +214,45 @@ class QueueGetters extends queue_base_1.QueueBase {
|
|
214
214
|
}
|
215
215
|
}
|
216
216
|
}
|
217
|
+
/**
|
218
|
+
* Get queue metrics related to the queue.
|
219
|
+
*
|
220
|
+
* This method returns the gathered metrics for the queue.
|
221
|
+
* The metrics are represented as an array of job counts
|
222
|
+
* per unit of time (1 minute).
|
223
|
+
*
|
224
|
+
* @param start - Start point of the metrics, where 0
|
225
|
+
* is the newest point to be returned.
|
226
|
+
* @param end - End poinf of the metrics, where -1 is the
|
227
|
+
* oldest point to be returned.
|
228
|
+
*
|
229
|
+
* @returns - Returns an object with queue metrics.
|
230
|
+
*/
|
231
|
+
async getMetrics(type, start = 0, end = -1) {
|
232
|
+
const client = await this.client;
|
233
|
+
const metricsKey = this.toKey(`metrics:${type}`);
|
234
|
+
const dataKey = `${metricsKey}:data`;
|
235
|
+
const multi = client.multi();
|
236
|
+
multi.hmget(metricsKey, 'count', 'prevTS', 'prevCount');
|
237
|
+
multi.lrange(dataKey, start, end);
|
238
|
+
multi.llen(dataKey);
|
239
|
+
const [hmget, range, len] = await multi.exec();
|
240
|
+
const [err, [count, prevTS, prevCount]] = hmget;
|
241
|
+
const [err2, data] = range;
|
242
|
+
const [err3, numPoints] = len;
|
243
|
+
if (err || err2) {
|
244
|
+
throw err || err2 || err3;
|
245
|
+
}
|
246
|
+
return {
|
247
|
+
meta: {
|
248
|
+
count: parseInt(count || '0', 10),
|
249
|
+
prevTS: parseInt(prevTS || '0', 10),
|
250
|
+
prevCount: parseInt(prevCount || '0', 10),
|
251
|
+
},
|
252
|
+
data,
|
253
|
+
count: numPoints,
|
254
|
+
};
|
255
|
+
}
|
217
256
|
parseClientList(list, suffix = '') {
|
218
257
|
const lines = list.split('\n');
|
219
258
|
const clients = [];
|