From 046165673879f27741dbd2ce7b17274b22c4dbae Mon Sep 17 00:00:00 2001 From: usbharu Date: Mon, 29 Jul 2024 16:14:01 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=83=A2=E3=82=B8=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=81=8C=E8=AA=AD=E3=81=BF=E8=BE=BC=E3=81=BE=E3=82=8C?= =?UTF-8?q?=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88=E3=81=8C=E3=81=82=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/dev/usbharu/owl/broker/Main.kt | 102 +++++++++--------- .../embedded/EmbeddedGrpcOwlProducer.kt | 3 +- .../producer/embedded/EmbeddedOwlProducer.kt | 3 +- 3 files changed, 57 insertions(+), 51 deletions(-) diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/Main.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/Main.kt index 69274668..d5f25364 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/Main.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/Main.kt @@ -32,6 +32,57 @@ import java.util.* val logger = LoggerFactory.getLogger("MAIN") +val mainModule = module { + single { + AssignQueuedTaskDeciderImpl(get(), get()) + } + single { TaskScannerImpl(get()) } + single { TaskPublishServiceImpl(get(), get(), get()) } + single { + TaskManagementServiceImpl( + taskScanner = get(), + queueStore = get(), + taskDefinitionRepository = get(), + assignQueuedTaskDecider = get(), + retryPolicyFactory = get(), + taskRepository = get(), + queueScanner = get(), + taskResultRepository = get() + ) + } + single { RegisterTaskServiceImpl(get()) } + single { QueueStoreImpl(get()) } + single { QueueScannerImpl(get()) } + single { QueuedTaskAssignerImpl(get(), get()) } + single { ProducerServiceImpl(get()) } + single { DefaultPropertySerializerFactory() } + single { ConsumerServiceImpl(get()) } + single { + OwlBrokerApplication( + assignmentTaskService = get(), + definitionTaskService = get(), + producerService = get(), + subscribeTaskService = get(), + taskPublishService = get(), + taskManagementService = get(), + taskResultSubscribeService = get(), + taskResultService = get() + ) + } + single { AssignmentTaskService(queuedTaskAssigner = get(), propertySerializerFactory = get()) } + single { DefinitionTaskService(registerTaskService = get()) } + single { dev.usbharu.owl.broker.interfaces.grpc.ProducerService(producerService = get()) } + single { SubscribeTaskService(consumerService = get()) } + single { + dev.usbharu.owl.broker.interfaces.grpc.TaskPublishService( + taskPublishService = get(), + propertySerializerFactory = get() + ) + } + single { TaskResultService(taskManagementService = get(), propertySerializerFactory = get()) } + single { TaskResultSubscribeService(taskManagementService = get(), propertySerializerFactory = get()) } +} + fun main() { val moduleContexts = ServiceLoader.load(ModuleContext::class.java) @@ -47,56 +98,9 @@ fun main() { single { DefaultRetryPolicyFactory(mapOf("" to ExponentialRetryPolicy())) } - single { - AssignQueuedTaskDeciderImpl(get(), get()) - } - single { TaskScannerImpl(get()) } - single { TaskPublishServiceImpl(get(), get(), get()) } - single { - TaskManagementServiceImpl( - taskScanner = get(), - queueStore = get(), - taskDefinitionRepository = get(), - assignQueuedTaskDecider = get(), - retryPolicyFactory = get(), - taskRepository = get(), - queueScanner = get(), - taskResultRepository = get() - ) - } - single { RegisterTaskServiceImpl(get()) } - single { QueueStoreImpl(get()) } - single { QueueScannerImpl(get()) } - single { QueuedTaskAssignerImpl(get(), get()) } - single { ProducerServiceImpl(get()) } - single { DefaultPropertySerializerFactory() } - single { ConsumerServiceImpl(get()) } - single { - OwlBrokerApplication( - assignmentTaskService = get(), - definitionTaskService = get(), - producerService = get(), - subscribeTaskService = get(), - taskPublishService = get(), - taskManagementService = get(), - taskResultSubscribeService = get(), - taskResultService = get() - ) - } - single { AssignmentTaskService(queuedTaskAssigner = get(), propertySerializerFactory = get()) } - single { DefinitionTaskService(registerTaskService = get()) } - single { dev.usbharu.owl.broker.interfaces.grpc.ProducerService(producerService = get()) } - single { SubscribeTaskService(consumerService = get()) } - single { - dev.usbharu.owl.broker.interfaces.grpc.TaskPublishService( - taskPublishService = get(), - propertySerializerFactory = get() - ) - } - single { TaskResultService(taskManagementService = get(), propertySerializerFactory = get()) } - single { TaskResultSubscribeService(taskManagementService = get(), propertySerializerFactory = get()) } + } - modules(module, moduleContext.module()) + modules(mainModule, module, moduleContext.module()) } val application = koin.koin.get() diff --git a/owl/owl-producer/owl-producer-embedded/src/main/kotlin/dev/usbharu/owl/producer/embedded/EmbeddedGrpcOwlProducer.kt b/owl/owl-producer/owl-producer-embedded/src/main/kotlin/dev/usbharu/owl/producer/embedded/EmbeddedGrpcOwlProducer.kt index c30cb199..cbf29443 100644 --- a/owl/owl-producer/owl-producer-embedded/src/main/kotlin/dev/usbharu/owl/producer/embedded/EmbeddedGrpcOwlProducer.kt +++ b/owl/owl-producer/owl-producer-embedded/src/main/kotlin/dev/usbharu/owl/producer/embedded/EmbeddedGrpcOwlProducer.kt @@ -17,6 +17,7 @@ package dev.usbharu.owl.producer.embedded import dev.usbharu.owl.broker.OwlBrokerApplication +import dev.usbharu.owl.broker.mainModule import dev.usbharu.owl.common.retry.RetryPolicyFactory import dev.usbharu.owl.common.task.PublishedTask import dev.usbharu.owl.common.task.Task @@ -41,7 +42,7 @@ class EmbeddedGrpcOwlProducer( config.retryPolicyFactory } } - modules(module, config.moduleContext.module()) + modules(mainModule, module, config.moduleContext.module()) }.koin application.get().start(config.port.toInt()) diff --git a/owl/owl-producer/owl-producer-embedded/src/main/kotlin/dev/usbharu/owl/producer/embedded/EmbeddedOwlProducer.kt b/owl/owl-producer/owl-producer-embedded/src/main/kotlin/dev/usbharu/owl/producer/embedded/EmbeddedOwlProducer.kt index c3323c8f..c9a30c9c 100644 --- a/owl/owl-producer/owl-producer-embedded/src/main/kotlin/dev/usbharu/owl/producer/embedded/EmbeddedOwlProducer.kt +++ b/owl/owl-producer/owl-producer-embedded/src/main/kotlin/dev/usbharu/owl/producer/embedded/EmbeddedOwlProducer.kt @@ -19,6 +19,7 @@ package dev.usbharu.owl.producer.embedded import dev.usbharu.owl.broker.OwlBrokerApplication import dev.usbharu.owl.broker.domain.exception.InvalidRepositoryException import dev.usbharu.owl.broker.domain.model.producer.ProducerRepository +import dev.usbharu.owl.broker.mainModule import dev.usbharu.owl.broker.service.* import dev.usbharu.owl.common.property.PropertySerializerFactory import dev.usbharu.owl.common.retry.RetryPolicyFactory @@ -59,7 +60,7 @@ class EmbeddedOwlProducer( embeddedOwlProducerConfig.propertySerializerFactory } } - modules(module, embeddedOwlProducerConfig.moduleContext.module()) + modules(mainModule, module, embeddedOwlProducerConfig.moduleContext.module()) }.koin application.getOrNull()