@midwayjs/bull 3.20.0 → 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.
@@ -4,6 +4,10 @@ import { Job, JobOptions, QueueOptions } from 'bull';
4
4
  import Bull = require('bull');
5
5
  export declare class BullQueue extends Bull implements IQueue<Job> {
6
6
  constructor(queueName: string, queueOptions: QueueOptions);
7
+ addJobToQueue(data: any, options?: JobOptions): Promise<Job>;
8
+ /**
9
+ * @deprecated use addJobToQueue instead
10
+ */
7
11
  runJob(data: any, options?: JobOptions): Promise<Job>;
8
12
  getQueueName(): string;
9
13
  }
@@ -24,6 +28,10 @@ export declare class BullFramework extends BaseFramework<Application, Context, a
24
28
  ensureQueue(name: string, queueOptions?: QueueOptions): BullQueue;
25
29
  getQueueList(): BullQueue[];
26
30
  addProcessor(processor: new (...args: any[]) => IProcessor, queueName: string | BullQueue, concurrency?: number): Promise<void>;
31
+ addJobToQueue(queueName: string, jobData: any, options?: JobOptions): Promise<Job | undefined>;
32
+ /**
33
+ * @deprecated use addJob instead
34
+ */
27
35
  runJob(queueName: string, jobData: any, options?: JobOptions): Promise<Job | undefined>;
28
36
  getJob(queueName: string, jobName: string): Promise<Job>;
29
37
  }
package/dist/framework.js CHANGED
@@ -17,6 +17,12 @@ class BullQueue extends Bull {
17
17
  constructor(queueName, queueOptions) {
18
18
  super(queueName, queueOptions);
19
19
  }
20
+ async addJobToQueue(data, options) {
21
+ return this.add(data || {}, options);
22
+ }
23
+ /**
24
+ * @deprecated use addJobToQueue instead
25
+ */
20
26
  async runJob(data, options) {
21
27
  return this.add(data || {}, options);
22
28
  }
@@ -64,7 +70,7 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
64
70
  }
65
71
  await this.addProcessor(mod, options.queueName, options.concurrency);
66
72
  if ((_c = options.jobOptions) === null || _c === void 0 ? void 0 : _c.repeat) {
67
- await this.runJob(options.queueName, {}, options.jobOptions);
73
+ await this.addJobToQueue(options.queueName, {}, options.jobOptions);
68
74
  }
69
75
  }
70
76
  }
@@ -124,12 +130,18 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
124
130
  }
125
131
  });
126
132
  }
127
- async runJob(queueName, jobData, options) {
133
+ async addJobToQueue(queueName, jobData, options) {
128
134
  const queue = this.queueMap.get(queueName);
129
135
  if (queue) {
130
- return await queue.runJob(jobData, options);
136
+ return await queue.addJobToQueue(jobData, options);
131
137
  }
132
138
  }
139
+ /**
140
+ * @deprecated use addJob instead
141
+ */
142
+ async runJob(queueName, jobData, options) {
143
+ return this.addJobToQueue(queueName, jobData, options);
144
+ }
133
145
  async getJob(queueName, jobName) {
134
146
  const queue = this.queueMap.get(queueName);
135
147
  if (queue) {
@@ -4,11 +4,19 @@ export interface IProcessor {
4
4
  execute(data: any): any;
5
5
  }
6
6
  export interface IQueue<Job> {
7
+ /**
8
+ * @deprecated use addJobToQueue instead
9
+ */
7
10
  runJob(data: Record<string, any>, options?: unknown): Promise<Job>;
11
+ addJobToQueue(data: Record<string, any>, options?: unknown): Promise<Job>;
8
12
  getJob(name: string): Promise<Job>;
9
13
  getQueueName(): string;
10
14
  }
11
15
  export interface IQueueManager<Queue extends IQueue<Job>, Job> {
16
+ addJobToQueue(queueName: string, jobData: any, options?: unknown): Promise<Job | undefined>;
17
+ /**
18
+ * @deprecated use addJobToQueue instead
19
+ */
12
20
  runJob(queueName: string, jobData: any, options?: unknown): Promise<Job | undefined>;
13
21
  getJob(queueName: string, jobName: string): Promise<Job>;
14
22
  createQueue(queueName: string, queueOptions?: unknown): Queue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/bull",
3
- "version": "3.20.0",
3
+ "version": "3.20.3",
4
4
  "description": "midway component for bull",
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.0",
28
- "@midwayjs/mock": "^3.20.0"
27
+ "@midwayjs/core": "^3.20.3",
28
+ "@midwayjs/mock": "^3.20.3"
29
29
  },
30
30
  "dependencies": {
31
31
  "bull": "4.16.5"
@@ -33,5 +33,5 @@
33
33
  "engines": {
34
34
  "node": ">=12"
35
35
  },
36
- "gitHead": "5bf838ec6054f6e1e983664b0456a975db795932"
36
+ "gitHead": "a0918e46838e220fd000997796dbc8d669d28746"
37
37
  }