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,21 +32,7 @@ import java.util.*
val logger = LoggerFactory.getLogger("MAIN")
fun main() {
val moduleContexts = ServiceLoader.load(ModuleContext::class.java)
val moduleContext = moduleContexts.first()
logger.info("Use module name: {}", moduleContext)
val koin = startKoin {
printLogger()
val module = module {
single<RetryPolicyFactory> {
DefaultRetryPolicyFactory(mapOf("" to ExponentialRetryPolicy()))
}
val mainModule = module {
single<AssignQueuedTaskDecider> {
AssignQueuedTaskDeciderImpl(get(), get())
}
@ -95,8 +81,26 @@ fun main() {
}
single { TaskResultService(taskManagementService = get(), propertySerializerFactory = get()) }
single { TaskResultSubscribeService(taskManagementService = get(), propertySerializerFactory = get()) }
}
fun main() {
val moduleContexts = ServiceLoader.load(ModuleContext::class.java)
val moduleContext = moduleContexts.first()
logger.info("Use module name: {}", moduleContext)
val koin = startKoin {
printLogger()
val module = module {
single<RetryPolicyFactory> {
DefaultRetryPolicyFactory(mapOf("" to ExponentialRetryPolicy()))
}
modules(module, moduleContext.module())
}
modules(mainModule, module, moduleContext.module())
}
val application = koin.koin.get<OwlBrokerApplication>()

View File

@ -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<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.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<ProducerRepository>()