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, 13, 16, 40), 'examples.configs.LocalDockerConfig', 'configs.LocalDockerConfig', ({}, {}), '()', False, 'from examples import configs\n'), ((18, 13, 18, 42), 'needlestack.servicers.factory.create_server', 'factory.create_server', ({(18, 35, 18, 41): 'config'}, {}), '(config)', False, 'from needlestack.servicers import factory\n'), ((19, 14, 19, 62), 'needlestack.servicers.factory.create_zookeeper_cluster_manager', 'factory.create_zookeeper_cluster_manager', ({(19, 55, 19, 61): 'config'}, {}), '(config)', False, 'from needlestack.servicers import factory\n'), ((24, 13, 24, 29), 'grpc_health.v1.health.HealthServicer', 'HealthServicer', ({}, {}), '()', False, 'from grpc_health.v1.health import HealthServicer\n'), ((25, 4, 25, 64), 'grpc_health.v1.health_pb2_grpc.add_HealthServicer_to_server', 'health_pb2_grpc.add_HealthServicer_to_server', ({(25, 49, 25, 55): 'health', (25, 57, 25, 63): 'server'}, {}), '(health, server)', False, 'from grpc_health.v1 import health_pb2, health_pb2_grpc\n'), ((28, 4, 28, 25), 'needlestack.servicers.factory.serve', 'factory.serve', ({(28, 18, 28, 24): 'server'}, {}), '(server)', False, 'from needlestack.servicers import factory\n'), ((12, 0, 12, 26), 'logging.getLogger', 'logging.getLogger', ({(12, 18, 12, 25): '"""kazoo"""'}, {}), "('kazoo')", False, 'import logging\n'), ((22, 52, 22, 83), 'needlestack.servicers.merger.MergerServicer', 'MergerServicer', ({(22, 67, 22, 73): 'config', (22, 75, 22, 82): 'manager'}, {}), '(config, manager)', False, 'from needlestack.servicers.merger import MergerServicer\n')]