Skip to content

Jeff-Tian/egg-grpc-client-ts

Repository files navigation

egg-grpc-client-ts

TypeScript version of egg grpc client plugin.

Inspired by egg-grpc-client.

NPM version Build Status codecov David deps Known Vulnerabilities npm download

Install

$ npm i egg-grpc-client-ts --save

Usage

// {app_root}/config/plugin.[t|j]s
exports.grpcClient = {
  enable: true,
  package: 'egg-grpc-client-ts',
};

Configuration

// {app_root}/config/config.default.[t|j]s
exports.grpcClient = {
  clients: {
    main: {
      protoPath: 'app/proto/main',
      host: '0.0.0.0',
      port: 50051,
    },
  },
};

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

Example

Questions & Suggestions

Please open an issue here.

License

MIT

Test

# start test grpc server
npm run test-server

# In another shell, run:
npm run test-local

Release Notes:

  • 1.1.5: 报错时,把相关 server address, service, method, 参数 等元信息带上。

  • 1.1.6: fail fast。默认超时时间为 10 秒(原来默认 1 分钟,太长了)

  • 2.0.1: 允许传入 grpcMeta,实现分布式链路跟踪

  • 2.1.0: grpc 健康检查