1.1.1 • Published 8 years ago

co-etcd v1.1.1

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

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
    }
  }
}
*/
1.1.1

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago