@midwayjs/bull 3.0.5 → 3.6.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/LICENSE +21 -0
- package/dist/config/config.default.d.ts +1 -1
- package/dist/config/config.default.js +1 -1
- package/dist/configuration.d.ts +1 -1
- package/dist/configuration.js +5 -6
- package/dist/decorator.js +6 -6
- package/dist/framework.js +10 -5
- package/package.json +7 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013 - Now midwayjs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/configuration.d.ts
CHANGED
package/dist/configuration.js
CHANGED
|
@@ -10,10 +10,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BullConfiguration = void 0;
|
|
13
|
-
const
|
|
13
|
+
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const DefaultConfig = require("./config/config.default");
|
|
15
15
|
const framework_1 = require("./framework");
|
|
16
|
-
const core_1 = require("@midwayjs/core");
|
|
17
16
|
const constants_1 = require("./constants");
|
|
18
17
|
let BullConfiguration = class BullConfiguration {
|
|
19
18
|
async init() {
|
|
@@ -23,21 +22,21 @@ let BullConfiguration = class BullConfiguration {
|
|
|
23
22
|
}
|
|
24
23
|
};
|
|
25
24
|
__decorate([
|
|
26
|
-
(0,
|
|
25
|
+
(0, core_1.Inject)(),
|
|
27
26
|
__metadata("design:type", framework_1.BullFramework)
|
|
28
27
|
], BullConfiguration.prototype, "framework", void 0);
|
|
29
28
|
__decorate([
|
|
30
|
-
(0,
|
|
29
|
+
(0, core_1.Inject)(),
|
|
31
30
|
__metadata("design:type", core_1.MidwayDecoratorService)
|
|
32
31
|
], BullConfiguration.prototype, "decoratorService", void 0);
|
|
33
32
|
__decorate([
|
|
34
|
-
(0,
|
|
33
|
+
(0, core_1.Init)(),
|
|
35
34
|
__metadata("design:type", Function),
|
|
36
35
|
__metadata("design:paramtypes", []),
|
|
37
36
|
__metadata("design:returntype", Promise)
|
|
38
37
|
], BullConfiguration.prototype, "init", null);
|
|
39
38
|
BullConfiguration = __decorate([
|
|
40
|
-
(0,
|
|
39
|
+
(0, core_1.Configuration)({
|
|
41
40
|
namespace: 'bull',
|
|
42
41
|
importConfigs: [
|
|
43
42
|
{
|
package/dist/decorator.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InjectQueue = exports.Processor = void 0;
|
|
4
|
-
const
|
|
4
|
+
const core_1 = require("@midwayjs/core");
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
6
|
function Processor(queueName, concurrency, jobOptions) {
|
|
7
7
|
return function (target) {
|
|
@@ -9,19 +9,19 @@ function Processor(queueName, concurrency, jobOptions) {
|
|
|
9
9
|
jobOptions = concurrency;
|
|
10
10
|
concurrency = 1;
|
|
11
11
|
}
|
|
12
|
-
(0,
|
|
13
|
-
(0,
|
|
12
|
+
(0, core_1.saveModule)(constants_1.BULL_PROCESSOR_KEY, target);
|
|
13
|
+
(0, core_1.saveClassMetadata)(constants_1.BULL_PROCESSOR_KEY, {
|
|
14
14
|
queueName,
|
|
15
15
|
concurrency,
|
|
16
16
|
jobOptions,
|
|
17
17
|
}, target);
|
|
18
|
-
(0,
|
|
19
|
-
(0,
|
|
18
|
+
(0, core_1.Provide)()(target);
|
|
19
|
+
(0, core_1.Scope)(core_1.ScopeEnum.Request)(target);
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
exports.Processor = Processor;
|
|
23
23
|
function InjectQueue(queueName) {
|
|
24
|
-
return (0,
|
|
24
|
+
return (0, core_1.createCustomPropertyDecorator)(constants_1.BULL_QUEUE_KEY, {
|
|
25
25
|
queueName,
|
|
26
26
|
});
|
|
27
27
|
}
|
package/dist/framework.js
CHANGED
|
@@ -8,7 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.BullFramework = exports.BullQueue = void 0;
|
|
10
10
|
const core_1 = require("@midwayjs/core");
|
|
11
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
12
11
|
const Bull = require("bull");
|
|
13
12
|
const constants_1 = require("./constants");
|
|
14
13
|
class BullQueue extends Bull {
|
|
@@ -42,9 +41,9 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
42
41
|
}
|
|
43
42
|
async run() {
|
|
44
43
|
var _a;
|
|
45
|
-
const processorModules = (0,
|
|
44
|
+
const processorModules = (0, core_1.listModule)(constants_1.BULL_PROCESSOR_KEY);
|
|
46
45
|
for (const mod of processorModules) {
|
|
47
|
-
const options = (0,
|
|
46
|
+
const options = (0, core_1.getClassMetadata)(constants_1.BULL_PROCESSOR_KEY, mod);
|
|
48
47
|
const currentQueue = this.ensureQueue(options.queueName);
|
|
49
48
|
// clear old repeat job when start
|
|
50
49
|
if (this.bullClearRepeatJobWhenStart) {
|
|
@@ -91,9 +90,15 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
91
90
|
from: processor,
|
|
92
91
|
});
|
|
93
92
|
ctx.logger.info(`start process job ${job.id} from ${processor.name}`);
|
|
93
|
+
const isPassed = await this.app
|
|
94
|
+
.getFramework()
|
|
95
|
+
.runGuard(ctx, processor, 'execute');
|
|
96
|
+
if (!isPassed) {
|
|
97
|
+
throw new core_1.MidwayInvokeForbiddenError('execute', processor);
|
|
98
|
+
}
|
|
94
99
|
const service = await ctx.requestContext.getAsync(processor);
|
|
95
100
|
const fn = await this.applyMiddleware(async (ctx) => {
|
|
96
|
-
return await
|
|
101
|
+
return await core_1.Utils.toAsyncFunction(service.execute.bind(service))(job.data, job);
|
|
97
102
|
});
|
|
98
103
|
try {
|
|
99
104
|
const result = await Promise.resolve(await fn(ctx));
|
|
@@ -120,7 +125,7 @@ let BullFramework = class BullFramework extends core_1.BaseFramework {
|
|
|
120
125
|
}
|
|
121
126
|
};
|
|
122
127
|
BullFramework = __decorate([
|
|
123
|
-
(0,
|
|
128
|
+
(0, core_1.Framework)()
|
|
124
129
|
], BullFramework);
|
|
125
130
|
exports.BullFramework = BullFramework;
|
|
126
131
|
//# sourceMappingURL=framework.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/bull",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"description": "midway component for bull",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
],
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@midwayjs/core": "^3.
|
|
28
|
-
"@midwayjs/
|
|
29
|
-
"@midwayjs/mock": "^3.4.13"
|
|
27
|
+
"@midwayjs/core": "^3.6.0",
|
|
28
|
+
"@midwayjs/mock": "^3.6.0"
|
|
30
29
|
},
|
|
31
30
|
"dependencies": {
|
|
32
|
-
"bull": "
|
|
33
|
-
"
|
|
31
|
+
"@types/bull": "3.15.9",
|
|
32
|
+
"bull": "4.10.1"
|
|
34
33
|
},
|
|
35
34
|
"engines": {
|
|
36
35
|
"node": ">=12"
|
|
37
|
-
}
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "7aa8d1d712ff5ae7e3b27eb2e154d3f7ee40889a"
|
|
38
38
|
}
|