egg-eureka-client
v1.0.18
Published
The Eureka client for egg js.
Downloads
18
Readme
egg-eureka-client
Install
$ npm i egg-eureka-client --save
Usage
// {app_root}/config/plugin.js
exports.eurekaClient = {
enable: true,
package: 'egg-eureka-client',
};
Configuration
// {app_root}/config/config.default.js
exports.eurekaClient = {
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.