@midwayjs/bullmq 3.20.2 → 3.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/framework.d.ts +12 -0
- package/dist/framework.js +24 -3
- package/dist/interface.d.ts +1 -1
- package/package.json +4 -4
package/dist/framework.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export declare class BullMQQueue extends Queue {
|
|
|
7
7
|
private queueEventsList;
|
|
8
8
|
private queueEventsProducerList;
|
|
9
9
|
constructor(queueName: string, queueOptions: QueueOptions);
|
|
10
|
+
addJobToQueue(data: any, options?: JobsOptions): Promise<Job>;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated use addJobToQueue instead
|
|
13
|
+
*/
|
|
10
14
|
runJob(data: any, options?: JobsOptions): Promise<Job>;
|
|
11
15
|
getQueueName(): string;
|
|
12
16
|
createQueueEvents(options?: QueueEventsOptions): QueueEvents;
|
|
@@ -59,6 +63,14 @@ export declare class BullMQFramework extends BaseFramework<Application, Context,
|
|
|
59
63
|
* Add a processor class and init a worker
|
|
60
64
|
*/
|
|
61
65
|
addProcessor(processor: new (...args: any[]) => IProcessor, queueName: string, workerOptions?: WorkerOptions): Promise<Worker<any, any, string>>;
|
|
66
|
+
/**
|
|
67
|
+
* Add a job to the queue
|
|
68
|
+
*/
|
|
69
|
+
addJobToQueue(queueName: string, jobData: any, options?: JobsOptions): Promise<Job | undefined>;
|
|
70
|
+
/**
|
|
71
|
+
* @deprecated use addJobToQueue instead
|
|
72
|
+
*/
|
|
73
|
+
runJob(queueName: string, jobData: any, options?: JobsOptions): Promise<Job | undefined>;
|
|
62
74
|
/**
|
|
63
75
|
* Create a flow producer, if producerName is provided, it will be store.
|
|
64
76
|
*/
|
package/dist/framework.js
CHANGED
|
@@ -21,8 +21,7 @@ class BullMQQueue extends bullmq_1.Queue {
|
|
|
21
21
|
this.queueEventsList = [];
|
|
22
22
|
this.queueEventsProducerList = [];
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
async runJob(data, options) {
|
|
24
|
+
async addJobToQueue(data, options) {
|
|
26
25
|
const { repeat, ...OtherOptions } = options !== null && options !== void 0 ? options : {};
|
|
27
26
|
if (repeat) {
|
|
28
27
|
return this.upsertJobScheduler(this.name, repeat, {
|
|
@@ -33,6 +32,13 @@ class BullMQQueue extends bullmq_1.Queue {
|
|
|
33
32
|
}
|
|
34
33
|
return this.add('jobName', data || {}, options);
|
|
35
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated use addJobToQueue instead
|
|
37
|
+
*/
|
|
38
|
+
// runJob 与 @midwayjs/bull 保持一致,如果想要使用 jobName 则可以直接调用 queue.add
|
|
39
|
+
async runJob(data, options) {
|
|
40
|
+
return this.addJobToQueue(data, options);
|
|
41
|
+
}
|
|
36
42
|
getQueueName() {
|
|
37
43
|
return this.queueName;
|
|
38
44
|
}
|
|
@@ -124,7 +130,7 @@ let BullMQFramework = class BullMQFramework extends core_1.BaseFramework {
|
|
|
124
130
|
await this.addProcessor(mod, options.queueName, options.workerOptions);
|
|
125
131
|
if (repeat) {
|
|
126
132
|
// add repeatable job
|
|
127
|
-
await ((_c = this.getQueue(options.queueName)) === null || _c === void 0 ? void 0 : _c.
|
|
133
|
+
await ((_c = this.getQueue(options.queueName)) === null || _c === void 0 ? void 0 : _c.addJobToQueue({}, options.jobOptions));
|
|
128
134
|
}
|
|
129
135
|
}
|
|
130
136
|
}
|
|
@@ -229,6 +235,21 @@ let BullMQFramework = class BullMQFramework extends core_1.BaseFramework {
|
|
|
229
235
|
}
|
|
230
236
|
}, workerOptions);
|
|
231
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Add a job to the queue
|
|
240
|
+
*/
|
|
241
|
+
async addJobToQueue(queueName, jobData, options) {
|
|
242
|
+
const queue = this.queueMap.get(queueName);
|
|
243
|
+
if (queue) {
|
|
244
|
+
return await queue.addJobToQueue(jobData, options);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* @deprecated use addJobToQueue instead
|
|
249
|
+
*/
|
|
250
|
+
async runJob(queueName, jobData, options) {
|
|
251
|
+
return this.addJobToQueue(queueName, jobData, options);
|
|
252
|
+
}
|
|
232
253
|
/**
|
|
233
254
|
* Create a flow producer, if producerName is provided, it will be store.
|
|
234
255
|
*/
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IMidwayApplication, IMidwayContext, NextFunction as BaseNextFunction } from '@midwayjs/core';
|
|
2
2
|
import { WorkerOptions, QueueOptions, Job, ConnectionOptions } from 'bullmq';
|
|
3
3
|
export interface IProcessor {
|
|
4
|
-
execute(data: any, job: Job, token?: string): Promise<
|
|
4
|
+
execute(data: any, job: Job, token?: string): Promise<any>;
|
|
5
5
|
}
|
|
6
6
|
export interface Application extends IMidwayApplication<Context> {
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/bullmq",
|
|
3
|
-
"version": "3.20.
|
|
3
|
+
"version": "3.20.3",
|
|
4
4
|
"description": "midway component for BullMQ",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
],
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@midwayjs/core": "^3.20.
|
|
28
|
-
"@midwayjs/mock": "^3.20.
|
|
27
|
+
"@midwayjs/core": "^3.20.3",
|
|
28
|
+
"@midwayjs/mock": "^3.20.3"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"bullmq": "5.39.1"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"node": ">=12"
|
|
35
35
|
},
|
|
36
36
|
"repository": "https://github.com/midwayjs/midway.git",
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "a0918e46838e220fd000997796dbc8d669d28746"
|
|
38
38
|
}
|