安裝
安裝grpc
pip install grpcio
安裝python grpc的protobuf的編譯工具
pip install grpcio-tools
安裝protobuf的python依賴庫
pip install protobuf
生成proto文件
- 創(chuàng)建proto文件夾
- 在proto文件下創(chuàng)建<filename>.proto文件
- 執(zhí)行下面命令
python -m grpc_tools.protoc -I ./ --python_out=. --grpc_python_out=. ./slb_nginx.proto
命令執(zhí)行后會(huì)生成<filename>_pb2_grpc.py文件和<filename>_pb2.py文件,這兩個(gè)文件在后面寫client和server中使用。
待更