1、ProtoBuffer是google的一款非常高效的数据传输格式框架
2、一个方法仅能接受一个参数
3、对于定义的message,每个值都有一个唯一的number类型的数字,根据官方文档的解释:它是用于以消息二进制格式标识字段,并且在使用过程中不能随便更改,否则会导致数据无法还原。同时,如果数字定义为1~15则使用一个字节来存储,而16~2047需要使用两个字节来存储
4、官网: https://grpc.io/docs/quickstart/python.html
5、 根据protocol生成代码:From the examples/python/helloworld
directory, run:
python -m grpc_tools.protoc -I../../protos --python_out=. --grpc_python_out=. ../../protos/helloworld.prot
6、python 的grpc加超时时间,一直不知道在哪里加,查了好多地方都没找到,后来pdb单步调试,终于发现了
def __call__(self, request, timeout=None, metadata=None, credentials=None)
response = self.stub_client.fs(fake_pb2.FsRequest(wfid=id,stime=s_m,type=type),timeout=60)
但怎么捕获异常,又不会了,再次看官方文档,在异常相关介绍那里找到了示例
https://grpc.io/docs/guides/error.html