egg-eureka插件基于eureka-js-client v4.4.2,帮助你在eggjs下快速将应用注册到eureka server。
$ npm i @taccisum/egg-eureka --save
$ git clone http://gitlab.deepexi.top/taccisum/egg-eureka
$ cd ./egg-eureka
$ npm link
$ cd ${your_project_root}
$ npm link @taccisum/egg-eureka
// {app_root}/config/plugin.js
exports.eureka = {
enable: true,
package: '@taccisum/egg-eureka',
};
// {app_root}/config/config.default.js
exports.eureka = {
client: {
instance: {
app: 'foo-service',
ipAddr: '127.0.0.1',
vipAddress: 'deepexi.foo',
port: 8080,
},
server: {
host: '192.168.0.239',
port: 8761,
},
// auth: {
// user: 'admin',
// password: 'deepexi',
// },
},
};
以上是最小配置,更多配置可以参考eureka-js-client;
const instances = app.eureka.getInstancesByAppId('foo-service');
// do something via instances info
empty now.