egg icon indicating copy to clipboard operation
egg copied to clipboard

[egg-grpc] support multiple endpoints on different services

Open legendecas opened this issue 6 years ago • 2 comments

  • Node Version:
  • Egg Version:
  • Plugin Name: egg-grpc
  • Plugin Version: 1.0.3
  • Platform:
  • Mini Showcase Repository:

While gRPC is commonly used in micro services that shall be accessed from different endpoints, egg-grpc can not be configured with ease yet to support multiple endpoints on different gRPC services.

With proto definitions:

// app/proto/foo.proto
syntax = "proto3";

package example;

service Foo {
  rpc Echo (TestRequest) returns (TestResponse) {}
}

message TestRequest {
  int32 id = 1;
}

message TestResponse {
  int32 id = 1;
}

// app/proto/bar.proto
syntax = "proto3";

package example;

service Bar {
  rpc Echo (TestRequest) returns (TestResponse) {}
}

message TestRequest {
  int32 id = 1;
}

message TestResponse {
  int32 id = 1;
}

A possible config may be:

// config/config.default.js
exports.grpc = {
  endpoints: {
    'example.Foo': 'localhost:50051',
    'example.Bar': 'localhost:50052',
  },
};

legendecas avatar Apr 26 '18 04:04 legendecas

大佬,这个pr多久能合并,很实用的功能

leoDreamer avatar Aug 06 '18 03:08 leoDreamer

期待这个功能。可以试试这个:https://github.com/SFight/egg-multi-grpc 根据egg-grpc实现了多点连接的问题。还需要完善。

SFight avatar Sep 03 '19 11:09 SFight