egg-etcd-discovery

1.2.4 • Public • Published

egg-etcd-discovery

provides egg bindings for the etcd.

npm download NPM version GitHub issues GitHub

Install

$ npm i egg-etcd-discovery --save

Usage

// {app_root}/config/plugin.ts
{
  enable: true,
  package: 'egg-etcd-discovery',
}

/** 
 * get server
 * @param string serverName
 * @return {name: string, ip: string, weight: number}
 * /
this.app.etcd.getNextServer(serverName);

see lib/discovery/controller.ts for more detail.

Configuration

// {app_root}/config/config.default.ts
exports.eggEtcdDiscovery = {

    options:{
        hosts: [
            '172.17.0.1:2379', '172.17.0.2:2379', '172.17.0.3:2379'
        ],
        dialTimeout: 5000
    },

    leaseTTL: 5,

    projectName: 'etcd',
    serverName: 'accountServer',
    nodeName: 'node-01',
    protocol: 'http',
    
    serverIp: 'localhost:8080',
    serverWeight: 1,
};

see config/config.default.ts for more detail.

Example

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i egg-etcd-discovery

Weekly Downloads

1

Version

1.2.4

License

MIT

Unpacked Size

60.5 kB

Total Files

21

Last publish

Collaborators

  • uccu