コード例 #1
0
def Recordtime(addr, key):
    # 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(addr) as channel:
        stub = metaserver_pb2_grpc.MetaStub(channel)

        request = metaserver_pb2.TimeRequest()

        # refer to https://developers.google.com/protocol-buffers/docs/reference/python-generated#embedded_message

        request.key = key
        response = stub.Recordtime(request)

    print("Recordtime client received: " + response.message)
コード例 #2
0
def getMetaspace(addr, key):
    # 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(addr) as channel:
        stub = metaserver_pb2_grpc.MetaStub(channel)

        request = metaserver_pb2.GetRequest()

        # refer to https://developers.google.com/protocol-buffers/docs/reference/python-generated#embedded_message

        request.key = key

        response = stub.Getmetaspace(request)
        #send the publish event

    return response.message
コード例 #3
0
def putMeta(addr, key, metainfo):
    # 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(addr) as channel:
        stub = metaserver_pb2_grpc.MetaStub(channel)

        request = metaserver_pb2.PutRequest()

        # refer to https://developers.google.com/protocol-buffers/docs/reference/python-generated#embedded_message

        request.key = key
        request.value = metainfo

        print("debug put request")
        print(metainfo)
        response = stub.Putmeta(request)
        #send the publish event

    print("PutRequest client received: " + response.message)