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.

Hierarchy

  • EventEmitter
    • HealthFacade

Implements

Constructors

Accessors

  • get componentId(): string
  • Returns string

    The application identifier

  • Returns { [link: string]: string }

    Links offered by this service

  • get name(): string
  • Returns string

    The application name

  • get router(): Router
  • Returns Router

    An Express router with access to health information

  • get status(): "pass" | "fail" | "warn"
  • Returns "pass" | "fail" | "warn"

    The health status of the component

Methods

  • 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

    Parameters

    • component: string

      component identification

    • measure: string

      measure identification

    • check: Check<any>

      check to be updated or included

    Returns boolean

    true, if the check has been updated

  • Adds a timestamped note to the health status.

    Parameters

    • note: string

      Note to be added.

    Returns void

  • Close health service

    Returns Promise<void>

  • Register a resource or a list of resources to monitor for errors.

    Parameters

    Returns void

  • Start health service

    Returns Promise<void>

  • Stop health service

    Returns Promise<void>