etcd

etcd client for node

etcd-node

An alternative client library for interacting with etcd from node.js (without coffeescrpt). If you don't mind having coffeescript dependencies, there is already is a module for that.

This is not stable at all! I am writing this module as I learn more about etcd, feel free to help!

$ npm install etcd

I made the client a singleton for the time being (up for suggestions). If you need to set host or port, use the configure method.

var etcd = require('etcd');
 
etcd.configure({
  host: '127.0.0.1',
  port: 40001
});

NOTE: I still need to add SSL support.

I am still implementing commands, but here is what we have so far:

etcd.set('hello', 'world', function (err) {
  if (err) throw err;
});

Set with a TTL:

etcd.set('hello', 'world', { ttl: 5 }, function (err) {
  if (err) throw err;
});

Set using a "setAndTest":

etcd.set('hello', 'world', { prev: 'world' }, function (err) {
  if (err) throw err;
});
etcd.get('hello', function (errresult) {
  if (err) throw err;
  assert(result.value);
});
etcd.del('hello', function (err) {
  if (err) throw err;
});
etcd.list('prefix', function (erritems) {
  if (err) throw err;
});
etcd.watch('prefix', function (err) {
  if (err) throw err;
});
etcd.machines(function (errlist) {
  if (err) throw err;
});
etcd.leader(function (errhost) {
  if (err) throw err;
});
  • encoding (json|string)

MIT