@midwayjs/bull 3.20.4 → 4.0.0-beta.1
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.
|
@@ -8,13 +8,12 @@ export declare const bull: {
|
|
|
8
8
|
};
|
|
9
9
|
defaultConcurrency: number;
|
|
10
10
|
clearRepeatJobWhenStart: boolean;
|
|
11
|
-
contextLoggerApplyLogger: string;
|
|
12
|
-
contextLoggerFormat: (info: any) => string;
|
|
13
11
|
};
|
|
14
12
|
export declare const midwayLogger: {
|
|
15
13
|
clients: {
|
|
16
14
|
bullLogger: {
|
|
17
15
|
fileLogName: string;
|
|
16
|
+
contextFormat: (info: any) => string;
|
|
18
17
|
};
|
|
19
18
|
};
|
|
20
19
|
};
|
|
@@ -11,16 +11,15 @@ exports.bull = {
|
|
|
11
11
|
},
|
|
12
12
|
defaultConcurrency: 1,
|
|
13
13
|
clearRepeatJobWhenStart: true,
|
|
14
|
-
contextLoggerApplyLogger: 'bullLogger',
|
|
15
|
-
contextLoggerFormat: info => {
|
|
16
|
-
const { jobId, from } = info.ctx;
|
|
17
|
-
return `${info.timestamp} ${info.LEVEL} ${info.pid} [${jobId} ${from.name}] ${info.message}`;
|
|
18
|
-
},
|
|
19
14
|
};
|
|
20
15
|
exports.midwayLogger = {
|
|
21
16
|
clients: {
|
|
22
17
|
bullLogger: {
|
|
23
18
|
fileLogName: 'midway-bull.log',
|
|
19
|
+
contextFormat: info => {
|
|
20
|
+
const { jobId, from } = info.ctx;
|
|
21
|
+
return `${info.timestamp} ${info.LEVEL} ${info.pid} [${jobId} ${from.name}] ${info.message}`;
|
|
22
|
+
},
|
|
24
23
|
},
|
|
25
24
|
},
|
|
26
25
|
};
|
package/dist/configuration.js
CHANGED
|
@@ -24,6 +24,7 @@ let BullConfiguration = class BullConfiguration {
|
|
|
24
24
|
this.framework.loadConfig();
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
+
exports.BullConfiguration = BullConfiguration;
|
|
27
28
|
__decorate([
|
|
28
29
|
(0, core_1.Inject)(),
|
|
29
30
|
__metadata("design:type", framework_1.BullFramework)
|
|
@@ -38,7 +39,7 @@ __decorate([
|
|
|
38
39
|
__metadata("design:paramtypes", []),
|
|
39
40
|
__metadata("design:returntype", Promise)
|
|
40
41
|
], BullConfiguration.prototype, "init", null);
|
|
41
|
-
BullConfiguration = __decorate([
|
|
42
|
+
exports.BullConfiguration = BullConfiguration = __decorate([
|
|
42
43
|
(0, core_1.Configuration)({
|
|
43
44
|
namespace: 'bull',
|
|
44
45
|
importConfigs: [
|
|
@@ -48,5 +49,4 @@ BullConfiguration = __decorate([
|
|
|
48
49
|
],
|
|
49
50
|
})
|
|
50
51
|
], BullConfiguration);
|
|
51
|
-
exports.BullConfiguration = BullConfiguration;
|
|
52
52
|
//# sourceMappingURL=configuration.js.map
|
package/dist/decorator.js
CHANGED
|
@@ -10,8 +10,8 @@ function Processor(queueName, concurrency, jobOptions, queueOptions) {
|
|
|
10
10
|
jobOptions = { ...concurrency };
|
|
11
11
|
concurrency = 1;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
core_1.DecoratorManager.saveModule(constants_1.BULL_PROCESSOR_KEY, target);
|
|
14
|
+
core_1.MetadataManager.defineMetadata(constants_1.BULL_PROCESSOR_KEY, {
|
|
15
15
|
queueName,
|
|
16
16
|
concurrency,
|
|
17
17
|
jobOptions,
|
|
@@ -23,7 +23,7 @@ function Processor(queueName, concurrency, jobOptions, queueOptions) {
|
|
|
23
23
|
}
|
|
24
24
|
exports.Processor = Processor;
|
|
25
25
|
function InjectQueue(queueName) {
|
|
26
|
-
return
|
|
26
|
+
return core_1.DecoratorManager.createCustomPropertyDecorator(constants_1.BULL_QUEUE_KEY, {
|
|
27
27
|
queueName,
|
|
28
28
|
});
|
|
29
29
|
}
|
package/dist/framework.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseFramework, IMidwayBootstrapOptions
|
|
1
|
+
import { BaseFramework, IMidwayBootstrapOptions } from '@midwayjs/core';
|
|
2
2
|
import { Application, Context, IProcessor, IQueue, IQueueManager } from './interface';
|
|
3
3
|
import { Job, JobOptions, QueueOptions } from 'bull';
|
|
4
4
|
import Bull = require('bull');
|
|
@@ -16,7 +16,7 @@ export declare class BullFramework extends BaseFramework<Application, Context, a
|
|
|
16
16
|
private bullDefaultConcurrency;
|
|
17
17
|
private bullClearRepeatJobWhenStart;
|
|
18
18
|
private queueMap;
|
|
19
|
-
protected
|
|
19
|
+
protected frameworkLoggerName: string;
|
|
20
20
|
applicationInitialize(options: IMidwayBootstrapOptions): Promise<void>;
|
|
21
21
|
loadConfig(): void;
|
|
22
22
|
configure(): any;
|
package/dist/framework.js
CHANGED
|
@@ -5,9 +5,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
9
|
exports.BullFramework = exports.BullQueue = void 0;
|
|
13
10
|
const core_1 = require("@midwayjs/core");
|
|
@@ -35,6 +32,7 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
35
32
|
constructor() {
|
|
36
33
|
super(...arguments);
|
|
37
34
|
this.queueMap = new Map();
|
|
35
|
+
this.frameworkLoggerName = 'bullLogger';
|
|
38
36
|
}
|
|
39
37
|
async applicationInitialize(options) {
|
|
40
38
|
this.app = {};
|
|
@@ -51,12 +49,11 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
51
49
|
return 'bull';
|
|
52
50
|
}
|
|
53
51
|
async run() {
|
|
54
|
-
|
|
55
|
-
const processorModules = (0, core_1.listModule)(constants_1.BULL_PROCESSOR_KEY);
|
|
52
|
+
const processorModules = core_1.DecoratorManager.listModule(constants_1.BULL_PROCESSOR_KEY);
|
|
56
53
|
for (const mod of processorModules) {
|
|
57
|
-
const options =
|
|
58
|
-
const { repeat, delay, ...otherOptions } =
|
|
59
|
-
const queueOptions =
|
|
54
|
+
const options = core_1.MetadataManager.getOwnMetadata(constants_1.BULL_PROCESSOR_KEY, mod);
|
|
55
|
+
const { repeat, delay, ...otherOptions } = options.jobOptions ?? {};
|
|
56
|
+
const queueOptions = options.queueOptions ?? {};
|
|
60
57
|
const currentQueue = this.ensureQueue(options.queueName, {
|
|
61
58
|
...queueOptions,
|
|
62
59
|
defaultJobOptions: otherOptions,
|
|
@@ -69,7 +66,7 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
68
|
await this.addProcessor(mod, options.queueName, options.concurrency);
|
|
72
|
-
if (
|
|
69
|
+
if (options.jobOptions?.repeat) {
|
|
73
70
|
await this.addJobToQueue(options.queueName, {}, options.jobOptions);
|
|
74
71
|
}
|
|
75
72
|
}
|
|
@@ -84,7 +81,7 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
84
81
|
const queue = new BullQueue(name, (0, core_1.extend)(true, {}, this.bullDefaultQueueConfig, queueOptions));
|
|
85
82
|
this.queueMap.set(name, queue);
|
|
86
83
|
queue.on('error', err => {
|
|
87
|
-
this.
|
|
84
|
+
this.logger.error(err);
|
|
88
85
|
});
|
|
89
86
|
return queue;
|
|
90
87
|
}
|
|
@@ -102,7 +99,7 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
102
99
|
}
|
|
103
100
|
async addProcessor(processor, queueName, concurrency) {
|
|
104
101
|
const queue = typeof queueName === 'string' ? this.queueMap.get(queueName) : queueName;
|
|
105
|
-
queue.process(concurrency
|
|
102
|
+
queue.process(concurrency ?? this.bullDefaultConcurrency, async (job) => {
|
|
106
103
|
const ctx = this.app.createAnonymousContext({
|
|
107
104
|
jobId: job.id,
|
|
108
105
|
job,
|
|
@@ -149,12 +146,8 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
149
146
|
}
|
|
150
147
|
}
|
|
151
148
|
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
__metadata("design:type", Object)
|
|
155
|
-
], BullFramework.prototype, "bullLogger", void 0);
|
|
156
|
-
BullFramework = __decorate([
|
|
149
|
+
exports.BullFramework = BullFramework;
|
|
150
|
+
exports.BullFramework = BullFramework = __decorate([
|
|
157
151
|
(0, core_1.Framework)()
|
|
158
152
|
], BullFramework);
|
|
159
|
-
exports.BullFramework = BullFramework;
|
|
160
153
|
//# sourceMappingURL=framework.js.map
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/bull",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-beta.1",
|
|
4
4
|
"description": "midway component for bull",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
-
"test": "node
|
|
10
|
-
"cov": "node
|
|
9
|
+
"test": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand",
|
|
10
|
+
"cov": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --coverage --forceExit"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
13
13
|
"midway",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
],
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@midwayjs/core": "^
|
|
28
|
-
"@midwayjs/mock": "^
|
|
27
|
+
"@midwayjs/core": "^4.0.0-beta.1",
|
|
28
|
+
"@midwayjs/mock": "^4.0.0-beta.1"
|
|
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": "
|
|
36
|
+
"gitHead": "832961ec3aff123c033197d8c00cb2bc9bad7ff8"
|
|
37
37
|
}
|