createHealthMonitor(targets, options)
createHealthCheck(target)
createHealthy(options)
healthLogging(options)
Every function described above is a top-level export. You can import any of them like this:
import { createHealthMonitor } from '@meltwater/mlabs-health'
Creates a new health monitor.
targets
(object): Health checks to use.options
(object):delay
(number): Milliseconds beforehealth
emits first event. Default: 0.timeout
(number): Milliseconds before health check times out with error. Default: 5000 (5 seconds).ttl
(number): Seconds to cache health check result. Default: 60 (1 minute).cache
(object|null): Default cache instance. Default: an in memory cache with the abovettl
.strategy
: Health strategy forhealth
. Default: the all-healthy strategy.createHealthCheck
: Function to wrap all targets with. Default: thecreateHealthCheck
function provided in this module.
(object): The health monitor.
Creates a health check for use by a health monitor.
target
(any): Thing to convert to health check.options
(object):timeout
(number): Milliseconds before health check times out with error. Default: 60000 (1 minute).ttl
(number): Seconds to cache health check result. Default: 60 (1 minute).cache
(object|null): Default cache instance. Default: an in memory cache with the abovettl
.
(function): An asynchronous health check function.
Creates a function which maps health status objects to a boolean healthy status.
options
(object):minAvailability
(number): Minimum availability before unhealthy. Default: 0.9.minReliability
(number): Minimum reliability before unhealthy. Default: 0.9.maxDowntime
(number): Maximum downtime (in milliseconds) before unhealthy. Default: 5 minutes.
(function): Function that maps status to boolean.
Logs all events in the status stream for all health checks in the health monitor.
options
(object):healthMonitor
(object): The health monitor to use.log
(object): A Bunyan compatible logger. Default: a new logger.
(undefined)