sogou / srpc

RPC framework based on C++ Workflow. Supports SRPC, Baidu bRPC, Tencent tRPC, thrift protocols.
Apache License 2.0
1.95k stars 386 forks source link

does one service support multi function #334

Closed ouclbc closed 1 year ago

ouclbc commented 1 year ago

like the following: syntax="proto3";

message EchoRequest { optional string message = 1; optional string name = 2; };

message EchoResponse { optional string message = 1; };

service Example { rpc Echo(EchoRequest) returns (EchoResponse); rpc A(Aa) returns (B); rpc C(Cc) returns (D); ... };

Barenboim commented 1 year ago

Sure.

ouclbc commented 1 year ago

thank you very much

ouclbc commented 1 year ago

rpc A() returns (B);这种形式出错,Expected type name,空的参数不行么?

holmes1412 commented 1 year ago

这个属于protobuf的语法问题哈~ protobuf是不支持rpc A() returns (B);这种的,你可以这样:

import "google/protobuf/empty.proto";
service MyService {
  rpc A(google.protobuf.Empty) returns (B);
}

可以参考这个:https://stackoverflow.com/questions/31768665/can-i-define-a-grpc-call-with-a-null-request-or-response

ouclbc commented 1 year ago

参考https://github.com/sogou/srpc/issues/120 这个,编译的时候出现如下错误

.srpc.h:1083:70: error: ‘protobuf’ in namespace ‘google’ does not name a type

ouclbc commented 1 year ago

message Null {};直接自己写一个

holmes1412 commented 1 year ago

好的~是的这样和protobuf自带那个Empty是一样的,还避免了找它的namespace的麻烦