def SayHelloStream(self, request, context): meta = dict(context.invocation_metadata()) print 'Got RPC with message for Streaming : \n' + str(request) yield echo_pb2.EchoReply(message='Streaming Hello 1, %s %s!' % (request.firstname, request.lastname)) yield echo_pb2.EchoReply(message='Streaming Hello 2, %s %s!' % (request.firstname, request.lastname)) return
def r(filename): f = open(filename, "rb") wire_msg = binascii.b2a_hex(f.read()) f.close() print 'Got wire_message: ' + wire_msg message_length = wire_msg[2:10] msg = wire_msg[10:10 + int(message_length, 16) * 2] r = echo_pb2.EchoReply() r.ParseFromString(binascii.a2b_hex(msg)) print 'Proto Decode: ' + r.message
def echo(self, request_iterator, context): for request_msg in request_iterator: reply_msgs = [] st = json.dumps(k8s_env()) st2 = datetime.now().isoformat() reply_msgs.append( echo_pb2.EchoReply( resp='### input message={}'.format(request_msg.msg))) reply_msgs.append( echo_pb2.EchoReply(resp='### environment={}'.format(st))) reply_msgs.append( echo_pb2.EchoReply(resp='### timestamp={}'.format(st2))) if (request_msg.log): logger.debug( '### EchoServiceServer -- input:{}, env:{}, time:{}'. format(request_msg.msg, st, st2)) for message in reply_msgs: yield message
def Reply(self, request, context): print( f"on Server meessage received: '{request.message}'. Will echo it back to client." ) return echo_pb2.EchoReply(message=f"You said: '{request.message}'")
def SayHello(self, request, context): meta = dict(context.invocation_metadata()) print 'Got RPC with message: \n' + str(request) return echo_pb2.EchoReply(message='Hello, %s %s!' % (request.firstname, request.lastname))