import logging

from grpc_health.v1 import health_pb2, health_pb2_grpc
from grpc_health.v1.health import HealthServicer

from needlestack.apis import servicers_pb2_grpc
from needlestack.servicers import factory
from needlestack.servicers.merger import MergerServicer

from examples import configs

logging.getLogger("kazoo").setLevel("WARN")


def main():
    config = configs.LocalDockerConfig()

    server = factory.create_server(config)
    manager = factory.create_zookeeper_cluster_manager(config)
    manager.startup()

    servicers_pb2_grpc.add_MergerServicer_to_server(MergerServicer(config, manager), server)

    health = HealthServicer()
    health_pb2_grpc.add_HealthServicer_to_server(health, server)
    health.set("Merger", health_pb2.HealthCheckResponse.SERVING)

    factory.serve(server)


if __name__ == "__main__":
    main()

[(16, 'examples.configs.LocalDockerConfig', 'configs.LocalDockerConfig', False, 'from examples import configs\n'), (18, 'needlestack.servicers.factory.create_server', 'factory.create_server', False, 'from needlestack.servicers import factory\n'), (19, 'needlestack.servicers.factory.create_zookeeper_cluster_manager', 'factory.create_zookeeper_cluster_manager', False, 'from needlestack.servicers import factory\n'), (24, 'grpc_health.v1.health.HealthServicer', 'HealthServicer', False, 'from grpc_health.v1.health import HealthServicer\n'), (25, 'grpc_health.v1.health_pb2_grpc.add_HealthServicer_to_server', 'health_pb2_grpc.add_HealthServicer_to_server', False, 'from grpc_health.v1 import health_pb2, health_pb2_grpc\n'), (28, 'needlestack.servicers.factory.serve', 'factory.serve', False, 'from needlestack.servicers import factory\n'), (12, 'logging.getLogger', 'logging.getLogger', False, 'import logging\n'), (22, 'needlestack.servicers.merger.MergerServicer', 'MergerServicer', False, 'from needlestack.servicers.merger import MergerServicer\n')]