luster-consul-config
v1.0.0
Published
Luster extension that provides support for getting configuration from Consul K/V storage
Downloads
2
Readme
luster-consul-config
An extension for luster that provides support for getting configuration from Consul K/V storage.
Usage
Install extension module to application:
$ npm install --save luster-consul-config
Add luster-consul-config
to the list of your luster extensions:
// luster.conf.json
{
"app": "worker.js",
···
"extensions": {
"luster-consul-config": {
"namespace": "settings/example/",
"connection": {
"host": "127.0.0.1",
"port": 8500
}
}
}
}
In your worker.js
use luster.consulConfig(observer)
method to subscribe to configuration data:
// worker.js
var luster = require('luster');
const config = {
foo: 'bar',
};
if (typeof luster.consulConfig === 'function') {
luster.consulConfig(newCfg => Object.assign(config, newCfg));
}
See example/
for complete example.
Configuration
namespace
- prefix of keys; this prefix will be stripped from config;cacheFile
- optional file path to store successfully loaded configuration. Config could be restored from this file in case of temporal downtimes of the Consul agent;connection
- Consul agent connection details; see node-consul.
Contribution and Feedback
Contributing is more than welcome. Create an issue if you see any problem in the code or send a PR with fixes if you'd like.
License
MIT