from messagebus import DefaultToken
from messagehandler import MessageHandlerBuilder
from messageprocessor import (
    DefaultMessageProcessorExecutorFactory,
    MessageProcessorMessageHandler,
)
from messageprocessorutil import LoggingProcessorCallback
from service_locator.service import ServiceLocator
from service_locator_api.shared.token import (
    TK_HV_FIND_SERVICE,
    TK_CMP_REG_SERVICE,
)
from service_locator.processor import (
    GetConfigProcessor,
    RegServiceProcessor,
    HealthCheckProcessor,
)

class StoreConfigMessageHandlerBuilder(MessageHandlerBuilder):

    def __init__(self):
        self.service_locator = ServiceLocator()

    def build_singletons(self):
        return

    def build_message_handler(self, message, event):
        return MessageProcessorMessageHandler(
            event_processors=None,
            message_processors={
                TK_HV_FIND_SERVICE: GetConfigProcessor(service_locator=self.service_locator),
                TK_CMP_REG_SERVICE: RegServiceProcessor(service_locator=self.service_locator),
                DefaultToken.TK_SYS_HEALTH_CHECK: HealthCheckProcessor(),
            },
            executor_factory=DefaultMessageProcessorExecutorFactory(
                [
                    LoggingProcessorCallback(),
                ]
            ),
        )

    def destroy_message_handler(self, message_handler):
        pass

    def destroy_singletons(self):
        pass
