1.1.3 • Published 7 years ago

dianda-config v1.1.3

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

dianda-config

Sync request,wait child process,Based on the zookeeper client implementation for configuration. This module is generally identical to sync-request, use spawnSync achieve sync request to zookeeper server node,after get config,child process exit then parent process go on. This module has been tested to work with node-zookeeper-client version 0.2.2.

Chinese: 这个模块通过开辟子进程,实现同步远程获取服务配置,前提是需要在zookeeper节点配置config参数,当子进程获取配置成功或失败,子进程退出, 主进程才得以继续,在子进程未exit之前主进程处于wait状态,所以慎用, 注:该module完全模仿了sync-request

Installation

You can install it using npm:

$ npm install dianda-config

Documentation

Arguments

  • zk_ip String - Comma separated host:port pairs, each represents a ZooKeeper server. You can optionally append a chroot path, then the client would be rooted at the given path. e.g.

  • options Object - An object to set the client options. Currently available options are:

    • rootNode like "/config"(default:/dianda-config) optional.
    • system like order,inventory etc.

  • callback function

Example

your zookeeper node must have path for /dianda-config/order .
/dianda-config/order
                     /redis
                           /host (the data of host:192.168.1.1:6379)
                     /database
                           /host (the data of host:192.168.1.101:3306)
var config = require('dianda-config')(
    '192.168.1.214:2181',
    {
        rootNode:'/xxx',
        system:'xx'
    });
// the config is 
{
    redis:{host:'192.168.1.1:6379'},
    database:{host:'192.168.1.101:3306'}
} 
console.log(config);

Dependency

This module depends on the following third-party libraries:

License

This module is licensed under MIT License

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.1

8 years ago