@midwayjs/core 3.14.3 → 3.14.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.
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { HealthResults, IMidwayContainer } from '../interface';
|
|
2
2
|
import { MidwayConfigService } from './configService';
|
|
3
|
-
import { MidwayLifeCycleService } from './lifeCycleService';
|
|
4
3
|
export declare class MidwayHealthService {
|
|
5
4
|
protected configService: MidwayConfigService;
|
|
6
|
-
protected lifeCycleService: MidwayLifeCycleService;
|
|
7
5
|
protected applicationContext: IMidwayContainer;
|
|
8
6
|
private healthCheckTimeout;
|
|
9
7
|
private healthCheckMethods;
|
|
10
|
-
|
|
8
|
+
init(lifeCycleInstanceList: Array<{
|
|
9
|
+
target: any;
|
|
10
|
+
namespace: string;
|
|
11
|
+
instance?: any;
|
|
12
|
+
}>): Promise<void>;
|
|
11
13
|
getStatus(): Promise<HealthResults>;
|
|
12
14
|
setCheckTimeout(timeout: number): void;
|
|
13
15
|
}
|
|
@@ -13,17 +13,16 @@ exports.MidwayHealthService = void 0;
|
|
|
13
13
|
const decorator_1 = require("../decorator");
|
|
14
14
|
const interface_1 = require("../interface");
|
|
15
15
|
const configService_1 = require("./configService");
|
|
16
|
-
const lifeCycleService_1 = require("./lifeCycleService");
|
|
17
16
|
const util_1 = require("../util");
|
|
18
17
|
let MidwayHealthService = class MidwayHealthService {
|
|
19
18
|
constructor() {
|
|
20
19
|
this.healthCheckTimeout = 1000;
|
|
21
20
|
this.healthCheckMethods = [];
|
|
22
21
|
}
|
|
23
|
-
async init() {
|
|
22
|
+
async init(lifeCycleInstanceList) {
|
|
24
23
|
const healthCheckTimeout = this.configService.getConfiguration('core.healthCheckTimeout') || 1000;
|
|
25
24
|
this.setCheckTimeout(healthCheckTimeout);
|
|
26
|
-
for (const lifecycleInstance of
|
|
25
|
+
for (const lifecycleInstance of lifeCycleInstanceList) {
|
|
27
26
|
if (lifecycleInstance.instance &&
|
|
28
27
|
lifecycleInstance.instance['onHealthCheck']) {
|
|
29
28
|
this.healthCheckMethods.push({
|
|
@@ -84,20 +83,10 @@ __decorate([
|
|
|
84
83
|
(0, decorator_1.Inject)(),
|
|
85
84
|
__metadata("design:type", configService_1.MidwayConfigService)
|
|
86
85
|
], MidwayHealthService.prototype, "configService", void 0);
|
|
87
|
-
__decorate([
|
|
88
|
-
(0, decorator_1.Inject)(),
|
|
89
|
-
__metadata("design:type", lifeCycleService_1.MidwayLifeCycleService)
|
|
90
|
-
], MidwayHealthService.prototype, "lifeCycleService", void 0);
|
|
91
86
|
__decorate([
|
|
92
87
|
(0, decorator_1.ApplicationContext)(),
|
|
93
88
|
__metadata("design:type", Object)
|
|
94
89
|
], MidwayHealthService.prototype, "applicationContext", void 0);
|
|
95
|
-
__decorate([
|
|
96
|
-
(0, decorator_1.Init)(),
|
|
97
|
-
__metadata("design:type", Function),
|
|
98
|
-
__metadata("design:paramtypes", []),
|
|
99
|
-
__metadata("design:returntype", Promise)
|
|
100
|
-
], MidwayHealthService.prototype, "init", null);
|
|
101
90
|
MidwayHealthService = __decorate([
|
|
102
91
|
(0, decorator_1.Provide)(),
|
|
103
92
|
(0, decorator_1.Scope)(interface_1.ScopeEnum.Singleton)
|
|
@@ -2,11 +2,13 @@ import { IMidwayContainer } from '../interface';
|
|
|
2
2
|
import { MidwayFrameworkService } from './frameworkService';
|
|
3
3
|
import { MidwayConfigService } from './configService';
|
|
4
4
|
import { MidwayMockService } from './mockService';
|
|
5
|
+
import { MidwayHealthService } from './healthService';
|
|
5
6
|
export declare class MidwayLifeCycleService {
|
|
6
7
|
readonly applicationContext: IMidwayContainer;
|
|
7
8
|
protected frameworkService: MidwayFrameworkService;
|
|
8
9
|
protected configService: MidwayConfigService;
|
|
9
10
|
protected mockService: MidwayMockService;
|
|
11
|
+
protected healthService: MidwayHealthService;
|
|
10
12
|
private lifecycleInstanceList;
|
|
11
13
|
constructor(applicationContext: IMidwayContainer);
|
|
12
14
|
protected init(): Promise<void>;
|
|
@@ -17,6 +17,7 @@ const frameworkService_1 = require("./frameworkService");
|
|
|
17
17
|
const configService_1 = require("./configService");
|
|
18
18
|
const util_1 = require("util");
|
|
19
19
|
const mockService_1 = require("./mockService");
|
|
20
|
+
const healthService_1 = require("./healthService");
|
|
20
21
|
const debug = (0, util_1.debuglog)('midway:debug');
|
|
21
22
|
let MidwayLifeCycleService = class MidwayLifeCycleService {
|
|
22
23
|
constructor(applicationContext) {
|
|
@@ -41,6 +42,8 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
|
|
|
41
42
|
}
|
|
42
43
|
cycle.instance && this.lifecycleInstanceList.push(cycle);
|
|
43
44
|
}
|
|
45
|
+
// init health check service
|
|
46
|
+
await this.healthService.init(this.lifecycleInstanceList);
|
|
44
47
|
// bind object lifecycle
|
|
45
48
|
await Promise.all([
|
|
46
49
|
this.runObjectLifeCycle(this.lifecycleInstanceList, 'onBeforeObjectCreated'),
|
|
@@ -143,6 +146,10 @@ __decorate([
|
|
|
143
146
|
(0, decorator_1.Inject)(),
|
|
144
147
|
__metadata("design:type", mockService_1.MidwayMockService)
|
|
145
148
|
], MidwayLifeCycleService.prototype, "mockService", void 0);
|
|
149
|
+
__decorate([
|
|
150
|
+
(0, decorator_1.Inject)(),
|
|
151
|
+
__metadata("design:type", healthService_1.MidwayHealthService)
|
|
152
|
+
], MidwayLifeCycleService.prototype, "healthService", void 0);
|
|
146
153
|
__decorate([
|
|
147
154
|
(0, decorator_1.Init)(),
|
|
148
155
|
__metadata("design:type", Function),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.4",
|
|
4
4
|
"description": "midway core",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=12"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "72aacdfd87ef730f100690557de48dcbd4d806a7"
|
|
46
46
|
}
|