egg-thrifty

0.2.1 • Public • Published

egg-thrifty

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

Install

$ npm i egg-thrifty --save

Usage

// {app_root}/config/plugin.js
exports.thrift = {
  enable: true,
  package: 'egg-thrifty',
};

Configuration

// {app_root}/config/config.default.js
const thrift = require('thrift');
 
exports.thrift = {
 
  app: true,
  agent: false,
 
  default: {
    timeout: 4000,
    connect_timeout: 4000,
    max_attempts: 10,
    reconnect: false,
    transport: thrift.TFramedTransport,
    protocol: thrift.TBinaryProtocol,
  },
 
};

see config/config.default.js for more detail.

Example

// config.js
 
config.thrift = {
  clients: {
    test: {
      host: 'localhost',
      port: 1111,
      genjs: path.join(appInfo.baseDir, 'path/to/ThriftService.js'),
      reconnect: true,
    },
  },
};
 
// service/test.js
'use strict';
 
const { Service } = require('egg');
 
class TestService extends Service {
 
  doSth() {
    const { client } = this.app.thrift.get('test');
 
    client.doSth(null, (err, data) => {
 
    });
  }
 
}
 
module.exports = SubscribeService;
 
 

License

MIT

Package Sidebar

Install

npm i egg-thrifty

Weekly Downloads

4

Version

0.2.1

License

MIT

Unpacked Size

66.2 kB

Total Files

28

Last publish

Collaborators

  • shawjia