Natively Pronounced Mandarin


    0.0.6 • Public • Published


    A library to manage service registry and discover over etcd.

    You will need a connection to etcd. If you're registering services, you will additionally need the public ip of your host.

    In the common use case where your service is a docker container on top of CoreOS/Fleet, you will need to connect to the etcd endpoint at You will determine your own ip/port by passing them as parameters in your fleet service definition.

    Connect to etcd

    var Registry = require('etcd-service-registry');
    var registry = new Registry();
    var registry = new Registry('', '4001');

    Register a service

    registry.Register('MyServiceName',      // Name that will be used by your clients
                      '',       // IP that the service is bound to
                      '8080',               // Port that the service is bound to
                      ['Testing', 'V1.1'])  // Some metadata tags

    Discover a service

    A call to Discover will not fulfill until the required service has been registered into etcd.

    .then(function(service) {
    // {
    //    name: 'MyServiceName',
    //    ip: '',
    //    port: '8080'
    //    tags: ['Testing', 'V1.1']
    // }

    Discover several services at once

    A call to DiscoverAll will not fulfill until all the services specified have been registered into etcd.

    registry.DiscoverAll(['ServiceA', 'ServiceB'])
    .then(function(services) {
    // { 
    //     ServiceA:
    //     { 
    //        name: 'ServiceA',
    //        ip: '',
    //        port: '80',
    //        tags: [ 'Production', 'Version-1.12.3' ]
    //     },
    //     ServiceB:
    //     {
    //        name: 'ServiceB',
    //        ip: '',
    //        port: '81',
    //        tags: [ 'Production', 'Version-1.12.4' ]
    //     }
    // }

    Service Sidekick

    A sidekick is a component external to your service that monitors its health and based on this health check registers your service into etcd.

    Sidekick-CLI under example/sidekick-cli is a CLI implementation of a sidekick service that you can instantly consume with very little effort. It offers inbuilt health check by polling the TCP socket of your service.

    Why TCP instead of HTTP? TCP is more generic so it supports a broader array of services. What you lose by doing TCP polling is the ability to monitor a specific path such as /health - since the TCP poll only checks if the socket is open and is accepting connections.

    Sidekick.js: Register and monitor a service on etcd via CLI.
      -n, --name        Name of the service you wish to register  [required]
      -i, --ip          Publicly accesible ip of your service     [required]
      -p, --port        Port of your service                      [required]
      -e, --expiry      Expiry interval for registration on etcd  [default: 15]
      -t, --poll        Polling interval for health check         [default: 5]
      --ei, --etcdip    Etcd service ip                           [default: "localhost"]
      --ep, --etcdport  Etcd service port                         [default: 4001]


    npm i etcd-service-registry

    DownloadsWeekly Downloads






    Last publish


    • sidbala