generate grpc client and server code in python

generate grpc client and server code in python,第1张

pip install grpcio-tools

python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. route_guide.proto

result:
	route_guide_pb2_grpc.py 
	route_guide_pb2.py
	content:
		classes for the messages defined in route_guide.proto
		classes for the service defined in route_guide.proto
			RouteGuideStub, which can be used by clients to invoke RouteGuide RPCs
			RouteGuideServicer, which defines the interface for implementations of the RouteGuide service
		a function for the service defined in route_guide.proto
			add_RouteGuideServicer_to_server, which adds a RouteGuideServicer to a grpc.Server

note:
	The 2 in pb2 indicates that the generated code is following Protocol Buffers Python API version 2.
		route_guide_pb2_grpc.py 
		route_guide_pb2.py
	Version 1 is obsolete. 
	It has no relation to the Protocol Buffers Language version, which is the one indicated by syntax = "proto3" or syntax = "proto2" in a .proto file.
	


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/718861.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-25
下一篇 2022-04-25

发表评论

登录后才能评论

评论列表(0条)

保存