0.0.2 • Published 9 years ago
node-etcdwatcher v0.0.2
Node Etcd watcher
"node-etcdwatcher" is simple libary, written in coffe-script for watching etcd directories for changes, and notifies you only when the keys have changed, and You get simple json dictionary of clean data!. It is a wrapper arround node-etcd, although the latest is not included as a depenndacy. In fact it has no dependencies at all. Insteam etcd-node connection option is accepted as constuctor parameter.
Example usage:
EtcdWatcher = require('node-etcdwatcher');
Etcd = require('node-etcd');
etcd = new Etcd(etcdHost, etcdPort);
redisHostWatcher = new EtcdWatcher(etcd);
redisHostWatcher.on('ok', function (key, val) {
console.log("Setting redis config:", val);
redisConfig.Host = val.host;
redisConfig.Port = val.port;
});
redisHostWatcher.on('error', function (key, error) {
console.log("Got error for key: $key:", error);
redisConfig = {};
});
redisHostWatcher.once('ok', function (key, val) {
redisConfig.Host = val.host;
redisConfig.Port = val.port;
some_service.start();
console.log("Service started: ", val);
});
redisHostWatcher.watch("/redis");
console.log("Waiting for redis config from", redisHostWatcher);
You can always call get_value()
in order to fet the current (if any) value
0.0.2
9 years ago