ngconf
A new generation distribute configuration component used etcd, currently for Node.JS
Quick Start
See example.js
const NgConf = ;const path = ; let ngconf = 'http://127.0.0.1:2379' 'ngconf-example'; ngconf; ngconf; ngconf; { console;} { console;}
- Put these files in the same directory
- example.js (shown above)
- examples/
- examples-prod/
- Development environment
$ node example.js
- Use NODE_ENV to switch profile.
$ NODE_ENV=production node example.js
Base Usage
etcdHosts namespace options
Args
- etcdHosts: String or array.
'http://127.0.0.1:2379'
or['http://127.0.0.1:2379', 'http://192.168.1.1:2379']
- namespace: String, usually use project name.
- options: Object. Full options and default values like this.
let opts = localOnly: false //When true, ngconf will only use content in local cache, and won't update configs in etcd { //function or string, returns profile name return processenvNODE_ENV || 'development'; }
Callbacks
callback
{}
watcher
{}
Methods
ngconf;
ngconf;