egg
egg copied to clipboard
[egg-grpc] support multiple endpoints on different services
- 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',
},
};
大佬,这个pr多久能合并,很实用的功能
期待这个功能。可以试试这个:https://github.com/SFight/egg-multi-grpc 根据egg-grpc实现了多点连接的问题。还需要完善。