fix: モジュールが読み込まれない場合があったので修正

This commit is contained in:
usbharu 2024-07-29 16:14:01 +09:00
parent da22a2a29f
commit 0461656738
3 changed files with 57 additions and 51 deletions

View File

@ -32,6 +32,57 @@ import java.util.*
val logger = LoggerFactory.getLogger("MAIN") val logger = LoggerFactory.getLogger("MAIN")
val mainModule = module {
single<AssignQueuedTaskDecider> {
AssignQueuedTaskDeciderImpl(get(), get())
}
single<TaskScanner> { TaskScannerImpl(get()) }
single<TaskPublishService> { TaskPublishServiceImpl(get(), get(), get()) }
single<TaskManagementService> {
TaskManagementServiceImpl(
taskScanner = get(),
queueStore = get(),
taskDefinitionRepository = get(),
assignQueuedTaskDecider = get(),
retryPolicyFactory = get(),
taskRepository = get(),
queueScanner = get(),
taskResultRepository = get()
)
}
single<RegisterTaskService> { RegisterTaskServiceImpl(get()) }
single<QueueStore> { QueueStoreImpl(get()) }
single<QueueScanner> { QueueScannerImpl(get()) }
single<QueuedTaskAssigner> { QueuedTaskAssignerImpl(get(), get()) }
single<ProducerService> { ProducerServiceImpl(get()) }
single<PropertySerializerFactory> { DefaultPropertySerializerFactory() }
single<ConsumerService> { 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() { fun main() {
val moduleContexts = ServiceLoader.load(ModuleContext::class.java) val moduleContexts = ServiceLoader.load(ModuleContext::class.java)
@ -47,56 +98,9 @@ fun main() {
single<RetryPolicyFactory> { single<RetryPolicyFactory> {
DefaultRetryPolicyFactory(mapOf("" to ExponentialRetryPolicy())) DefaultRetryPolicyFactory(mapOf("" to ExponentialRetryPolicy()))
} }
single<AssignQueuedTaskDecider> {
AssignQueuedTaskDeciderImpl(get(), get())
}
single<TaskScanner> { TaskScannerImpl(get()) }
single<TaskPublishService> { TaskPublishServiceImpl(get(), get(), get()) }
single<TaskManagementService> {
TaskManagementServiceImpl(
taskScanner = get(),
queueStore = get(),
taskDefinitionRepository = get(),
assignQueuedTaskDecider = get(),
retryPolicyFactory = get(),
taskRepository = get(),
queueScanner = get(),
taskResultRepository = get()
)
}
single<RegisterTaskService> { RegisterTaskServiceImpl(get()) }
single<QueueStore> { QueueStoreImpl(get()) }
single<QueueScanner> { QueueScannerImpl(get()) }
single<QueuedTaskAssigner> { QueuedTaskAssignerImpl(get(), get()) }
single<ProducerService> { ProducerServiceImpl(get()) }
single<PropertySerializerFactory> { DefaultPropertySerializerFactory() }
single<ConsumerService> { 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<OwlBrokerApplication>() val application = koin.koin.get<OwlBrokerApplication>()

View File

@ -17,6 +17,7 @@
package dev.usbharu.owl.producer.embedded package dev.usbharu.owl.producer.embedded
import dev.usbharu.owl.broker.OwlBrokerApplication import dev.usbharu.owl.broker.OwlBrokerApplication
import dev.usbharu.owl.broker.mainModule
import dev.usbharu.owl.common.retry.RetryPolicyFactory import dev.usbharu.owl.common.retry.RetryPolicyFactory
import dev.usbharu.owl.common.task.PublishedTask import dev.usbharu.owl.common.task.PublishedTask
import dev.usbharu.owl.common.task.Task import dev.usbharu.owl.common.task.Task
@ -41,7 +42,7 @@ class EmbeddedGrpcOwlProducer(
config.retryPolicyFactory config.retryPolicyFactory
} }
} }
modules(module, config.moduleContext.module()) modules(mainModule, module, config.moduleContext.module())
}.koin }.koin
application.get<OwlBrokerApplication>().start(config.port.toInt()) application.get<OwlBrokerApplication>().start(config.port.toInt())

View File

@ -19,6 +19,7 @@ package dev.usbharu.owl.producer.embedded
import dev.usbharu.owl.broker.OwlBrokerApplication import dev.usbharu.owl.broker.OwlBrokerApplication
import dev.usbharu.owl.broker.domain.exception.InvalidRepositoryException import dev.usbharu.owl.broker.domain.exception.InvalidRepositoryException
import dev.usbharu.owl.broker.domain.model.producer.ProducerRepository 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.broker.service.*
import dev.usbharu.owl.common.property.PropertySerializerFactory import dev.usbharu.owl.common.property.PropertySerializerFactory
import dev.usbharu.owl.common.retry.RetryPolicyFactory import dev.usbharu.owl.common.retry.RetryPolicyFactory
@ -59,7 +60,7 @@ class EmbeddedOwlProducer(
embeddedOwlProducerConfig.propertySerializerFactory embeddedOwlProducerConfig.propertySerializerFactory
} }
} }
modules(module, embeddedOwlProducerConfig.moduleContext.module()) modules(mainModule, module, embeddedOwlProducerConfig.moduleContext.module())
}.koin }.koin
application.getOrNull<ProducerRepository>() application.getOrNull<ProducerRepository>()