Simple config management with Etcd
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.md
example.cluster.js
example.js
index.js
package.json

README.md

etcd-simple-config

Simple config management with Etcd

npm install etcd-simple-config --save

See example.js

API

etcdConfig.bind(prefix, defaultConfig, changeCallback)

Bind etcd path prefix, providing the default config defaultConfig, get the current config and start watching for updates with changeCallback

var etcdConfig = new EtcdSimpleConfig('127.0.0.1', 4001);

var config = etcdConfig.bind(prefix, defaultConfig, function(key, change){
	console.log('Config changed', change, config);
});

config = etcdConfig.get(prefix)

Get config

etcdConfig.set(prefix, obj)

Add or update values

etcdConfig.toJSON(prefix)

Get config, merged with defaultConfig

Listening for events instead of using the change callback

Listen for the 'change' event

var config = etcdConfig.bind(prefix, defaultConfig, true);

config.on('change', function(key, change){
	console.log('on change', arguments);
});

or listen for a single field change

config.on('change:max_requests', function(key, change){
	console.log('on max_requests change', arguments);
});