def HelloMetadata(self, request, context): for key, value in context.invocation_metadata(): if key == request.name: break else: raise KeyError(request.name) context.send_initial_metadata( (f"initial-{key}", repr(value)) for key, value in context.invocation_metadata()) context.set_trailing_metadata( (f"trailing-{key}", repr(value)) for key, value in context.invocation_metadata()) return helloworld_pb2.HelloReply(message=repr(value))
async def HelloStreamMetadata(self, request, context): for key, value in context.invocation_metadata(): if key == request.name: break else: raise KeyError(request.name) await context.send_initial_metadata( (f"initial-{key}", repr(value)) for key, value in context.invocation_metadata()) for c in value: yield helloworld_pb2.HelloReply(message=c) await context.set_trailing_metadata( (f"trailing-{key}", repr(value)) for key, value in context.invocation_metadata())
async def SayHelloSlowly(self, request, context): message = FORMAT_STRING.format(request=request) for char in message: yield helloworld_pb2.HelloReply(message=char)
async def SayHello(self, request, context): return helloworld_pb2.HelloReply(message=FORMAT_STRING.format( request=request))