0.0.2 • Published 9 years ago

express-service-discovery v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

#Express-service-discovery Build Status NPM version Dependencies

Express Plugin for OpenTable service discovery.

Takes a discovery client, exposes routes for announce, unannounce (so that you can control the server externally). Is compatible with https://github.com/opentable/grunt-ot-discovery.

Currently depends on some closed-source modules which we are in the process of open-sourcing.

Usage:

var express = require('express');
var OTDiscovery = require('ot-discovery');

var discoveryClient = new OTDiscovery('hostname.opentable.com');

discoveryClient.connect(function(error, host, servers) {
  if (error) {
    console.error('discovery client error: ' + error.stack);
    process.exit(1);
  } else {
    var app = express();
    require('express-service-discovery').configure(app, {
      serviceType: 'my-service',
      serviceUri: 'http://my-service.domain.com', // Defaults to the machine's FQDN
      discoveryClient: discoveryClient
    });
    app.listen();
  }
});

Routes:

GET /discovery/announce    - announce this server to the registry
GET /discovery/unannounce  - unannounce this server
GET /discovery/lease       - show lease info
GET /discovery/lastUpdated - show last time the client received an update from the remote discovery service (useful for monitoring)