@midwayjs/bull 3.0.2 → 3.0.4
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.
|
@@ -2,10 +2,14 @@ export declare const bull: {
|
|
|
2
2
|
defaultQueueOptions: {
|
|
3
3
|
prefix: string;
|
|
4
4
|
};
|
|
5
|
+
defaultJobOptions: {
|
|
6
|
+
removeOnSuccess: boolean;
|
|
7
|
+
removeOnFail: number;
|
|
8
|
+
};
|
|
9
|
+
defaultConcurrency: number;
|
|
10
|
+
clearRepeatJobWhenStart: boolean;
|
|
5
11
|
contextLoggerApplyLogger: string;
|
|
6
12
|
contextLoggerFormat: (info: any) => string;
|
|
7
|
-
defaultConcurrency: number;
|
|
8
|
-
clearJobWhenStart: boolean;
|
|
9
13
|
};
|
|
10
14
|
export declare const midwayLogger: {
|
|
11
15
|
clients: {
|
|
@@ -3,15 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.midwayLogger = exports.bull = void 0;
|
|
4
4
|
exports.bull = {
|
|
5
5
|
defaultQueueOptions: {
|
|
6
|
-
prefix: 'midway-
|
|
6
|
+
prefix: '${midway-bull}',
|
|
7
7
|
},
|
|
8
|
+
defaultJobOptions: {
|
|
9
|
+
removeOnSuccess: true,
|
|
10
|
+
removeOnFail: 10,
|
|
11
|
+
},
|
|
12
|
+
defaultConcurrency: 1,
|
|
13
|
+
clearRepeatJobWhenStart: true,
|
|
8
14
|
contextLoggerApplyLogger: 'bullLogger',
|
|
9
15
|
contextLoggerFormat: info => {
|
|
10
|
-
const { jobId,
|
|
11
|
-
return `${info.timestamp} ${info.LEVEL} ${info.pid} [${jobId} ${
|
|
16
|
+
const { jobId, from } = info.ctx;
|
|
17
|
+
return `${info.timestamp} ${info.LEVEL} ${info.pid} [${jobId} ${from.name}}] ${info.message}`;
|
|
12
18
|
},
|
|
13
|
-
defaultConcurrency: 1,
|
|
14
|
-
clearJobWhenStart: true,
|
|
15
19
|
};
|
|
16
20
|
exports.midwayLogger = {
|
|
17
21
|
clients: {
|
package/dist/framework.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare class BullQueue extends Bull implements IQueue<Job> {
|
|
|
10
10
|
export declare class BullFramework extends BaseFramework<Application, Context, any> implements IQueueManager<BullQueue, Job> {
|
|
11
11
|
private bullDefaultQueueConfig;
|
|
12
12
|
private bullDefaultConcurrency;
|
|
13
|
-
private
|
|
13
|
+
private bullClearRepeatJobWhenStart;
|
|
14
14
|
private queueMap;
|
|
15
15
|
applicationInitialize(options: IMidwayBootstrapOptions): Promise<void>;
|
|
16
16
|
configure(): any;
|
package/dist/framework.js
CHANGED
|
@@ -32,7 +32,7 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
32
32
|
this.app = {};
|
|
33
33
|
this.bullDefaultQueueConfig = this.configService.getConfiguration('bull.defaultQueueOptions');
|
|
34
34
|
this.bullDefaultConcurrency = this.configService.getConfiguration('bull.defaultConcurrency');
|
|
35
|
-
this.
|
|
35
|
+
this.bullClearRepeatJobWhenStart = this.configService.getConfiguration('bull.clearRepeatJobWhenStart');
|
|
36
36
|
}
|
|
37
37
|
configure() {
|
|
38
38
|
return this.configService.getConfiguration('bull');
|
|
@@ -45,10 +45,13 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
45
45
|
const processorModules = (0, decorator_1.listModule)(constants_1.BULL_PROCESSOR_KEY);
|
|
46
46
|
for (const mod of processorModules) {
|
|
47
47
|
const options = (0, decorator_1.getClassMetadata)(constants_1.BULL_PROCESSOR_KEY, mod);
|
|
48
|
-
this.ensureQueue(options.queueName);
|
|
49
|
-
// clear old job when start
|
|
50
|
-
if (this.
|
|
51
|
-
await
|
|
48
|
+
const currentQueue = this.ensureQueue(options.queueName);
|
|
49
|
+
// clear old repeat job when start
|
|
50
|
+
if (this.bullClearRepeatJobWhenStart) {
|
|
51
|
+
const jobs = await currentQueue.getRepeatableJobs();
|
|
52
|
+
for (const job of jobs) {
|
|
53
|
+
await currentQueue.removeRepeatableByKey(job.key);
|
|
54
|
+
}
|
|
52
55
|
}
|
|
53
56
|
await this.addProcessor(mod, options.queueName, options.concurrency);
|
|
54
57
|
if ((_a = options.jobOptions) === null || _a === void 0 ? void 0 : _a.repeat) {
|
package/index.d.ts
CHANGED