/**
 * 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 { Health, Layer } from '@mdf.js/core';
import { EventEmitter } from 'events';
import express from 'express';
import { HealthRegistryOptions } from './types';
/**
 * The HealthFacade class serves as a comprehensive solution for monitoring and exposing the health
 * of all components within an application. It abstracts the complexity of health information
 * aggregation and distribution, making it accessible through a REST API and manageable across
 * different operational contexts (e.g., standalone, clustered master, and worker processes).
 *
 * This class leverages:
 * - Aggregator: To aggregate health checks and status events from components.
 * - Port: To handle health information requests and responses in a cluster, accommodating both
 *   master and worker roles.
 * - Router: To expose aggregated health information via a REST API.
 */
export declare class HealthFacade extends EventEmitter implements Layer.App.Service {
    private readonly options;
    /** Debug logger for development and deep troubleshooting */
    private readonly logger;
    /** Health aggregator */
    private readonly aggregator;
    /** Health registry */
    private readonly port?;
    /** Health router */
    private readonly _router;
    /**
     * Create an instance of health registry
     * @param options - health registry options
     */
    constructor(options: HealthRegistryOptions);
    /**
     * Dynamically selects and initializes the appropriate Port implementation based on the
     * application's execution context (standalone, clustered master, or worker) to manage
     * health information exchange.
     * @param options - health registry options
     * @param aggregator - health aggregator
     * @param logger - logger instance
     * @returns Port to manage the health information
     */
    private getPort;
    /** @returns The application name */
    get name(): string;
    /** @returns The application identifier */
    get componentId(): string;
    /** @returns An Express router with access to health information */
    get router(): express.Router;
    /** @returns Links offered by this service */
    get links(): {
        [link: string]: string;
    };
    /** @returns The health status of the component */
    get status(): Health.Status;
    /** @returns Health checks for this service */
    get checks(): Health.Checks;
    /**
     * Adds a timestamped note to the health status.
     * @param note - Note to be added.
     */
    addNote(note: string): void;
    /**
     * Register a resource or a list of resources to monitor for errors.
     * @param component - Resource or list of resources to be registered
     */
    register(component: Layer.App.Resource | Layer.App.Resource[]): void;
    /**
     * Update or add a check measure.
     * This should be used to inform about the state of resources behind the Component/Microservice,
     * for example states of connections with field devices.
     *
     * The new check will be taking into account in the overall health status.
     * The new check will be included in the `checks` object with the key "component:measure".
     * If this key already exists, the `componentId` of the `check` parameter will be checked, if
     * there is a check with the same `componentId` in the array, the check will be updated, in other
     * case the new check will be added to the existing array.
     *
     * The maximum number external checks is 100
     * @param component - component identification
     * @param measure - measure identification
     * @param check - check to be updated or included
     * @returns true, if the check has been updated
     */
    addCheck(component: string, measure: string, check: Health.Check): boolean;
    /** @returns The health of the application */
    get health(): Layer.App.Health;
    /** Start health service */
    start(): Promise<void>;
    /** Stop health service */
    stop(): Promise<void>;
    /** Close health service */
    close(): Promise<void>;
    /** Event handler for status event */
    private readonly statusEventHandler;
}
//# sourceMappingURL=HealthFacade.d.ts.map