gRPC和Beta gRPC类有什么区别?

2024-09-30 16:35:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我有下面的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)之间的区别及其用法。在

我见过代码使用第一个类,代码使用第二个类。在


Tags: 文件代码pymessageservicerpccalculatorproto
1条回答
网友
1楼 · 发布于 2024-09-30 16:35:17

您应该使用非限定的代码元素(尤其是_pb2_grpc.py文件中的那些代码元素),而不是_pb2.py文件中的Beta代码元素。如果使用最新版本的代码生成器生成_pb2.py_pb2_grpc.py文件(请尝试使用绝对最新的^{},当前为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。在

Our examples显示生成的_pb2_pb2_grpc模块的当前预期用途。在

相关问题 更多 >