1.2.1 • Published 5 years ago

muchconf-consul-provider v1.2.1

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

muchconf consul provider

npm Build Status

Muchconf configuration provider for consul KV store. It supports application reloading on configuration update.

Consul is a distributed service mesh to connect, secure, and configure services across any runtime platform and public or private cloud (see: consul.io)

Getting started

Install module using your favorite package manager.

npm install muchconf-consul-provider

Create muchconf configuration store with consul provider. key is name of directory in consul store where configuration is kept. See muchconf repository for more information how to use store.

const { muchconf } = require('muchconf');
const { muchConsul } = require('muchconf-conusl-provider');

const configStore = muchconf([
    muchConsul({
        key: 'myService'
    })
]);

configStore.on('ready', (config) => {
    console.log('Service running at ' + config.ip + ':' + confgi.port);
});

configStore.load();

Class: ConsulProvider

Syntax:

new ConsulProvider(options, commonProviderOptions);

or

muchConsul(options, commonProviderOptions);
nametyperequireddefaultdescription
optionsobjectyesoptions for consul provider
options.hoststringno127.0.0.1agent address (see: silas/node-consul)
options.portnumberno8500agent HTTP(S) port (see: silas/node-consul)
options.securebooleannofalseenable HTTPS (see: silas/node-consul)
options.caString[]noarray of strings or Buffers of trusted certificates in PEM format (see: silas/node-consul)
options.defaultsobjectnocommon method call options that will be included with every call (ex: set default token), these options can be override on a per call basis (see: silas/node-consul)
options.keystringyesthe consul directory where configuration is stored
options.watchIntervalnumbernothe time in milliseconds to wait in between checking of configuration update
commonProviderOptionsobjectnosee belowcommon options for provider
commonProviderOptions.castNumbersbooleannofalseif possible, strings will be converted to number, e.g. '2' will be 2
commonProviderOptions.convertTrueFalseStringsbooleannofalsestrings like 'true' or 'false' will be converted to boolean
commonProviderOptions.cutQuotationsbooleannofalsedouble quotation marks form beginning and ending of string will be cut off. E.g. '"some value"' will be 'some value'
commonProviderOptions.notobjectnoconditions when provider should not be used
commonProviderOptions.isobjectnoconditions when provider should be used

Events:

update fired on configuration change if configuration watching is enabled.

Tests

npm run test
1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago