Golang中GRPC客户端服务器架构中的原始不匹配

时间:2020-05-13 21:14:33

标签: grpc-go

我在客户端中有一个原型文件,在服务器中有一个原型文件,但是客户端protobuf中特定属性的字段号在服务器原型中必须相同。

message Foo_client {
    string foo_has = 1;
    string bar_has = 3;
 }

message Foo_server {
    string bar_true = 1;
    string foo_true = 2;
    string bar_has = 3;
 }

since in server proto file attribute "bar_has" had tag=3 ,so in client it has to be 3  
why?? and is there any other solution that we can use to remove this ambiguity

1 个答案:

答案 0 :(得分:0)

请更清楚您的查询。据我了解,您没有服务器和客户端的两个单独的原始文件。定义原型文件的全部目的是要在服务器和客户端之间定义一致的握手。

您不能跳过数字,因为它是增量数字。您应该定义的结构应该基于请求/响应,而不是服务器/客户端。