@danielwpz/health-check
A promise-based health check util for Nodejs
Last updated a year ago by danielwpz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @danielwpz/health-check 
SYNC missed versions from official npm registry.

health-check

A promise-based health check util for Nodejs

Example

const Healthcheck = require('@danielwpz/health-check');
const Checker = Healthcheck.Checker;
const HTTPChecker = Healthcheck.HTTPChecker;

const okChecker = new Checker('ok', () => Promise.resolve(true), 100);
const throwChecker = new Checker('throw', () => Promise.reject('Bad happened'), 100);
const timeoutChecker = new Checker('timeout', () => new Promise((res, rej) => {}), 1000);
const httpChecker = new HTTPChecker('google', 'https://www.google.com/');

const healthcheck = new Healthcheck([okChecker, throwChecker, timeoutChecker, httpChecker]);
healthcheck.run().then(console.log);

should print

[ { name: 'ok', healthy: true, critical: false, time: 32 },
  { name: 'throw', healthy: false, critical: false, time: 30 },
  { name: 'timeout', healthy: false, critical: false, time: 1004 },
  { name: 'google', healthy: true, critical: false, time: 169 },
  { name: '404', healthy: false, critical: false, time: 421 } ]

API

  • Healthcheck

    • constructor([Healthcheck.Checker...])
    • run(): Promise
  • Chekcer

    • constructor(name, promiseFn, timeout, critical)
      • name: The name for this health checker
      • promiseFn: A function that returns a Promise, which will be called each time when the checkers runs
      • timeout: Timeout in ms
      • critical: An indicator of whether this is a critical health check. Currently not used
    • check(): Promise
  • HTTPChecker extends Checker

    • constructor(name, url, timeout, critical)
      • url: The URL to GET. Only 2xx responses are considered healthy.

Current Tags

  • 0.0.1                                ...           latest (a year ago)

1 Versions

  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (3)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |