@midwayjs/bull 3.19.2 → 4.0.0-alpha.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.
- package/dist/configuration.js +2 -2
- package/dist/decorator.js +3 -3
- package/dist/framework.js +8 -9
- package/package.json +6 -6
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.js
CHANGED
|
@@ -45,12 +45,11 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
45
45
|
return 'bull';
|
|
46
46
|
}
|
|
47
47
|
async run() {
|
|
48
|
-
|
|
49
|
-
const processorModules = (0, core_1.listModule)(constants_1.BULL_PROCESSOR_KEY);
|
|
48
|
+
const processorModules = core_1.DecoratorManager.listModule(constants_1.BULL_PROCESSOR_KEY);
|
|
50
49
|
for (const mod of processorModules) {
|
|
51
|
-
const options =
|
|
52
|
-
const { repeat, delay, ...otherOptions } =
|
|
53
|
-
const queueOptions =
|
|
50
|
+
const options = core_1.MetadataManager.getOwnMetadata(constants_1.BULL_PROCESSOR_KEY, mod);
|
|
51
|
+
const { repeat, delay, ...otherOptions } = options.jobOptions ?? {};
|
|
52
|
+
const queueOptions = options.queueOptions ?? {};
|
|
54
53
|
const currentQueue = this.ensureQueue(options.queueName, {
|
|
55
54
|
...queueOptions,
|
|
56
55
|
defaultJobOptions: otherOptions,
|
|
@@ -63,7 +62,7 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
await this.addProcessor(mod, options.queueName, options.concurrency);
|
|
66
|
-
if (
|
|
65
|
+
if (options.jobOptions?.repeat) {
|
|
67
66
|
await this.runJob(options.queueName, {}, options.jobOptions);
|
|
68
67
|
}
|
|
69
68
|
}
|
|
@@ -96,7 +95,7 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
96
95
|
}
|
|
97
96
|
async addProcessor(processor, queueName, concurrency) {
|
|
98
97
|
const queue = typeof queueName === 'string' ? this.queueMap.get(queueName) : queueName;
|
|
99
|
-
queue.process(concurrency
|
|
98
|
+
queue.process(concurrency ?? this.bullDefaultConcurrency, async (job) => {
|
|
100
99
|
const ctx = this.app.createAnonymousContext({
|
|
101
100
|
jobId: job.id,
|
|
102
101
|
job,
|
|
@@ -137,12 +136,12 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
138
|
};
|
|
139
|
+
exports.BullFramework = BullFramework;
|
|
140
140
|
__decorate([
|
|
141
141
|
(0, core_1.Logger)('bullLogger'),
|
|
142
142
|
__metadata("design:type", Object)
|
|
143
143
|
], BullFramework.prototype, "bullLogger", void 0);
|
|
144
|
-
BullFramework = __decorate([
|
|
144
|
+
exports.BullFramework = BullFramework = __decorate([
|
|
145
145
|
(0, core_1.Framework)()
|
|
146
146
|
], BullFramework);
|
|
147
|
-
exports.BullFramework = BullFramework;
|
|
148
147
|
//# 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-alpha.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-alpha.1",
|
|
28
|
+
"@midwayjs/mock": "^4.0.0-alpha.1"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"bull": "4.16.4"
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=12"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "14bb4da91805a1cf52f190c0d37a74b395dd6372"
|
|
37
37
|
}
|