npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

healthcheck-monitor

v1.0.3

Published

Health check anything, with this core functionality of monitoring health checks

Downloads

9

Readme

Healthcheck monitor

Greenkeeper badge

NPM Version Build Status Test Coverage

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} = require('healthcheck-monitor');
    const healthCheckMonitor = new 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
            action :  (testInfo , onResponse)=>{
                //Synchronous / Asynchronous action
                onResponse(STATUS.UNHEALTHY);
            })
    });

function statusCheckAction(testInfo , onResponse){
    //Synchronous / Asynchronous action
    //If success
    onResponse(STATUS.HEALTHY)
    //If error
    onResponse(STATUS.UNHEALTHY)
}

//Simple to start
healthCheckMonitor.start();
//You can wait for the first definitive status when starting
healthCheckMonitor.start((testResult)=>{
    //You will also get that first status testResult

});
//You can pause the helthcheck at any time
healthCheckMonitor.pause();
//After pausing you can simply resume
healthCheckMonitor.resume();
//Or get notfied on the first definitive answer after resuming
healthCheckMonitor.resume((testResult)=>{
    //You will also get that first status testResult

});
//You can even invok a manual test
healthCheckMonitor.test((testResult)=>{
    //You will also get that first status testResult

});
//Listen to events
healthCheckMonitor.on('statusChange' , (status)=>{
    //For any change of status after 
    //waiting `healthyAfter` or `unhealthyAfter`
    //will be called with the new status (enum STATUS)

});
healthCheckMonitor.on('testResult' , (testResult)=>{
    //For every single check you will get an event with a `TestResult`

});

//You can also get information about the status at any time
healthCheckMonitor.isChanging //true, if it's currently transitioning to a different status
healthCheckMonitor.transitionStatus //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.

License

MIT