1.1.2 • Published 9 years ago

columbus v1.1.2

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

columbus

An UDP-based service discovery module with a simple API.

Installation

npm install --save columbus

Usage example

Advertise a service (Server)

var columbus = require('columbus')();

columbus.advertise({
    name: 'my-service',
    port: process.env.PORT
});

Get the connection information of a service (Client)

var columbus = require('columbus')();

columbus.need('my-service', function onAnswer (err, config) {
    if (err) {
        return console.error('Meh: ' + err.toString());
    }

    console.log(config.name); // e.g. my-service
    console.log(config.ipaddress); // e.g. 172.1.0.12
    console.log(config.port); // e.g. 8080
});

API

advertise(configuration[, callback])

Optional: callback

Will advertise a service. Please note that the attributes name and port are mandatory.

need(name, callback)

Will fetch the connection information of a service. The result object that will be passed to the callback as a second parameter provides the following attributes:

  • name: The name of the respective service.
  • ipaddress: The ip address of the respective service.
  • port: The port of the respective service.

Tests

npm test

Author

Copyright, 2014-2015 priorist.com