noms-digital-studio/poll-endpoint-for

Name: poll-endpoint-for

Owner: NOMS Digital Studio

Description: A simple utility that waits for a deployment to finish and then start polling a health endpoint

Created: 2017-04-11 14:19:49.0

Updated: 2017-04-11 19:51:54.0

Pushed: 2017-04-12 12:44:33.0

Homepage:

Size: 37

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

CircleCI

Wait for deployment

A simple configurable utility script that continuously polls an endpoint until the response contains/matches all the fields asked for.

Install

rn add poll-endpoint-for

 -

m install --save poll-endpoint-for

Usage

pollEndpointFor takes two arguments

t pollEndpointFor = require('poll-endpoint-for');

EndpointFor(
{ status: 'OK' },
{ 
    url: 'http://foo-url.com/health',        
    initialWait: 15,
    requestInterval: 10,
    retryCount: 1,
    onSuccess: () => { console.log('I worked!') },
    onError: () => { console.log('I failed') }
    logger: (...args) => { console.info(...args)}
}

Configuration Object

url: (string), // full url for the endpoint
initialWait: (int), // time in ms
requestInterval: (int), // time in ms
timeoutResponse: (int), // time in ms (sets maximum time to wait for the first byte to arrive from the server)
timeoutDeadline: (int), // time in ms (sets a deadline for the entire request (including all redirects) to complete)
retryCount: (int), // amount of times to retry a request
onSuccess: (func), // callback called when the endpoint request matches
onError: (func), // callback called when the endpoint reaches it's count limit without success
logger: (func) // callback used to override the default logger   

Running test

rn test

License

(The MIT License)


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.