@rsdk/core 5.15.0-next.4 → 5.15.0-next.6
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/health/health.config.d.ts +4 -0
- package/dist/health/health.config.js +31 -0
- package/dist/health/health.config.js.map +1 -0
- package/dist/health/health.service.d.ts +3 -1
- package/dist/health/health.service.js +9 -3
- package/dist/health/health.service.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/health/health.config.ts +13 -0
- package/src/health/health.service.spec.ts +34 -0
- package/src/health/health.service.ts +5 -1
- package/src/index.ts +2 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.HealthChecksConfig = void 0;
|
|
13
|
+
const config_1 = require("../config");
|
|
14
|
+
const config_const_1 = require("../config/config.const");
|
|
15
|
+
let HealthChecksConfig = class HealthChecksConfig extends config_1.Config {
|
|
16
|
+
logging;
|
|
17
|
+
};
|
|
18
|
+
exports.HealthChecksConfig = HealthChecksConfig;
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, config_1.Property)('HEALTH_CHECK_LOGGING', new config_1.BoolParser(), {
|
|
21
|
+
defaultValue: true,
|
|
22
|
+
description: 'Enable trace logging of health check calls',
|
|
23
|
+
}),
|
|
24
|
+
__metadata("design:type", Boolean)
|
|
25
|
+
], HealthChecksConfig.prototype, "logging", void 0);
|
|
26
|
+
exports.HealthChecksConfig = HealthChecksConfig = __decorate([
|
|
27
|
+
(0, config_1.ConfigSection)({
|
|
28
|
+
tags: [config_const_1.ConfigTag.infrastructure, config_const_1.ConfigTag.logging],
|
|
29
|
+
})
|
|
30
|
+
], HealthChecksConfig);
|
|
31
|
+
//# sourceMappingURL=health.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.config.js","sourceRoot":"","sources":["../../src/health/health.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAwE;AACxE,yDAAmD;AAK5C,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,eAAM;IAKnC,OAAO,CAAW;CAC5B,CAAA;AANY,gDAAkB;AAKpB;IAJR,IAAA,iBAAQ,EAAC,sBAAsB,EAAE,IAAI,mBAAU,EAAE,EAAE;QAClD,YAAY,EAAE,IAAI;QAClB,WAAW,EAAE,4CAA4C;KAC1D,CAAC;;mDACyB;6BALhB,kBAAkB;IAH9B,IAAA,sBAAa,EAAC;QACb,IAAI,EAAE,CAAC,wBAAS,CAAC,cAAc,EAAE,wBAAS,CAAC,OAAO,CAAC;KACpD,CAAC;GACW,kBAAkB,CAM9B"}
|
|
@@ -3,14 +3,16 @@ import { ModuleRef } from '@nestjs/core';
|
|
|
3
3
|
import type { Constructor } from '@rsdk/common';
|
|
4
4
|
import { ILogger } from '@rsdk/logging';
|
|
5
5
|
import { RsdkMetadataProvider } from '@rsdk/metadata';
|
|
6
|
+
import { HealthChecksConfig } from './health.config';
|
|
6
7
|
import type { CheckSummary, HealthIndicator, IndicatorMetadata } from './types';
|
|
7
8
|
export declare class HealthChecksService implements OnModuleInit {
|
|
8
9
|
private readonly logger;
|
|
9
10
|
private readonly moduleRef;
|
|
10
11
|
private readonly rsdkMetadataProvider;
|
|
12
|
+
private readonly config;
|
|
11
13
|
private readonly indicators;
|
|
12
14
|
private readonly indicatorNames;
|
|
13
|
-
constructor(logger: ILogger, moduleRef: ModuleRef, rsdkMetadataProvider: RsdkMetadataProvider);
|
|
15
|
+
constructor(logger: ILogger, moduleRef: ModuleRef, rsdkMetadataProvider: RsdkMetadataProvider, config: HealthChecksConfig);
|
|
14
16
|
check(filter?: '*' | string): Promise<CheckSummary>;
|
|
15
17
|
iterateByIndicators(): [Constructor<HealthIndicator>, IndicatorMetadata][];
|
|
16
18
|
onModuleInit(): Promise<void>;
|
|
@@ -19,20 +19,25 @@ const metadata_1 = require("@rsdk/metadata");
|
|
|
19
19
|
const logging_1 = require("../logging");
|
|
20
20
|
const constants_1 = require("./metadata/constants");
|
|
21
21
|
const exceptions_1 = require("./exceptions");
|
|
22
|
+
const health_config_1 = require("./health.config");
|
|
22
23
|
const health_const_1 = require("./health.const");
|
|
23
24
|
let HealthChecksService = class HealthChecksService {
|
|
24
25
|
logger;
|
|
25
26
|
moduleRef;
|
|
26
27
|
rsdkMetadataProvider;
|
|
28
|
+
config;
|
|
27
29
|
indicators = { common: [] };
|
|
28
30
|
indicatorNames = new Map();
|
|
29
|
-
constructor(logger, moduleRef, rsdkMetadataProvider) {
|
|
31
|
+
constructor(logger, moduleRef, rsdkMetadataProvider, config) {
|
|
30
32
|
this.logger = logger;
|
|
31
33
|
this.moduleRef = moduleRef;
|
|
32
34
|
this.rsdkMetadataProvider = rsdkMetadataProvider;
|
|
35
|
+
this.config = config;
|
|
33
36
|
}
|
|
34
37
|
async check(filter) {
|
|
35
|
-
this.
|
|
38
|
+
if (this.config.logging) {
|
|
39
|
+
this.logger.trace('Checking health', { filter });
|
|
40
|
+
}
|
|
36
41
|
const indicators = this.filterIndicators(filter);
|
|
37
42
|
let success = true;
|
|
38
43
|
const summary = { details: {}, status: 'up' };
|
|
@@ -126,6 +131,7 @@ exports.HealthChecksService = HealthChecksService = __decorate([
|
|
|
126
131
|
(0, common_1.Injectable)(),
|
|
127
132
|
__param(0, (0, logging_1.InjectLogger)(HealthChecksService)),
|
|
128
133
|
__metadata("design:paramtypes", [Object, core_1.ModuleRef,
|
|
129
|
-
metadata_1.RsdkMetadataProvider
|
|
134
|
+
metadata_1.RsdkMetadataProvider,
|
|
135
|
+
health_config_1.HealthChecksConfig])
|
|
130
136
|
], HealthChecksService);
|
|
131
137
|
//# sourceMappingURL=health.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.service.js","sourceRoot":"","sources":["../../src/health/health.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,2CAA4C;AAC5C,uCAAyC;AAGzC,6CAAsD;AAEtD,wCAA0C;AAE1C,oDAA4E;AAE5E,6CAAoD;AACpD,iDAA4D;AAUrD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAKwB;IACnC;IACA;
|
|
1
|
+
{"version":3,"file":"health.service.js","sourceRoot":"","sources":["../../src/health/health.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,2CAA4C;AAC5C,uCAAyC;AAGzC,6CAAsD;AAEtD,wCAA0C;AAE1C,oDAA4E;AAE5E,6CAAoD;AACpD,mDAAqD;AACrD,iDAA4D;AAUrD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAKwB;IACnC;IACA;IACA;IAPF,UAAU,GAAuB,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAChD,cAAc,GAAG,IAAI,GAAG,EAA2B,CAAC;IAErE,YACsD,MAAe,EAClD,SAAoB,EACpB,oBAA0C,EAC1C,MAA0B;QAHS,WAAM,GAAN,MAAM,CAAS;QAClD,cAAS,GAAT,SAAS,CAAW;QACpB,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,WAAM,GAAN,MAAM,CAAoB;IA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ACN,gBAAS;QACE,+BAAoB;QAClC,kCAAkB;GARlC,mBAAmB,CAwI/B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { ProtocolDetector } from './transport/protocol.detector';
|
|
|
5
5
|
export { TracingHeaderMappings, Span, NoSpan } from './tracing';
|
|
6
6
|
export { FileSystemCheckOptions, FileSystemIndicator, PingCheckOptions, PingIndicator, } from './health/indicators.abstract';
|
|
7
7
|
export { HealthChecksService } from './health/health.service';
|
|
8
|
+
export { HealthChecksConfig } from './health/health.config';
|
|
8
9
|
export { CheckSummary } from './health/types';
|
|
9
10
|
export { getLoggerToken } from './logging/helpers';
|
|
10
11
|
export { Indicator } from './health/metadata/indicator.decorator';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.TracingHeaders = exports.PlatformApp = exports.register = exports.Summary = exports.MetricsModule = exports.Metric = exports.Histogram = exports.Gauge = exports.Counter = exports.InjectLogger = exports.PlatformContext = exports.ConfigTag = exports.CheckResult = exports.Indicator = exports.getLoggerToken = exports.HealthChecksService = exports.PingIndicator = exports.FileSystemIndicator = exports.NoSpan = exports.Span = exports.ProtocolDetector = exports.Manifest = exports.APP_SCOPE = void 0;
|
|
17
|
+
exports.TracingHeaders = exports.PlatformApp = exports.register = exports.Summary = exports.MetricsModule = exports.Metric = exports.Histogram = exports.Gauge = exports.Counter = exports.InjectLogger = exports.PlatformContext = exports.ConfigTag = exports.CheckResult = exports.Indicator = exports.getLoggerToken = exports.HealthChecksConfig = exports.HealthChecksService = exports.PingIndicator = exports.FileSystemIndicator = exports.NoSpan = exports.Span = exports.ProtocolDetector = exports.Manifest = exports.APP_SCOPE = void 0;
|
|
18
18
|
require("./unhandled-rejection.handler");
|
|
19
19
|
var app_metadata_const_1 = require("./app-metadata/app-metadata.const");
|
|
20
20
|
Object.defineProperty(exports, "APP_SCOPE", { enumerable: true, get: function () { return app_metadata_const_1.APP_SCOPE; } });
|
|
@@ -30,6 +30,8 @@ Object.defineProperty(exports, "FileSystemIndicator", { enumerable: true, get: f
|
|
|
30
30
|
Object.defineProperty(exports, "PingIndicator", { enumerable: true, get: function () { return indicators_abstract_1.PingIndicator; } });
|
|
31
31
|
var health_service_1 = require("./health/health.service");
|
|
32
32
|
Object.defineProperty(exports, "HealthChecksService", { enumerable: true, get: function () { return health_service_1.HealthChecksService; } });
|
|
33
|
+
var health_config_1 = require("./health/health.config");
|
|
34
|
+
Object.defineProperty(exports, "HealthChecksConfig", { enumerable: true, get: function () { return health_config_1.HealthChecksConfig; } });
|
|
33
35
|
var helpers_1 = require("./logging/helpers");
|
|
34
36
|
Object.defineProperty(exports, "getLoggerToken", { enumerable: true, get: function () { return helpers_1.getLoggerToken; } });
|
|
35
37
|
var indicator_decorator_1 = require("./health/metadata/indicator.decorator");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yCAAuC;AAEvC,wEAA8D;AAArD,+GAAA,SAAS,OAAA;AAElB,gDAA+C;AAAtC,oGAAA,QAAQ,OAAA;AAEjB,mEAAiE;AAAxD,qHAAA,gBAAgB,OAAA;AAEzB,qCAAgE;AAAhC,+FAAA,IAAI,OAAA;AAAE,iGAAA,MAAM,OAAA;AAE5C,oEAKsC;AAHpC,0HAAA,mBAAmB,OAAA;AAEnB,oHAAA,aAAa,OAAA;AAGf,0DAA8D;AAArD,qHAAA,mBAAmB,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yCAAuC;AAEvC,wEAA8D;AAArD,+GAAA,SAAS,OAAA;AAElB,gDAA+C;AAAtC,oGAAA,QAAQ,OAAA;AAEjB,mEAAiE;AAAxD,qHAAA,gBAAgB,OAAA;AAEzB,qCAAgE;AAAhC,+FAAA,IAAI,OAAA;AAAE,iGAAA,MAAM,OAAA;AAE5C,oEAKsC;AAHpC,0HAAA,mBAAmB,OAAA;AAEnB,oHAAA,aAAa,OAAA;AAGf,0DAA8D;AAArD,qHAAA,mBAAmB,OAAA;AAE5B,wDAA4D;AAAnD,mHAAA,kBAAkB,OAAA;AAI3B,6CAAmD;AAA1C,yGAAA,cAAc,OAAA;AAEvB,6EAAkE;AAAzD,gHAAA,SAAS,OAAA;AAIlB,4CAA+C;AAAtC,sGAAA,WAAW,OAAA;AAEpB,sDAAkD;AAAzC,yGAAA,SAAS,OAAA;AAElB,uDAAqD;AAA5C,mHAAA,eAAe,OAAA;AAExB,2CAAyB;AAEzB,+CAA6B;AAE7B,wDAAsC;AAEtC,qCAAyC;AAAhC,uGAAA,YAAY,OAAA;AAErB,qCASmB;AAPjB,kGAAA,OAAO,OAAA;AACP,gGAAA,KAAK,OAAA;AACL,oGAAA,SAAS,OAAA;AACT,iGAAA,MAAM,OAAA;AACN,wGAAA,aAAa,OAAA;AACb,kGAAA,OAAO,OAAA;AACP,mGAAA,QAAQ,OAAA;AAGV,mDAAiD;AAAxC,2GAAA,WAAW,OAAA;AAEpB,0CAAwB;AAExB,4DAA0C;AAE1C,oEAAkD;AAElD,qCAA2C;AAAlC,yGAAA,cAAc,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/core",
|
|
3
|
-
"version": "5.15.0-next.
|
|
3
|
+
"version": "5.15.0-next.6",
|
|
4
4
|
"description": "Nestjs based microservice chassis",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"optional": true
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "02b2a6b9b7aa58419075323fce9d20846c920b6d"
|
|
58
58
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BoolParser, Config, ConfigSection, Property } from '../config';
|
|
2
|
+
import { ConfigTag } from '../config/config.const';
|
|
3
|
+
|
|
4
|
+
@ConfigSection({
|
|
5
|
+
tags: [ConfigTag.infrastructure, ConfigTag.logging],
|
|
6
|
+
})
|
|
7
|
+
export class HealthChecksConfig extends Config {
|
|
8
|
+
@Property('HEALTH_CHECK_LOGGING', new BoolParser(), {
|
|
9
|
+
defaultValue: true,
|
|
10
|
+
description: 'Enable trace logging of health check calls',
|
|
11
|
+
})
|
|
12
|
+
readonly logging!: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ModuleRef } from '@nestjs/core';
|
|
2
|
+
import type { ILogger } from '@rsdk/logging';
|
|
3
|
+
import type { RsdkMetadataProvider } from '@rsdk/metadata';
|
|
4
|
+
|
|
5
|
+
import type { HealthChecksConfig } from './health.config';
|
|
6
|
+
import { HealthChecksService } from './health.service';
|
|
7
|
+
|
|
8
|
+
function check(logging: boolean): Promise<ILogger> {
|
|
9
|
+
const logger = { trace: jest.fn() } as unknown as ILogger;
|
|
10
|
+
const service = new HealthChecksService(
|
|
11
|
+
logger,
|
|
12
|
+
{} as ModuleRef,
|
|
13
|
+
{} as RsdkMetadataProvider,
|
|
14
|
+
{ logging } as HealthChecksConfig,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
return service.check().then(() => logger);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe('HealthChecksService — HEALTH_CHECK_LOGGING', () => {
|
|
21
|
+
it('логирует вызов при true', async () => {
|
|
22
|
+
const logger = await check(true);
|
|
23
|
+
|
|
24
|
+
expect(logger.trace).toHaveBeenCalledWith('Checking health', {
|
|
25
|
+
filter: undefined,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('не логирует вызов при false', async () => {
|
|
30
|
+
const logger = await check(false);
|
|
31
|
+
|
|
32
|
+
expect(logger.trace).not.toHaveBeenCalled();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -10,6 +10,7 @@ import { InjectLogger } from '../logging';
|
|
|
10
10
|
import { HEALTH_INDICATOR_RSDK_METADATA_SCOPE } from './metadata/constants';
|
|
11
11
|
import type { HealthIndicatorRsdkMetadata } from './metadata/types';
|
|
12
12
|
import { HealthCheckException } from './exceptions';
|
|
13
|
+
import { HealthChecksConfig } from './health.config';
|
|
13
14
|
import { DEFAULT_HEALTH_CHECK_SCOPE } from './health.const';
|
|
14
15
|
import type {
|
|
15
16
|
CheckSummary,
|
|
@@ -28,10 +29,13 @@ export class HealthChecksService implements OnModuleInit {
|
|
|
28
29
|
@InjectLogger(HealthChecksService) private readonly logger: ILogger,
|
|
29
30
|
private readonly moduleRef: ModuleRef,
|
|
30
31
|
private readonly rsdkMetadataProvider: RsdkMetadataProvider,
|
|
32
|
+
private readonly config: HealthChecksConfig,
|
|
31
33
|
) {}
|
|
32
34
|
|
|
33
35
|
async check(filter?: '*' | string): Promise<CheckSummary> {
|
|
34
|
-
this.
|
|
36
|
+
if (this.config.logging) {
|
|
37
|
+
this.logger.trace('Checking health', { filter });
|
|
38
|
+
}
|
|
35
39
|
|
|
36
40
|
const indicators = this.filterIndicators(filter);
|
|
37
41
|
|
package/src/index.ts
CHANGED