etcd-spaceport
service registry leveraging etcd as a backend
Last updated 5 years ago by defunctzombie .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install etcd-spaceport 
SYNC missed versions from official npm registry.

etcd-spaceport

Service registry leveraging etcd as a backend

Create a new Registry

var Registry = require('etcd-registry');

var registry = Registry('/path/to/services' [, '127.0.0.1:4001']);

Specify the etcd base keypath. Services will be registered under this path.

Listen for new services

registry.browse(function(service) {
    service.name; // 'my-service'

    service.once('offline', function() {
        // service is offline, no longer active
    })
});

When a new service is registered, the callback will be called with a service object. Listen for the offline event to know when the service goes offline.

Register your service

var service = registry.service('my-service');

var details = {
    'any': 'keys',
    'that': 'you want'
};

// start the service
service.start(details, function(err) {
    // started
});

// stop a service sometime later
service.stop(function() {
});

Some other process can register services into the registry. When you start a service, you can pass service details which will be available to the browsers. These details are stored as a JSON string as the etcd value for the service key.

If there is already a service running with the same name, the start call will fail with and error.

Current Tags

  • 0.4.0                                ...           latest (5 years ago)

8 Versions

  • 0.4.0                                ...           5 years ago
  • 0.3.0                                ...           6 years ago
  • 0.2.3                                ...           6 years ago
  • 0.2.2                                ...           6 years ago
  • 0.2.1                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 0
Last Month 9
Dependencies (3)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |