co-etcd

1.1.1 • Public • Published

Co Etcd

NPM

npm Dependencies

A promise/co wrapper for the node-etcd module. All functions from node-etcd are supported, but are converted to return a promise

'use strict';
 
let CoEtcd = require('co-etcd');
let co = require('co');
 
co(function *() {
  let etcd = new CoEtcd('127.0.0.1');
  let result = yield etcd.get('');
  console.log(result);
}).catch((e) => { console.log(e.stack); });

Additions

etcd.nodeToTree()

Arguments

  • Javascript object in etcd node format

Returns

  • Node format converted into a JSON tree object

Example

let config = yield etcd.get('');
console.log(config);
/*
{
  "action": "get",
  "node": {
    "key": "/config",
    "dir": true,
    "nodes": [
      {
        "key": "/config/etcd",
        "dir": true,
        "nodes": [
          {
            "key": "/config/etcd/host",
            "value": "somefoohost.com",
            "modifiedIndex": 2280,
            "createdIndex": 2280
          },
          {
            "key": "/config/etcd/active",
            "value": "true",
            "modifiedIndex": 2281,
            "createdIndex": 2281
          }
        ],
        "modifiedIndex": 1086,
        "createdIndex": 1086
      }
    ]
  }
}
*/
 
config = etcd.nodeToTree(config);
console.log(config);
/*
{
  config: {
    etcd: {
      host: "somefoohost",
      active: true
    }
  }
}
*/

Readme

Keywords

Package Sidebar

Install

npm i co-etcd

Weekly Downloads

1

Version

1.1.1

License

MIT

Last publish

Collaborators

  • johnhof