Healthcheck monitor
Core functionality of monitoring healthcheck.
Features
- Retries for failled check
- Timeout monitoring
- Healthy after X checks
- Unhealthy after Y checks
- Pause between failled checks
- Everything is super configurable - with resolved functions as options
- Fully unit tested
- TypeScript support
Simple to use
If you have any requests/issues please open an issue at Github.
//All fields with defaults const HealthCheckMonitor STATUS = ; const healthCheckMonitor = interval : 5000 //MS, Interval between definitive results //BTW any field will be resovled if it's a function //It gives you total control on the values at any time //An example to a changin interval 1-3 seconds: // interval : ()=>{return (Math.floor(Math.random()*3) + 1)*1000}, timeout : 5000 //MS, Time to wait till decided an action will be dicarded due to a timeout startPeriod : 0 //MS, Time to ater start() called retries : 1 //If service is unhealthy how many retry action to preform till definitive test result. retryPauseTime : 0//MS, how much time to wait between each retry healthyAfter : 2 //How many consecutive healty action recorded before deciding the status is healty unhealthyAfter : 1//How many consecutive unhealty action recorded before deciding the status is unhealty { //Synchronous / Asynchronous action ; }) ; { //Synchronous / Asynchronous action //If success //If error } //Simple to starthealthCheckMonitorstart;//You can wait for the first definitive status when startinghealthCheckMonitorstart{ //You will also get that first status testResult };//You can pause the helthcheck at any timehealthCheckMonitor;//After pausing you can simply resumehealthCheckMonitor;//Or get notfied on the first definitive answer after resuminghealthCheckMonitor;//You can even invok a manual testhealthCheckMonitor;//Listen to eventshealthCheckMonitor;healthCheckMonitor; //You can also get information about the status at any timehealthCheckMonitorisChanging //true, if it's currently transitioning to a different statushealthCheckMonitortransitionStatus //enum STATUS, the status we are currently transitioning to.
How can it help
Health checking is known to be an important part of service integration, in addition it's an important part of any integration, even internal one. Some common use cases:
- Monitor an HTTP backend.
- Montior a Websocket backend.
- Monitor a file on the system.
- Monitor an IPC connection.
- Monitor a (node)cluster worker.
Because this gives you the core functinality of testing, you are left to decide only what is the action you are testing.