service-discovery-settings v1.0.21
service-discovery-settings
Basic remote service discovery and configuration interface into Configuraiton Service
Configure the following in /resources/config.properties (this is the bare minimum of configuration, necessary to bootstrap):
service.discovery.url
service.id
service.scope
service.discovery.url
specifies the url of the discovery server, service.id
identifies the microservice, this is a unique name. service.scope
identifies the scope of configuration, like local
, development
, qa
, or production
.
Three mechanisms of configuraiton are utilized in this module. Most basic is the local configuration coming from /resources/config.properties. These are local settings. A copy of this file ships with each docker container, and you need to map a volume to override the file. Second vehicle is the environment variables. This comes handy when running a container without mapping a volume. Finally, there's remote configuration, that is returned from the service discovery API. Behind the scenes, service discovery API runs on etcd, and configuration settings can be provided at the global microservice level, and overwritten for a specific scope.
Remote configuration is being re-read every 5 seconds, and the service keeps registering itself against the registry at the same time. Once service instance dies, it will no longer be visible in the registry.
For more information on the remote configuration, see the service discovery api.
For example,
service.discovery.url=http://127.0.0.1:8081
service.id=catalog
service.scope=development
Usage:
var config = require('service-discovery-settings');
var elasticLogLevel = config.get('elastic.log.level') || 'error';
You can listen in on configuration value changes:
config.listen('elastic.log.level', function(val){
console.log(val);
});
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago