def main_handler()

in step1/src/client/client.py [0:0]


def main_handler():
    q, count = random.choice(list(queries.items()))

    channel = grpc.insecure_channel(SERVER_ADDR)
    stub = shakesapp_pb2_grpc.ShakespeareServiceStub(channel)
    logger.info(f"request to server with query: {q}")
    resp = stub.GetMatchCount(shakesapp_pb2.ShakespeareRequest(query=q))
    if count != resp.match_count:
        raise UnexpectedResultError(
            f"The expected count for '{q}' was {count}, but result was {resp.match_count } obtained"
        )
    result = str(resp.match_count)
    logger.info(f"matched count for '{q}' is {result}")
    return result