def default_response_data(response_size): sresp = messages_pb2.SimpleResponse() sresp.payload.body = b'\x00' * response_size serialized_resp_proto = sresp.SerializeToString() response_data = b'\x00' + struct.pack( 'i', len(serialized_resp_proto))[::-1] + serialized_resp_proto return response_data
def UnaryCall(self, request, context): _maybe_echo_metadata(context) _maybe_echo_status_and_message(request, context) return messages_pb2.SimpleResponse( payload=messages_pb2.Payload(type=messages_pb2.COMPRESSABLE, body=b"\x00" * request.response_size))