Skip to content
Load and Watch configuration from etcd
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
LICENSE
README.md
index.js
package.json

README.md

node-etcd-config

Returns a configuration object from etcd

Usage

// initiate EtcdConfig
var appConfig = new EtcdConfig({connectionString: 'http://127.0.0.1:4001/', jsonKeys: true });

// identify application
appConfig.identify('my-app');

// load the configuration
appConfig.load(function (err, config) {
    console.log('config loaded: %j', config);

    appConfig.on('changed', function (item) {
        console.log('key %s changed', item.key);
    });
});

Options

passed as an object to constructor

  • connectionString: url of etcd http api (required)
  • jsonKeys: set to true if configuration values saved as JSON in etcd. Defaults to false (optional)

Methods

  • identify(applicationName): identifies where to find the etcd keys for config using tree pattern /applications/{applicationName}
  • load(callback): callback called when config parsed from etcd. Callback signature is function(err, config)

Events

  • 'changed': fired on changes to etcd keys, returning a changed object

Testing

To run the tests, an instance of etcd must be available at http://127.0.0.1:4001

You can’t perform that action at this time.