sogou/srpc

does one service support multi function

Closed this issue · 7 comments

ouclbc commented

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);
...
};

Sure.

ouclbc commented

thank you very much

ouclbc commented

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

这个属于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

参考#120 这个,编译的时候出现如下错误

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

ouclbc commented

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

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