コード例 #1
0
def run():
    channel = grpc.insecure_channel('localhost:50051')
    stub = hello_pb2_grpc.GreeterStub(channel)
    # reponse = stub.SayHello(hello_pb2.HelloRequest(name='you'))
    # print(reponse.message)
    reponse = stub.PlusTest(hello_pb2.PlusRequest(num1=1, num2=2))
    print(reponse.result)
コード例 #2
0
ファイル: greeter_client.py プロジェクト: wac81/experience
def run_Map():
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = hello_pb2_grpc.GreeterStub(channel)
        response = stub.MapSayHello(hello_pb2.HelloRequest(name='kkk'))

    print("WAC Greeter client received: ")
    print(response.dict_map)
コード例 #3
0
def run():
    # NOTE(gRPC Python Team): .close() is possible on a channel and should be
    # used in circumstances in which the with statement does not fit the needs
    # of the code.
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = hello_pb2_grpc.GreeterStub(channel)
        response = stub.SayHello(hello_pb2.HelloRequest(name='python-world'))
    print("Greeter client received: " + response.message)
コード例 #4
0
def run():
    # connect grpc server
    channel = grpc.insecure_channel('localhost:8089')
    # send grpc
    stub = hello_pb2_grpc.GreeterStub(channel)

    response = stub.SayHello(hello_pb2.Request(name = 'cpx'))
    print("Greeter client received: " + response.message)
コード例 #5
0
def run():
    channel = grpc.insecure_channel('localhost:50051')
    stub = hello_pb2_grpc.GreeterStub(channel)

    request = hello_pb2.RequestInfo()
    request.mtype = hello_pb2.HEART
    request.heart.devid = "xxxx-xxxx"
    request.heart.ver = "xxx"

    response = stub.SayHello(request)
    print("Greeter client received: " + str(response.rcode))
コード例 #6
0
def main() -> None:
    print('Connecting...')
    try:
        with grpc.insecure_channel('localhost:50051') as channel:
            stub = hello_pb2_grpc.GreeterStub(channel)
            request = hello_pb2.HelloRequest()

            request.name = 'John'
            print('Sending request...')
            response = stub.SayHello(request)

            print('Response received')
            print(response.response)
    except grpc.RpcError as error:
        print(error)
コード例 #7
0
import os
import logging
import grpc

import hello_pb2
import hello_pb2_grpc

PROTO_PATH = "../protos/hello.proto"

SERVER_HOST = os.getenv("HOST", "0.0.0.0")
SERVER_PORT = os.getenv("PORT", "50051")
SERVER_ADDRESS = f'{SERVER_HOST}:{SERVER_PORT}'

with grpc.insecure_channel(SERVER_ADDRESS) as channel:
    stub = hello_pb2_grpc.GreeterStub(channel)
    response = stub.SayHello(hello_pb2.HelloRequest(name='SimpliRoute'))
    print("Response: " + response.message)
コード例 #8
0
def run():
    channel = grpc.insecure_channel('localhost:50052')
    stub = hello_pb2_grpc.GreeterStub(channel)
    response = stub.SayHello(hello_pb2.HelloRequest(name='you'))
    print("Greeter client received: " + response.message)
コード例 #9
0
def client_stub():
    import hello_pb2_grpc
    channel = grpc.insecure_channel('localhost:9094')
    stub = hello_pb2_grpc.GreeterStub(channel)
    return stub
コード例 #10
0
def run():
    with grpc.insecure_channel('localhost:50051') as channel:  # create channel
        stub = hello_pb2_grpc.GreeterStub(channel)  # create stub to call service methods
        response = stub.SayHello(hello_pb2.HelloRequest(name='cae'))  # call service methods
        print("Greeter client received: " + response.message)
コード例 #11
0
def run():
    channel = grpc.insecure_channel('localhost:50051')
    stub = hello_pb2_grpc.GreeterStub(channel)
    response = stub.SayHello(hello_pb2.HelloRequest(name='nyan'))
    print('message', response.message)
コード例 #12
0
ファイル: greeter_client.py プロジェクト: wac81/experience
def run_WAC():
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = hello_pb2_grpc.GreeterStub(channel)
        response = stub.WacSayHello(hello_pb2.HelloRequest(name='kkk'))
コード例 #13
0
def run():
    with grpc.insecure_channel("localhost:50051") as channel:
        stub = hello_pb2_grpc.GreeterStub(channel)
        response = stub.SayHello(hello_pb2.HelloRequest(name="kapil"))
    print(response.message)
コード例 #14
0
def main(argv):
    channel = grpc.insecure_channel('localhost:50051')
    stub = hello_pb2_grpc.GreeterStub(channel)
    hello_req = hello_pb2.HelloRequest(name='gRPC world')
    hello_rsp = stub.SayHello(hello_req)
    print(hello_rsp.message)
コード例 #15
0
ファイル: greeter_client.py プロジェクト: tomsovic/Learn
def run():
    # channel = grpc.insecure_channel('localhost:50051')
    channel = grpc.insecure_channel('192.168.1.24:50051')
    stub = hello_pb2_grpc.GreeterStub(channel)
    response = stub.SayHello(hello_pb2.HelloRequest(name='goodspeed'))
    print("Greeter client received: " + response.message)
コード例 #16
0
def run():
    with grpc.insecure_channel('localhost:50051') as channel:
        stub = hello_pb2_grpc.GreeterStub(channel)
        response = stub.SayHello(hello_pb2.HelloRequest(name='Quan Vu'))
    print("Hello client received: " + response.message)