egg-eureka-client

1.0.18 • Public • Published

egg-eureka-client

NPM version build status Test coverage David deps Known Vulnerabilities npm download

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.

License

MIT

Package Sidebar

Install

npm i egg-eureka-client

Weekly Downloads

18

Version

1.0.18

License

MIT

Unpacked Size

27.4 kB

Total Files

20

Last publish

Collaborators

  • mathewwang