egg-eureka-client
Install
$ npm i egg-eureka-client --save
Usage
// {app_root}/config/plugin.jsexportseurekaClient = enable: true package: 'egg-eureka-client';
Configuration
// {app_root}/config/config.default.jsexportseurekaClient = aws:true eureka: useLocalMetadata: true preferIpAddress: true serviceUrls: default: 'http://reg1.oriente.internal:8761/eureka/' 'http://reg2.oriente.internal:8762/eureka/' 'http://reg3.oriente.internal:8763/eureka/' ;
see config/config.default.js for more detail.
Example
app.js
app.beforeStart(async () => {
app.eureka = app.eurekaFactory.createClient();
await app.eureka.ready(true);
app.eureka.updateRegistry();
}
// get
this.ctx.app.eureka.app('fe-shortlink-biz').get('/system/version').then( ret => {
console.log(ret && ret.body);
this.ctx.app.logger.info('[Eureka-Client] The systemVersion is :' + `${ret && ret.body}`);
});
// post
this.ctx.app.eureka.app('common-biz').post('/common/short_url/shorten/create', {data:{oriUrl : oriUrl}}).then( ret => {
console.log(ret && ret.body.data);
});
Questions & Suggestions
Please open an issue here.