官方文档地址:
https://googleapis.dev/python/protobuf/latest/google/protobuf/descriptor_pool.html
-
官方文档中提到基于反射使用MessageFactory.GetPrototype() 来替代
-
找到MessageFactory.GetPrototype() 这个函数参数需要传递一个descriptor
-
在descriptor_pool 模块中有有一个类DescriptorPool 中有一个方法FindMessageTypeByName(full_name) ,根据协议名字返回一个descriptor
-
就是去构建这个DescriptorPool 对象
从源码中看,DescriptorPool 对象中的AddFileDescriptor 需要传入FileDescriptor 参数
- 构建这个FileDescriptor 对象,理想中是根据.proto 文件生成这个对象
但是实际没找到…第五步这里老师们帮忙看看了