ravel-etcd-config
Distributed Ravel configuration via etcd

Ravel has a managed configuration system which is traditionally supplied values via a .ravelrc
file. While this is convenient for development, production deployments with replicated Ravel apps benefit from utilizing a distributed configuration approach. To that end, this module provides a mechanism for loading configuration parameters from etcd, a popular open-source key/value store which is often utilized for this purpose.
This module can be used with any version of etcd
which supports the v2
API (this includes etcd 3.x
).
Example Usage:
Load parameters into a folder in etcd
using the tool or language of your choice:
$ etcdctl set "/ravelrc/redis host" 1.2.3.4
$ etcdctl set "/ravelrc/redis port" 6379
$ etcdctl set "/ravelrc/my object parameter" "{\"a\": 1, \"b\": 2}"
Then consume the parameters in your Ravel application:
app.js
const app = new require('ravel')();
const EtcdConfig = require('ravel-etcd-config');
new EtcdConfig(app);
app.set('config etcd host', 'http://1.2.3.4:2379');
app.set('config etcd options', {timeout: 1000});
app.modules('./modules');
app.resources('./resources');
app.init();
app.listen();
Advanced Usage:
If you wish to utilize a unique directory name for your configuration parameters, or even load parameters from multiple directories, you can supply a name manually:
$ etcdctl set "/ravelrc/redis host" 1.2.3.4
$ etcdctl set "/customer1/redis port" 6379
$ etcdctl set "/customer1/my object parameter" "{\"a\": 1, \"b\": 2}"
.ravelrc
{
"config etcd host": "http://1.2.3.4:2379",
"config etcd options": {
"timeout": 1000
}
}
app.js
const app = new require('ravel')();
const EtcdConfig = require('ravel-etcd-config');
new EtcdConfig(app);
new EtcdConfig(app, 'customer1');
app.modules('./modules');
app.resources('./resources');
app.init();
app.listen();