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 | Object.defineProperty(exports, "__esModule", { value: true });
|
9 | const Lifecycle_1 = require("../ioc/Lifecycle");
|
10 | const Decorators_1 = require("../ioc/Decorators");
|
11 | const HealthCheck_1 = require("./HealthCheck");
|
12 | let ContextReadyHealthCheck = class ContextReadyHealthCheck extends HealthCheck_1.HealthCheck {
|
13 | constructor() {
|
14 | super('context', 5000);
|
15 | }
|
16 | getType() {
|
17 | return HealthCheck_1.HealthCheckType.CONTEXT;
|
18 | }
|
19 | async doCheck() {
|
20 | if (!this.context) {
|
21 | return new HealthCheck_1.HealthCheckResult(HealthCheck_1.HealthCheckStatus.NOT_READY, `Context not wired`);
|
22 | }
|
23 | const contextStatus = this.context.getStatus();
|
24 | if (contextStatus === Lifecycle_1.LifecycleState.NOT_STARTED || contextStatus === Lifecycle_1.LifecycleState.STARTING) {
|
25 | return new HealthCheck_1.HealthCheckResult(HealthCheck_1.HealthCheckStatus.NOT_READY, `Context not ready. Still in status: ${contextStatus.getName()}`);
|
26 | }
|
27 | else if (contextStatus === Lifecycle_1.LifecycleState.STARTED) {
|
28 | return new HealthCheck_1.HealthCheckResult(HealthCheck_1.HealthCheckStatus.OK, `Context STARTED`);
|
29 | }
|
30 | else {
|
31 | return new HealthCheck_1.HealthCheckResult(HealthCheck_1.HealthCheckStatus.STOPPING, `Context STOPPING`);
|
32 | }
|
33 | }
|
34 | };
|
35 | __decorate([
|
36 | Decorators_1.AutowireContext
|
37 | ], ContextReadyHealthCheck.prototype, "context", void 0);
|
38 | ContextReadyHealthCheck = __decorate([
|
39 | HealthCheck_1.RegisterAsHealthCheck
|
40 | ], ContextReadyHealthCheck);
|
41 | exports.ContextReadyHealthCheck = ContextReadyHealthCheck;
|
42 |
|
\ | No newline at end of file |