sdiscovery

0.1.4 • Public • Published

Autodiscovery module for microservices.

This Node module encapsulates a set of useful functions to discover nearby services in Openshift 3.x / Kubernetes, you just need to remember the service name to retrieve connectivity information.

Features

  • Discovery through environment variables.
    • Look for surrounding services looking at environment variables.
  • DNS Lookup
    • You can discover services that are in your same network/project in OSE3/Kubernetes.
  • DNS SRV (Experimental)
  • Whoami
    • Get information on how to connect to your own service, useful if you want to send this info to other services.

Demo

API

  • discover.searchInEnvVars
    • it look for environment variables of other containers shared with your service.
  let discover = require('discovery');
 
  //{"service": "172.30.228.0","port": "8080" }
  discover.searchInEnvVars('service name');
  • discover.searchInDNS
  • if for some reason environment variables are not shared, this method allow you to lookup the service name in the DNS.
  • return an object with IP address and port.
 
  // returns the IP of the cluster.
discover.searchInDNS('service name'); //"172.30.228.0"
  • discover.searchInDNSSRV
  • You can retrieve address and port from a DNS with SRV record support.
//returns the IP address.
// {  "service": "172.30.228.0","port": "8080" },
discover.searchInDNSSRV('service name');  
  • discover.whoami
  • the connection details for your own service, can be handy to report to some orchestrator.
//return.
discover.whoami();
                        //  "name": "discovery",
                        //  "info": {
                        //    "service": "172.30.234.24",
                        //    "port": "8080"
                        //  }
}

More info

Readme

Keywords

none

Package Sidebar

Install

npm i sdiscovery

Weekly Downloads

0

Version

0.1.4

License

ISC

Last publish

Collaborators

  • cvaldezr