def request_messages(): for i in range(100): request = demo_pb2.Request( client_id=CLIENT_ID, request_data=("Chamada pelo cliente Python, Mensagem: %d" % i)) yield request time.sleep(1)
def request_messages(): for i in range(5): request = demo_pb2.Request( client_id=CLIENT_ID, request_data=("called by Python client, message: %d" % i)) yield request time.sleep(1)
def simple_method(stub): print("--------------Call SimpleMethod Begin--------------") request = demo_pb2.Request(client_id=CLIENT_ID, request_data="check") response = stub.SimpleMethod(request) print("resp from server(%d), the message=%s" % (response.server_id, response.response_data)) print("--------------Call SimpleMethod Over---------------")
def simple_method(stub): print("//--------------INICIANDO LIGACAO : SIMPLES :--------//") request = demo_pb2.Request(client_id=CLIENT_ID, request_data="Chamada pelo cliente Python") response = stub.SimpleMethod(request) print("Resposta Servidor(%d), A Mensagem =%s" % (response.server_id, response.response_data)) print("//--------------FINALIZANDO LIGACAO---------------//")
def server_streaming_method(stub): print("--------------Call ServerStreamingMethod Begin--------------") request = demo_pb2.Request(client_id=CLIENT_ID, request_data="start") response_iterator = stub.ServerStreamingMethod(request) for response in response_iterator: print("recv from server(%d), message=%s" % (response.server_id, response.response_data)) print("--------------Call ServerStreamingMethod Over---------------")
def server_streaming_method(stub): print("//--------------INICIANDO LIGACAO : SERVIDOR STREAMING :--------------//") request = demo_pb2.Request(client_id=CLIENT_ID, request_data="Chamada pelo cliente Python") response_iterator = stub.ServerStreamingMethod(request) for response in response_iterator: print("Resposta Servidor(%d), A Mensagem =%s" % (response.server_id, response.response_data)) print("//--------------FINALIZANDO LIGACAO---------------//")
def simple_method(stub): #Uploading file in_file_name = 'C:\Users\usuario\Documents\Dev\gRPC-Python\data_transmission\uploading\file.parquet' client.upload(in_file_name) #Downloading file out_file_name = 'C:\Users\usuario\Documents\Dev\gRPC-Python\data_transmission\downloading\file.parquet' if os.path.exists(out_file_name): os.remove(out_file_name) client.download('whatever_name', out_file_name) os.system(f'sha1sum {in_file_name}') os.system(f'sha1sum {out_file_name}') print("//--------------INICIANDO LIGACAO : SIMPLES :--------//") request = demo_pb2.Request(client_id=CLIENT_ID, request_data="Chamada pelo cliente Python") response = stub.SimpleMethod(request) print("Resposta Servidor(%d), A Mensagem =%s" % (response.server_id, response.response_data)) print("//--------------FINALIZANDO LIGACAO---------------//")
def request_messages(): for i in range(5): request = demo_pb2.Request( client_id=CLIENT_ID, request_data=("called by Python client, message:%d" % i)) return request