示例#1
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 = route_guide_pb2_grpc.RouteGuideStub(channel)
        guide_route_chat(stub)
示例#2
0
def run(bytes_per_row, num_rows, max_msg, pagesize):
    options = [('grpc.max_receive_message_length', max_msg)]
    with grpc.insecure_channel('localhost:50052', options=options) as channel:
        stub = route_guide_pb2_grpc.RouteGuideStub(channel)

        ### Repeat messages
        # Message sizes over 1 GB seem to break
        if max_msg < (1024 * 1024 * 1024):
            print("-------------- call repeated --------------")
            start = time.time()
            gen_repeated(stub, bytes_per_row, num_rows, True)
            print("elapsed time:{:.3f}".format(time.time() - start))
        else:
            print("Message size too large; skipping repeat rows.")

        ### Simulated paging
        if pagesize > 0:
            print("-------------- call paging ----------------")
            num_pages = num_rows / pagesize
            last_page = num_rows % pagesize
            print("Number of pages: %d" % (num_pages +
                                           (1 if last_page > 0 else 0)))
            start = time.time()
            for i in range(num_pages):
                gen_repeated(stub, bytes_per_row, pagesize, False)
            if last_page > 0:
                gen_repeated(stub, bytes_per_row, last_page, False)
            print("elapsed time:{:.3f}".format(time.time() - start))

        ### Streaming
        print("-------------- call stream ----------------")
        start = time.time()
        gen_stream(stub, bytes_per_row, num_rows, False)
        print("elapsed time:{:.3f}".format(time.time() - start))
示例#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', options=(('grpc.enable_http_proxy', 0),)) as channel:
        stub = route_guide_pb2_grpc.RouteGuideStub(channel)
        print("-------------- GetFeature --------------")
        guide_get_feature(stub)
        print("-------------- ListFeatures --------------")
        guide_list_features(stub)
        print("-------------- RecordRoute --------------")
        guide_record_route(stub)
        print("-------------- RouteChat --------------")
        guide_route_chat(stub)
        


        print("-------------- RouteRetrievetest --------------")
        print("\n\n\n start student test \n\n\n")
        
        print("add some routes to the server")
        guide_record_route(stub)
        guide_record_route(stub)
        guide_record_route(stub)
        
        student_test(stub)
示例#4
0
def connect(servers, request):
    """
    server - server ip

    request - input tuple
    """
    server = random.choice(servers)
    channel = grpc.insecure_channel(server)
    stub = route_guide_pb2_grpc.RouteGuideStub(channel)
    return stub
示例#5
0
async def main() -> None:
    async with grpc.aio.insecure_channel('localhost:50051') as channel:
        stub = route_guide_pb2_grpc.RouteGuideStub(channel)
        print("-------------- GetFeature --------------")
        await guide_get_feature(stub)
        print("-------------- ListFeatures --------------")
        await guide_list_features(stub)
        print("-------------- RecordRoute --------------")
        await guide_record_route(stub)
        print("-------------- RouteChat --------------")
        await guide_route_chat(stub)
示例#6
0
def run():
    channel = grpc.insecure_channel('localhost:50051')
    stub = route_guide_pb2_grpc.RouteGuideStub(channel)
    print("-------------- GetFeature --------------")
    guide_get_feature(stub)
    print("-------------- ListFeatures --------------")
    guide_list_features(stub)
    print("-------------- RecordRoute --------------")
    guide_record_route(stub)
    print("-------------- RouteChat --------------")
    guide_route_chat(stub)
示例#7
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 = route_guide_pb2_grpc.RouteGuideStub(channel)
        print("-------------- GetFeature --------------")
        guide_get_feature(stub)
        print("-------------- ListFeatures --------------")
        guide_list_features(stub)
        print("-------------- RecordRoute --------------")
        guide_record_route(stub)
        print("-------------- RouteChat --------------")
        guide_route_chat(stub)
