MicroserviceHealthIndicator

The MicroserviceHealthIndicator is a health indicators which is used for health checks related to microservices

  
class MicroserviceHealthIndicator extends HealthIndicator {
  pingCheck<MicroserviceClientOptions extends MicroserviceOptionsLike>(key: string, options: MicroserviceHealthIndicatorOptions<MicroserviceClientOptions>): Promise<HealthIndicatorResult>

  // inherited from terminus/lib/HealthIndicator
  protected getStatus(key: string, isHealthy: boolean, data?: { [key: string]: any; }): HealthIndicatorResult
}

Methods

pingCheck()

Checks if the given microservice is up


pingCheck<MicroserviceClientOptions extends MicroserviceOptionsLike>(key: string, options: MicroserviceHealthIndicatorOptions<MicroserviceClientOptions>): Promise<HealthIndicatorResult>

Parameters

Option Type Description
key string

The key which will be used for the result object

options MicroserviceHealthIndicatorOptions

The options of the microservice

Examples

    
microservice.pingCheck('tcp', {
  transport: Transport.TCP,
  options: { host: 'localhost', port: 3001 },
})

Returns

Promise<HealthIndicatorResult>

Throws

HealthCheckError If the microservice is not reachable