hrpc/example/server.py
Luke Murphy 1f61e86cba
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Clean up example
2020-08-09 03:53:39 +02:00

24 lines
621 B
Python

"""Greeter server."""
from purerpc import Server
from greeter_grpc import GreeterServicer
from greeter_pb2 import HelloReply, HelloRequest
class Greeter(GreeterServicer):
async def SayHello(self, message):
return HelloReply(message=f"Hello, {message.name}")
async def SayHelloToMany(self, input_messages):
async for message in input_messages:
yield HelloReply(message=f"Hello, {message.name}")
if __name__ == "__main__":
server = Server(50055)
server.add_service(Greeter().service)
try:
server.serve(backend="trio")
except KeyboardInterrupt:
pass