Skip to content

deedubs/node-etcd-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7e76905 · May 8, 2015

History

24 Commits
Mar 12, 2015
Mar 12, 2015
Mar 12, 2015
Mar 22, 2014
May 8, 2015
Mar 22, 2014
May 8, 2015

Repository files navigation

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