示例#8
0
async def main() -> None:
    target = 'fargate-grpc-load-balancer-1566060198.us-east-2.elb.amazonaws.com:50051'

    credentials = grpc.ssl_channel_credentials()
    async with grpc.aio.insecure_channel(target, credentials) as channel:
        stub = route_guide_pb2_grpc.RouteGuideStub(channel)
        print("-------------- GetFeature --------------")
        await guide_get_feature(stub)
        print("-------------- ListFeatures --------------")
        await guide_list_features(stub)
        print("-------------- RecordRoute --------------")
        await guide_record_route(stub)
        print("-------------- RouteChat --------------")
        await guide_route_chat(stub)
示例#9
0
def run():
    channel = grpc.insecure_channel('localhost:50051')
    greeter_stub = helloworld_pb2_grpc.GreeterStub(channel)
    route_guide_stub = route_guide_pb2_grpc.RouteGuideStub(channel)
    greeter_response = greeter_stub.SayHello(
        helloworld_pb2.HelloRequest(name='you'))
    print("Greeter client received: " + greeter_response.message)
    print("-------------- GetFeature --------------")
    guide_get_feature(route_guide_stub)
    print("-------------- ListFeatures --------------")
    guide_list_features(route_guide_stub)
    print("-------------- RecordRoute --------------")
    guide_record_route(route_guide_stub)
    print("-------------- RouteChat --------------")
    guide_route_chat(route_guide_stub)
示例#10
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:
        greeter_stub = helloworld_pb2_grpc.GreeterStub(channel)
        route_guide_stub = route_guide_pb2_grpc.RouteGuideStub(channel)
        greeter_response = greeter_stub.SayHello(
            helloworld_pb2.HelloRequest(name='you'))
        print("Greeter client received: " + greeter_response.message)
        print("-------------- GetFeature --------------")
        guide_get_feature(route_guide_stub)
        print("-------------- ListFeatures --------------")
        guide_list_features(route_guide_stub)
        print("-------------- RecordRoute --------------")
        guide_record_route(route_guide_stub)
        print("-------------- RouteChat --------------")
        guide_route_chat(route_guide_stub)
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.

    # target = 'fargate-grpc-load-balancer-1566060198.us-east-2.elb.amazonaws.com:50051'
    target = 'app.boarlabs.net:50051'

    credentials = grpc.ssl_channel_credentials()

    with grpc.secure_channel(target, credentials) as channel:
        stub = route_guide_pb2_grpc.RouteGuideStub(channel)
        print("-------------- GetFeature --------------")
        guide_get_feature(stub)
        print("-------------- ListFeatures --------------")
        guide_list_features(stub)
        print("-------------- RecordRoute --------------")
        guide_record_route(stub)
        print("-------------- RouteChat --------------")
        guide_route_chat(stub)
示例#12
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 open('auth.crt', 'rb') as f:
        trusted_certs = f.read()

    credentials = grpc.ssl_channel_credentials(root_certificates=trusted_certs,
                                               private_key=None,
                                               certificate_chain=None)
    with grpc.secure_channel('sbia-pc103.med.upenn.edu:50051',
                             credentials) as channel:
        stub = route_guide_pb2_grpc.RouteGuideStub(channel)
        print("-------------- GetFeature --------------")
        guide_get_feature(stub)
        print("-------------- ListFeatures --------------")
        guide_list_features(stub)
        print("-------------- RecordRoute --------------")
        guide_record_route(stub)
        print("-------------- RouteChat --------------")
        guide_route_chat(stub)
示例#13
0
def run():
    channel = grpc.insecure_channel('localhost:50051')
    stub = route_guide_pb2_grpc.RouteGuideStub(channel)
    print("-------------- GetFeature --------------")
    guide_get_feature(stub)
示例#14
0
import grpc

import route_guide_pb2
import route_guide_pb2_grpc


def guide_get_feature(stub):
    point = route_guide_pb2.Point(latitude=123, longitude=456)
    feature = stub.GetFeature(point)
    print(feature)


if __name__ == '__main__':
    with grpc.insecure_channel('localhost:55051') as channel:
        stub = route_guide_pb2_grpc.RouteGuideStub(channel)
        guide_get_feature(stub)