GithubHelp home page GithubHelp logo

tcp-ping-node's Introduction

tcp-ping-node

TCP ping utility for node.js with promise support. You can test if chosen address accepts connections at desired port and find out your latency.

One of the critical topic of Microservice architecture is Observability. The operator need to find a way to detect the microservice's readiness, liveness and health. Health Check API (/health) is the most common practise to provide the ability for platform to observe the microservice. Hence, dependency of microservice is the main figure about its health.

Installation

npm install tcp-ping-node

How to use it

You can just simply call the ping API, which is asynchronous. After the ping complete, it will return the result for your follow-up action.

 const options = {host: 'www.bing.com', port: '80', timeout: 10000}
 const result = await ping(options);

You will get the result with JSON format:

{
    "host": "www.bing.com", 
    "port": 80,
    "success": true,
    "time": "49.388"
}

API

ping(options)

ping(options) is an asynchronous API. it accepts the options with below format:

  • host: address to ping. Default is localhost
  • port: port of above address to ping. Default is 80. both number and string type are accepted.
  • timeout: ping timeout setting in ms. Default is 5000 ms.

It returns the result as below:

  • host: host to ping.
  • port: port of host to ping.
  • success: indicate that whether the ping is success or not.
  • time: the elapsed time of ping action in ms.

tcp-ping-node's People

Contributors

cs-lames avatar notechsolution avatar

Stargazers

 avatar  avatar

Watchers

 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.