Code Monkey home page Code Monkey logo

service-cloud-config's Introduction

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');

service-cloud-config's People

Contributors

andrepinto avatar

Watchers

James Cloos avatar caizx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.