Socket
Book a DemoInstallSign in
Socket

service-cloud-config2

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

service-cloud-config2

nodejs cloud service config

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

About service-cloud-config

service-cloud-config is a nodejs module that provides client-side support for externalized configuration in a distributed system.

Adpters

currently only supports: Consul

enter image description here

Installation

$ npm install service-cloud-config

Overview

service-cloud-configr used the service name to discovery the settings

service-cloud-config Options

  • service - Module name. Default null
  • adapter - Used adpter. Default null
  • store - save service config local. Default true
  • mergeWithConfigEnv - If this option is enabled then the module settings will inherit the module envServiceName. Default true
  • envServiceName - The parent module name: Default environment

Inheritance

If mergeWithConfigEnv = true then

example:

environment config = {
	database:{
		ip:"127.0.0.1",
		port:8091
	},
	elasticsearch:{
		ip:"127.0.0.1",
		port:9200
	}
}

my-module config = {
	elasticsearch:{
		ip:"192.168.99.100",
		port:9202
	},
	amqp:{
		host:"127.0.0.1"
	}
}

result config = {
	database:{
		ip:"127.0.0.1",
		port:8091
	},
	elasticsearch:{
		ip:"192.168.99.100",
		port:9202
	},
	amqp:{
		host:"127.0.0.1"
	}
}

API

  • start(callback) - start adpater connection
  • getData(options, callback) - get all configurations remotely
  • get(key) - get config value locally. Only works if store = true
  • getRemoteValue(key, callback) - get single config key remotely

Consul

Note:

  • The consul adapter uses kv to store configurations
adapter:{
    name:'consul',
    connection:{
        host: '192.168.99.100',
        port: 8500
    }
},

Usage

Consul kv

my-service/database/ip

    var ServiceCloudConfig = require('service-cloud-config');
    
    
    var config = new ServiceCloudConfig({
        service:'my-service',
        adapter:{
            name:'consul',
            connection:{
                host: '192.168.99.100',
                port: 8500
            }
        },
        mergeWithConfigEnv:true
    });
    
    
    config.start( function(err, data){
        config.getData(function(err, data){
           console.log(data);
        });
    });

  • get configurations (locally)

    • take paths in documents which can include nested paths specified by '.'s and can evaluate the path to a value
   config.get('database.ip');

Keywords

nodejs

FAQs

Package last updated on 20 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts