Git Product home page Git Product logo

poll-endpoint-for's Introduction

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

$ yarn add poll-endpoint-for

- or -

$ npm install --save poll-endpoint-for

Usage

pollEndpointFor takes two arguments

  • An object containing the desired key value pairs received from the response(s).
  • A configuration object with with to manage the request cycles
const pollEndpointFor = require('poll-endpoint-for');

pollEndpointFor(
    { 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

$ yarn test

License

(The MIT License)

poll-endpoint-for's People

Contributors

romidane avatar

Watchers

Rob Lazzurs avatar James Cloos avatar  avatar Joe McGrath avatar  avatar Nick Talbot avatar Tim Taylor avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.