UNPKG

@mdf.js/service-registry

Version:

MMS - API - Service Registry

48 lines 2.14 kB
/** * Copyright 2024 Mytra Control S.L. All rights reserved. * * Use of this source code is governed by an MIT-style license that can be found in the LICENSE file * or at https://opensource.org/licenses/MIT. */ import { LoggerInstance } from '@mdf.js/logger'; import { Aggregator } from '../Aggregator'; import { HealthMessage } from '../types'; import { Port } from './Port'; /** * WorkerPort class is responsible for managing health diagnostics in a worker process of a * clustered Node.js application. It listens for health request messages from the master process, * retrieves health checks from the Aggregator, and sends these health diagnostics back to the * master. * * Inherits from the Port class, utilizing its logging capabilities for diagnostic and operational * logging within the worker process. */ export declare class WorkerPort extends Port { private readonly aggregator; /** * Create an instance of health manager in a worker process * @param aggregator - Aggregator instance to manage the health checks * @param logger - Logger instance for logging activities */ constructor(aggregator: Aggregator, logger: LoggerInstance); /** * Responds to health request messages from the master process. This method is triggered * by health request messages, gathering the current health checks from the Aggregator * and sending a response back to the master process. * * @param message - The health request message received from the master. */ readonly onHealthRequestHandler: (message: HealthMessage) => void; /** * Starts listening for health diagnostic requests from the master process. * This method enables the worker to begin processing incoming health request messages. */ start(): void; /** * Stops listening for health diagnostic requests from the master process. * This method disables the worker's ability to process incoming health request messages, * effectively isolating it from further health diagnostics communication. */ stop(): void; } //# sourceMappingURL=WorkerPort.d.ts.map