python --version
pip install grpcio grpcio-tools
Define a service in Protocol Buffers, generate Python code, implement the server, and call it from a client.
1 syntax = "proto3"; 2 3 package greeter; 4 5 service Greeter { 6 rpc SayHello (HelloRequest) returns (HelloReply); 7 rpc SayHelloStream (HelloRequest) returns (stream HelloReply); 8 } 9 10 message HelloRequest { 11 string name = 1; 12 string language = 2; 13 } 14 15 message HelloReply { 16 string message = 1; 17 int64 timestamp = 2; 18 } 19
Sign in to share your feedback and join the discussion.