egg-etcd-discovery
v1.3.3
Published
provides egg bindings for the etcd discovery.
Downloads
11
Maintainers
Readme
egg-etcd-discovery
provides egg bindings for the etcd.
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.