0.2.1 • Published 6 years ago

egg-thrifty v0.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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

0.2.1

6 years ago

0.2.0

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago