我有下面的proto文件,它将生成一个pb2.py文件,供python使用。在
syntax = "proto3";
service Calculator {
rpc Add (AddRequest) returns (AddReply) {}
}
message AddRequest{
int32 n1=1;
int32 n2=2;
}
message AddReply{
int32 n1=1;
}
在\u pb2.py中,protoc将生成:
^{pr2}$我想知道这两个类(CalculatorServicervsBetaCalculatorServicer)之间的区别及其用法。在
我见过代码使用第一个类,代码使用第二个类。在
您应该使用非限定的代码元素(尤其是} ,当前为1.1.3),则应该会看到doc strings on the Beta code elements in the generated code describing them as deprecated and to be removed in the future。在
_pb2_grpc.py
文件中的那些代码元素),而不是_pb2.py
文件中的Beta代码元素。如果使用最新版本的代码生成器生成_pb2.py
和_pb2_grpc.py
文件(请尝试使用绝对最新的^{Our examples显示生成的
_pb2
和_pb2_grpc
模块的当前预期用途。在相关问题 更多 >
编程相关推荐