iservice-client

0.0.23 • Public • Published

Build Status

About

iservice-client is a client library for iservice

Usage

var client = require('iservice-client');
client.init({
  host : '127.0.0.1:8123', //iservice address
  cache : '/tmp/cache', //local cache path,
  token : 'abcdefgabcdefg' //token for client
});
 
//create config object for itier
var conf = client.createConfig('/itier');
conf.on('ready', function () {
  //get /memcache/host config
  var h = conf.get('/memcache/host');
  
  //get subtree of /memcache node
  var tree = conf.get('/memcache');
});
conf.on('change', function () {
  //do something while change event occurs
});
conf.on('error', function (err) {
  //do something while error event occurs
});
 
var serv = client.createService();
var app = serv.subscribe('itier');
app.on('ready', function () {
  /**
   * get itier host info
   *
   * hostAddr = {
   *   host : 'x.x.x.x',
   *   port : xx
   * }
   */
  var hostAddr = app.get();
  //do something with host and port
});

Readme

Keywords

none

Package Sidebar

Install

npm i iservice-client

Weekly Downloads

2

Version

0.0.23

License

none

Last publish

Collaborators

  • aleafs
  • vincent-zhao