Skip to content

johnhof/co-etcd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Wrapper for the node-etcd client

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published