Skip to content

Instantly share code, notes, and snippets.

@daggy1234
Last active August 4, 2023 13:30
Show Gist options
  • Save daggy1234/954e369d984210885f365a037d3e55a8 to your computer and use it in GitHub Desktop.
Save daggy1234/954e369d984210885f365a037d3e55a8 to your computer and use it in GitHub Desktop.
from rpc_echo_python_client import Connection, HelloRequest
c = Connection("0.0.0.0:5000")
req = HelloRequest("Hello Request")
o = c.say_hello(req)
syntax = "proto3";
package rpc_echo;
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
// The request message containing the user's name.
message HelloRequest {
bytes name = 1;
}
// The response message containing the greetings
message HelloReply {
bytes message = 1;
}
from rpc_echo_python_server import MyGreeter, HelloRequest, HelloResponse
def say_hello(req: HelloRequest) -> HelloResponse:
msg = req.message
print(f"Got {msg}")
return HelloResponse(f"Recieved {msg}!")
s = MyGreeter()
s.add_say_hello(say_hello)
s.run("0.0.0.0:5000")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment