UNPKG

nestjs-temporal-core

Version:

Complete NestJS integration for Temporal.io with auto-discovery, declarative scheduling, enhanced monitoring, and enterprise-ready features

77 lines 3.9 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; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TemporalHealthController = void 0; const common_1 = require("@nestjs/common"); const temporal_service_1 = require("../services/temporal.service"); let TemporalHealthController = class TemporalHealthController { constructor(temporalService) { this.temporalService = temporalService; } async getHealth() { const overallHealth = await this.temporalService.getOverallHealth(); const serviceStats = this.temporalService.getStats(); const workerStatus = this.temporalService.getWorkerStatus(); const components = overallHealth.components; const healthyComponents = Object.values(components).filter((component) => component.status === 'healthy').length; const degradedComponents = Object.values(components).filter((component) => component.status === 'degraded').length; const unhealthyComponents = Object.values(components).filter((component) => component.status === 'unhealthy').length; return { status: overallHealth.status, timestamp: overallHealth.timestamp.toISOString(), uptime: process.uptime(), client: { available: serviceStats.client.isConnected, healthy: serviceStats.client.isHealthy, connected: serviceStats.client.isConnected, }, worker: { available: this.temporalService.hasWorker(), running: workerStatus?.isRunning || false, healthy: workerStatus?.isHealthy || false, activitiesCount: serviceStats.worker.activitiesCount, }, discovery: { activities: serviceStats.discovery.discoveredCount, complete: serviceStats.discovery.isComplete, discoveredCount: serviceStats.discovery.discoveredCount, }, schedules: { total: serviceStats.schedules.total, active: serviceStats.schedules.active, paused: serviceStats.schedules.paused, }, metadata: { classes: serviceStats.activities.classes, methods: serviceStats.activities.methods, total: serviceStats.activities.total, }, summary: { totalComponents: Object.keys(components).length, healthyComponents, degradedComponents, unhealthyComponents, }, }; } }; exports.TemporalHealthController = TemporalHealthController; __decorate([ (0, common_1.Get)(), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], TemporalHealthController.prototype, "getHealth", null); exports.TemporalHealthController = TemporalHealthController = __decorate([ (0, common_1.Controller)('temporal/health'), __metadata("design:paramtypes", [temporal_service_1.TemporalService]) ], TemporalHealthController); //# sourceMappingURL=temporal-health.controller.js.map