- simple interface
- key/value starage
- watch for changes
OSX
$ curl -L https://github.com/coreos/etcd/releases/download/v2.1.3/etcd-v2.1.3-darwin-amd64.zip -o etcd-v2.1.3-darwin-amd64.zip
$ unzip etcd-v2.1.3-darwin-amd64.zip
$ cd etcd-v2.1.3-darwin-amd64
$ ./etcd
Open another terminal:
$ ./etcdctl set mykey "this is awesome"
this is awesome
$ ./etcdctl get mykey
this is awesome
OSX Homebrew
$ brew install etcd
$ etcd
Open another terminal:
$ etcdctl set mykey "this is awesome"
this is awesome
$ etcdctl get mykey
this is awesome
For nodejs >= 0.10 and iojs:
$ npm install node-etcd
For nodejs == 0.8:
$ npm install node-etcd@3.0.2
Basic usage
Etcd = require('node-etcd');
etcd = new Etcd();
etcd.set('key', 'value');
etcd.get('key', console.log);
etcd.del('key', console.log);
.set(key, value, [options], [callback])
etcd.set('key', 'value', {ttl: 5}, console.log);
ttl
(time to live in seconds)
.create(path, value, [options], [callback])
Atomically create in-order keys.
etcd.create('queue', 'first');
etcd.create('queue', 'next', console.log);
.watcher(key, [index], [options])
Returns an eventemitter for watching for changes on a key
watcher = etcd.watcher('key');
watcher.on('change', console.log); // Triggers on all changes
You can cancel a watcher by calling .stop()
.
Signals:
change
- emitted on value changereconnect
- emitted on reconnecterror
- emitted on invalid content<etcd action>
- the etcd action that triggered the watcher (ex: set, delete, expire).stop
- watcher was canceled.resync
- watcher lost sync (server cleared and outdated the index).
Use the .watch()
command in you need more direct control.
- get
- watcher instance
- etcd 초기화(setup, notify, connect)
- watcher 작성
- test