Upbeat Health
This is a variety of strategies upbeat uses to test the health of various services. They are simple and can be used outside of upbeat-server.
Usage
For a simple one-time health check:
var health = ;var tcp = health;;
For an interval based health check:
var health = ;var checker = health;checker;checker;checkerstart;
API
Main object (health = require('upbeat-health'))
health.http([options])
Returns a function that you can call that accepts one callback. This callback's provides the error status of the check if failed. Error is null if passed. NOTE: http can be any strategy name. eg: health.tcp([options]), health.http([optios]), etc...
For a list of strategies, look below.
var http = health; ;
health.checker(strategy, [options]);
- strategy: strategy function
- options (Object)
- interval (integer): the number of milliseconds to wait before calling the next health check
Returns a checker object.
Checker
var checker = strategy options; // or var checker = health;
checker.start()
Start running checks. Intervals start after the completion (or timeout) of each check. This means that the time between checks is interval+checkTime.
checker.stop()
Stop running checks. Will still handle the last check if its in the process of running it.
Strategies and Options
health.http([options]) or health.http([url])
If options is used:
- url (String) eg: "http://www.google.com" (use of port in string is also valid)
- method (String) defaults to GET.
- hostname (String)
- path (String) defaults to '/'
- port (Integer) defaults to 80
- headers (Object) defaults to {}
- auth (Object) defaults to null
- agent (Object) defaults to false
- timeout (Integer) defaults to 10000
health.tcp([options]) or health.tcp("host:port");
If options is used:
- hostname (String)
- port (Integer)
- timeout (Integer) defaults to 2000