UNPKG

inceptum

Version:

hipages take on the foundational library for enterprise-grade apps written in NodeJS

36 lines 1.8 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.MySQLHealthCheck = void 0; const HealthCheck_1 = require("../health/HealthCheck"); let MySQLHealthCheck = class MySQLHealthCheck extends HealthCheck_1.HealthCheck { constructor(name, readonly) { super(name, 60000, 2, true); this.readonly = readonly; } getType() { return HealthCheck_1.HealthCheckType.DEPENDENCY; } async doCheck() { if (!this.mysqlClient) { return new HealthCheck_1.HealthCheckResult(HealthCheck_1.HealthCheckStatus.NOT_READY, 'MySQL Client not set yet'); } try { await this.mysqlClient.ping(this.readonly); return new HealthCheck_1.HealthCheckResult(HealthCheck_1.HealthCheckStatus.OK, 'Ping OK'); } catch (e) { return new HealthCheck_1.HealthCheckResult(HealthCheck_1.HealthCheckStatus.CRITICAL, `Couldn't ping DB ${this.readonly ? 'slave' : 'master'}: ${e.message}`, new Date().getTime(), e); } } }; MySQLHealthCheck = __decorate([ HealthCheck_1.RegisterAsHealthCheck ], MySQLHealthCheck); exports.MySQLHealthCheck = MySQLHealthCheck; //# sourceMappingURL=MySQLHealthCheck.js.map