diff --git a/hideout-core/src/intTest/kotlin/activitypub/inbox/InboxTest.kt b/hideout-core/src/intTest/kotlin/activitypub/inbox/InboxTest.kt index aab8b225..40f9ffdf 100644 --- a/hideout-core/src/intTest/kotlin/activitypub/inbox/InboxTest.kt +++ b/hideout-core/src/intTest/kotlin/activitypub/inbox/InboxTest.kt @@ -18,6 +18,8 @@ package activitypub.inbox import dev.usbharu.hideout.SpringApplication import dev.usbharu.hideout.util.Base64Util +import dev.usbharu.owl.producer.api.OwlProducer +import kotlinx.coroutines.runBlocking import org.flywaydb.core.Flyway import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.BeforeEach @@ -150,9 +152,12 @@ class InboxTest { companion object { @JvmStatic @AfterAll - fun dropDatabase(@Autowired flyway: Flyway) { + fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) { flyway.clean() flyway.migrate() + runBlocking { + owlProducer.stop() + } } } } diff --git a/hideout-core/src/intTest/kotlin/activitypub/note/NoteTest.kt b/hideout-core/src/intTest/kotlin/activitypub/note/NoteTest.kt index 604d4ee3..62d7d3ce 100644 --- a/hideout-core/src/intTest/kotlin/activitypub/note/NoteTest.kt +++ b/hideout-core/src/intTest/kotlin/activitypub/note/NoteTest.kt @@ -17,6 +17,8 @@ package activitypub.note import dev.usbharu.hideout.SpringApplication +import dev.usbharu.owl.producer.api.OwlProducer +import kotlinx.coroutines.runBlocking import org.flywaydb.core.Flyway import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.BeforeEach @@ -230,9 +232,12 @@ class NoteTest { companion object { @JvmStatic @AfterAll - fun dropDatabase(@Autowired flyway: Flyway) { + fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) { flyway.clean() flyway.migrate() + runBlocking { + owlProducer.stop() + } } } } diff --git a/hideout-core/src/intTest/kotlin/activitypub/webfinger/WebFingerTest.kt b/hideout-core/src/intTest/kotlin/activitypub/webfinger/WebFingerTest.kt index 171ceb98..a12bbfd4 100644 --- a/hideout-core/src/intTest/kotlin/activitypub/webfinger/WebFingerTest.kt +++ b/hideout-core/src/intTest/kotlin/activitypub/webfinger/WebFingerTest.kt @@ -18,6 +18,8 @@ package activitypub.webfinger import dev.usbharu.hideout.SpringApplication import dev.usbharu.hideout.application.external.Transaction +import dev.usbharu.owl.producer.api.OwlProducer +import kotlinx.coroutines.runBlocking import org.flywaydb.core.Flyway import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.Test @@ -103,9 +105,12 @@ class WebFingerTest { companion object { @JvmStatic @AfterAll - fun dropDatabase(@Autowired flyway: Flyway) { + fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) { flyway.clean() flyway.migrate() + runBlocking { + owlProducer.stop() + } } } } diff --git a/hideout-core/src/intTest/kotlin/mastodon/account/AccountApiPaginationTest.kt b/hideout-core/src/intTest/kotlin/mastodon/account/AccountApiPaginationTest.kt index 861c5c23..81971e7a 100644 --- a/hideout-core/src/intTest/kotlin/mastodon/account/AccountApiPaginationTest.kt +++ b/hideout-core/src/intTest/kotlin/mastodon/account/AccountApiPaginationTest.kt @@ -20,6 +20,8 @@ import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import dev.usbharu.hideout.SpringApplication import dev.usbharu.hideout.domain.mastodon.model.generated.Status +import dev.usbharu.owl.producer.api.OwlProducer +import kotlinx.coroutines.runBlocking import org.assertj.core.api.Assertions.assertThat import org.flywaydb.core.Flyway import org.junit.jupiter.api.AfterAll @@ -152,9 +154,13 @@ class AccountApiPaginationTest { companion object { @JvmStatic @AfterAll - fun dropDatabase(@Autowired flyway: Flyway) { + fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) { flyway.clean() flyway.migrate() + runBlocking { + owlProducer.stop() + } } + } } \ No newline at end of file diff --git a/hideout-core/src/intTest/kotlin/mastodon/account/AccountApiTest.kt b/hideout-core/src/intTest/kotlin/mastodon/account/AccountApiTest.kt index 77f785c9..c936764d 100644 --- a/hideout-core/src/intTest/kotlin/mastodon/account/AccountApiTest.kt +++ b/hideout-core/src/intTest/kotlin/mastodon/account/AccountApiTest.kt @@ -19,6 +19,8 @@ package mastodon.account import dev.usbharu.hideout.SpringApplication import dev.usbharu.hideout.core.domain.model.actor.ActorRepository import dev.usbharu.hideout.core.infrastructure.exposedquery.FollowerQueryServiceImpl +import dev.usbharu.owl.producer.api.OwlProducer +import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runTest import org.assertj.core.api.Assertions.assertThat import org.flywaydb.core.Flyway @@ -462,9 +464,12 @@ class AccountApiTest { companion object { @JvmStatic @AfterAll - fun dropDatabase(@Autowired flyway: Flyway) { + fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) { flyway.clean() flyway.migrate() + runBlocking { + owlProducer.stop() + } } } } diff --git a/hideout-core/src/intTest/kotlin/mastodon/apps/AppTest.kt b/hideout-core/src/intTest/kotlin/mastodon/apps/AppTest.kt index 65e42b4a..8ce170eb 100644 --- a/hideout-core/src/intTest/kotlin/mastodon/apps/AppTest.kt +++ b/hideout-core/src/intTest/kotlin/mastodon/apps/AppTest.kt @@ -18,6 +18,8 @@ package mastodon.apps import dev.usbharu.hideout.SpringApplication import dev.usbharu.hideout.core.infrastructure.springframework.oauth2.RegisteredClient +import dev.usbharu.owl.producer.api.OwlProducer +import kotlinx.coroutines.runBlocking import org.assertj.core.api.Assertions.assertThat import org.flywaydb.core.Flyway import org.jetbrains.exposed.sql.selectAll @@ -107,9 +109,12 @@ class AppTest { companion object { @JvmStatic @AfterAll - fun dropDatabase(@Autowired flyway: Flyway) { + fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) { flyway.clean() flyway.migrate() + runBlocking { + owlProducer.stop() + } } } } diff --git a/hideout-core/src/intTest/kotlin/mastodon/filter/FilterTest.kt b/hideout-core/src/intTest/kotlin/mastodon/filter/FilterTest.kt index 89fe1f5c..bb3dccae 100644 --- a/hideout-core/src/intTest/kotlin/mastodon/filter/FilterTest.kt +++ b/hideout-core/src/intTest/kotlin/mastodon/filter/FilterTest.kt @@ -22,6 +22,8 @@ import dev.usbharu.hideout.domain.mastodon.model.generated.FilterKeywordsPostReq import dev.usbharu.hideout.domain.mastodon.model.generated.FilterPostRequest import dev.usbharu.hideout.domain.mastodon.model.generated.FilterPostRequestKeyword import dev.usbharu.hideout.domain.mastodon.model.generated.V1FilterPostRequest +import dev.usbharu.owl.producer.api.OwlProducer +import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runTest import org.flywaydb.core.Flyway import org.junit.jupiter.api.AfterAll @@ -702,9 +704,12 @@ class FilterTest { companion object { @JvmStatic @AfterAll - fun dropDatabase(@Autowired flyway: Flyway) { + fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) { flyway.clean() flyway.migrate() + runBlocking { + owlProducer.stop() + } } } } \ No newline at end of file diff --git a/hideout-core/src/intTest/kotlin/mastodon/media/MediaTest.kt b/hideout-core/src/intTest/kotlin/mastodon/media/MediaTest.kt index b745cf0c..77f23281 100644 --- a/hideout-core/src/intTest/kotlin/mastodon/media/MediaTest.kt +++ b/hideout-core/src/intTest/kotlin/mastodon/media/MediaTest.kt @@ -20,6 +20,8 @@ import dev.usbharu.hideout.SpringApplication import dev.usbharu.hideout.core.service.media.MediaDataStore import dev.usbharu.hideout.core.service.media.MediaSaveRequest import dev.usbharu.hideout.core.service.media.SuccessSavedMedia +import dev.usbharu.owl.producer.api.OwlProducer +import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runTest import org.flywaydb.core.Flyway import org.junit.jupiter.api.AfterAll @@ -131,9 +133,12 @@ class MediaTest { companion object { @JvmStatic @AfterAll - fun dropDatabase(@Autowired flyway: Flyway) { + fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) { flyway.clean() flyway.migrate() + runBlocking { + owlProducer.stop() + } } } diff --git a/hideout-core/src/intTest/kotlin/mastodon/notifications/ExposedNotificationsApiPaginationTest.kt b/hideout-core/src/intTest/kotlin/mastodon/notifications/ExposedNotificationsApiPaginationTest.kt index ba30f9a7..7405caf6 100644 --- a/hideout-core/src/intTest/kotlin/mastodon/notifications/ExposedNotificationsApiPaginationTest.kt +++ b/hideout-core/src/intTest/kotlin/mastodon/notifications/ExposedNotificationsApiPaginationTest.kt @@ -20,6 +20,8 @@ import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import dev.usbharu.hideout.SpringApplication import dev.usbharu.hideout.domain.mastodon.model.generated.Notification +import dev.usbharu.owl.producer.api.OwlProducer +import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runTest import org.assertj.core.api.Assertions.assertThat import org.flywaydb.core.Flyway @@ -172,9 +174,12 @@ class ExposedNotificationsApiPaginationTest { companion object { @JvmStatic @AfterAll - fun dropDatabase(@Autowired flyway: Flyway) { + fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) { flyway.clean() flyway.migrate() + runBlocking { + owlProducer.stop() + } } } } \ No newline at end of file diff --git a/hideout-core/src/intTest/kotlin/mastodon/notifications/MongodbNotificationsApiPaginationTest.kt b/hideout-core/src/intTest/kotlin/mastodon/notifications/MongodbNotificationsApiPaginationTest.kt index 58c67aaa..0de15332 100644 --- a/hideout-core/src/intTest/kotlin/mastodon/notifications/MongodbNotificationsApiPaginationTest.kt +++ b/hideout-core/src/intTest/kotlin/mastodon/notifications/MongodbNotificationsApiPaginationTest.kt @@ -23,6 +23,8 @@ import dev.usbharu.hideout.domain.mastodon.model.generated.Notification import dev.usbharu.hideout.mastodon.domain.model.MastodonNotification import dev.usbharu.hideout.mastodon.domain.model.NotificationType import dev.usbharu.hideout.mastodon.infrastructure.mongorepository.MongoMastodonNotificationRepository +import dev.usbharu.owl.producer.api.OwlProducer +import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runTest import org.assertj.core.api.Assertions import org.flywaydb.core.Flyway @@ -178,7 +180,7 @@ class MongodbNotificationsApiPaginationTest { @JvmStatic @BeforeAll fun setupMongodb( - @Autowired mongoMastodonNotificationRepository: MongoMastodonNotificationRepository + @Autowired mongoMastodonNotificationRepository: MongoMastodonNotificationRepository, ) { mongoMastodonNotificationRepository.deleteAll() @@ -203,11 +205,14 @@ class MongodbNotificationsApiPaginationTest { @AfterAll fun dropDatabase( @Autowired flyway: Flyway, - @Autowired mongodbMastodonNotificationRepository: MongoMastodonNotificationRepository + @Autowired mongodbMastodonNotificationRepository: MongoMastodonNotificationRepository, + @Autowired owlProducer: OwlProducer, ) { flyway.clean() flyway.migrate() - + runBlocking { + owlProducer.stop() + } mongodbMastodonNotificationRepository.deleteAll() } } diff --git a/hideout-core/src/intTest/kotlin/mastodon/status/StatusTest.kt b/hideout-core/src/intTest/kotlin/mastodon/status/StatusTest.kt index 4c805205..817d5dfc 100644 --- a/hideout-core/src/intTest/kotlin/mastodon/status/StatusTest.kt +++ b/hideout-core/src/intTest/kotlin/mastodon/status/StatusTest.kt @@ -22,6 +22,8 @@ import dev.usbharu.hideout.core.domain.model.emoji.UnicodeEmoji import dev.usbharu.hideout.core.infrastructure.exposedrepository.CustomEmojis import dev.usbharu.hideout.core.infrastructure.exposedrepository.Reactions import dev.usbharu.hideout.core.infrastructure.exposedrepository.toReaction +import dev.usbharu.owl.producer.api.OwlProducer +import kotlinx.coroutines.runBlocking import org.assertj.core.api.Assertions.assertThat import org.flywaydb.core.Flyway import org.jetbrains.exposed.sql.and @@ -236,9 +238,12 @@ class StatusTest { companion object { @JvmStatic @AfterAll - fun dropDatabase(@Autowired flyway: Flyway) { + fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) { flyway.clean() flyway.migrate() + runBlocking { + owlProducer.stop() + } } } } diff --git a/hideout-core/src/intTest/kotlin/mastodon/timelines/TimelineApiTest.kt b/hideout-core/src/intTest/kotlin/mastodon/timelines/TimelineApiTest.kt index 5ebcb3a9..21719e85 100644 --- a/hideout-core/src/intTest/kotlin/mastodon/timelines/TimelineApiTest.kt +++ b/hideout-core/src/intTest/kotlin/mastodon/timelines/TimelineApiTest.kt @@ -17,6 +17,8 @@ package mastodon.timelines import dev.usbharu.hideout.SpringApplication +import dev.usbharu.owl.producer.api.OwlProducer +import kotlinx.coroutines.runBlocking import org.flywaydb.core.Flyway import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.BeforeEach @@ -123,9 +125,12 @@ class TimelineApiTest { companion object { @JvmStatic @AfterAll - fun dropDatabase(@Autowired flyway: Flyway) { + fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) { flyway.clean() flyway.migrate() + runBlocking { + owlProducer.stop() + } } } } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/application/external/OwlProducerRunner.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/application/external/OwlProducerRunner.kt index 06f74c44..ca86bce1 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/application/external/OwlProducerRunner.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/application/external/OwlProducerRunner.kt @@ -19,17 +19,25 @@ package dev.usbharu.hideout.application.external import dev.usbharu.owl.common.task.TaskDefinition import dev.usbharu.owl.producer.api.OwlProducer import kotlinx.coroutines.runBlocking +import org.springframework.beans.factory.DisposableBean import org.springframework.boot.ApplicationArguments import org.springframework.boot.ApplicationRunner import org.springframework.stereotype.Component @Component class OwlProducerRunner(private val owlProducer: OwlProducer, private val taskDefinitions: List>) : - ApplicationRunner { + ApplicationRunner, DisposableBean { override fun run(args: ApplicationArguments?) { runBlocking { owlProducer.start() taskDefinitions.forEach { taskDefinition -> owlProducer.registerTask(taskDefinition) } } } -} \ No newline at end of file + + override fun destroy() { + System.err.println("destroy aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") + runBlocking { + owlProducer.stop() + } + } +} diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/job/DeliverCreateTask.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/job/DeliverCreateTask.kt index b989b782..2c645290 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/job/DeliverCreateTask.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/job/DeliverCreateTask.kt @@ -31,5 +31,4 @@ data class DeliverCreateTask( data object DeliverCreateTaskDef : TaskDefinition { override val type: Class get() = DeliverCreateTask::class.java - } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/job/DeliverDeleteTask.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/job/DeliverDeleteTask.kt index 29fe25d3..6ce63ad2 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/job/DeliverDeleteTask.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/job/DeliverDeleteTask.kt @@ -31,5 +31,4 @@ data class DeliverDeleteTask( data object DeliverDeleteTaskDef : TaskDefinition { override val type: Class get() = DeliverDeleteTask::class.java - } diff --git a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/job/DeliverUndoTask.kt b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/job/DeliverUndoTask.kt index 69d47260..3ae7f129 100644 --- a/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/job/DeliverUndoTask.kt +++ b/hideout-core/src/main/kotlin/dev/usbharu/hideout/core/external/job/DeliverUndoTask.kt @@ -31,5 +31,4 @@ data class DeliverUndoTask( data object DeliverUndoTaskDef : TaskDefinition { override val type: Class get() = DeliverUndoTask::class.java - } diff --git a/libs.versions.toml b/libs.versions.toml index 85f71822..ee6f9c7c 100644 --- a/libs.versions.toml +++ b/libs.versions.toml @@ -84,7 +84,7 @@ jackson = ["jackson-databind", "jackson-module-kotlin"] [plugins] kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -spring-boot = { id = "org.springframework.boot", version = "3.2.3" } +spring-boot = { id = "org.springframework.boot", version = "3.2.5" } detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } kotlin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" } kover = { id = "org.jetbrains.kotlinx.kover", version = "0.7.6" } diff --git a/owl/owl-producer/owl-producer-api/src/main/kotlin/dev/usbharu/owl/producer/api/OwlProducer.kt b/owl/owl-producer/owl-producer-api/src/main/kotlin/dev/usbharu/owl/producer/api/OwlProducer.kt index 21495894..7ece4505 100644 --- a/owl/owl-producer/owl-producer-api/src/main/kotlin/dev/usbharu/owl/producer/api/OwlProducer.kt +++ b/owl/owl-producer/owl-producer-api/src/main/kotlin/dev/usbharu/owl/producer/api/OwlProducer.kt @@ -48,4 +48,6 @@ interface OwlProducer { * @return 公開されたタスク */ suspend fun publishTask(task: T): PublishedTask + + suspend fun stop() } diff --git a/owl/owl-producer/owl-producer-default/src/main/kotlin/dev/usbharu/owl/producer/defaultimpl/DefaultOwlProducer.kt b/owl/owl-producer/owl-producer-default/src/main/kotlin/dev/usbharu/owl/producer/defaultimpl/DefaultOwlProducer.kt index 33a14e34..e4a1dfd4 100644 --- a/owl/owl-producer/owl-producer-default/src/main/kotlin/dev/usbharu/owl/producer/defaultimpl/DefaultOwlProducer.kt +++ b/owl/owl-producer/owl-producer-default/src/main/kotlin/dev/usbharu/owl/producer/defaultimpl/DefaultOwlProducer.kt @@ -87,4 +87,8 @@ class DefaultOwlProducer(private val defaultOwlProducerConfig: DefaultOwlProduce now ) } + + override suspend fun stop() { + defaultOwlProducerConfig.channel.shutdownNow() + } } \ No newline at end of file diff --git a/owl/owl-producer/owl-producer-default/src/main/kotlin/dev/usbharu/owl/producer/defaultimpl/DefaultOwlProducerConfig.kt b/owl/owl-producer/owl-producer-default/src/main/kotlin/dev/usbharu/owl/producer/defaultimpl/DefaultOwlProducerConfig.kt index ced2695f..1f955677 100644 --- a/owl/owl-producer/owl-producer-default/src/main/kotlin/dev/usbharu/owl/producer/defaultimpl/DefaultOwlProducerConfig.kt +++ b/owl/owl-producer/owl-producer-default/src/main/kotlin/dev/usbharu/owl/producer/defaultimpl/DefaultOwlProducerConfig.kt @@ -19,6 +19,7 @@ package dev.usbharu.owl.producer.defaultimpl import dev.usbharu.owl.common.property.PropertySerializerFactory import dev.usbharu.owl.producer.api.OwlProducerConfig import io.grpc.Channel +import io.grpc.ManagedChannel /** * デフォルトの[dev.usbharu.owl.producer.api.OwlProducer]の構成 @@ -28,7 +29,7 @@ class DefaultOwlProducerConfig : OwlProducerConfig { /** * gRPCで使用する[Channel] */ - lateinit var channel: Channel + lateinit var channel: ManagedChannel /** * プロデューサー名 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 2a4e1791..477363a3 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 @@ -55,4 +55,8 @@ class EmbeddedGrpcOwlProducer( override suspend fun publishTask(task: T): PublishedTask { return config.owlProducer.publishTask(task) } + + override suspend fun stop() { + config.owlProducer.stop() + } } \ No newline at end of file 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 0f9c5647..032f3255 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 @@ -27,6 +27,7 @@ import dev.usbharu.owl.common.task.Task import dev.usbharu.owl.common.task.TaskDefinition import dev.usbharu.owl.producer.api.OwlProducer import org.koin.core.Koin +import org.koin.core.context.GlobalContext import org.koin.core.context.GlobalContext.startKoin import org.koin.dsl.module import org.koin.ksp.generated.defaultModule @@ -42,9 +43,12 @@ class EmbeddedOwlProducer( private lateinit var application: Koin + private lateinit var brokerApplication: OwlBrokerApplication + private val taskMap: MutableMap, TaskDefinition<*>> = mutableMapOf() override suspend fun start() { + GlobalContext.stopKoin() application = startKoin { printLogger() @@ -71,7 +75,8 @@ class EmbeddedOwlProducer( ) ) - application.get().start(embeddedOwlProducerConfig.port.toInt()) + brokerApplication = application.get() + brokerApplication.start(embeddedOwlProducerConfig.port.toInt()) } override suspend fun registerTask(taskDefinition: TaskDefinition) { @@ -108,4 +113,8 @@ class EmbeddedOwlProducer( Instant.now() ) } + + override suspend fun stop() { + brokerApplication.stop() + } } \ No newline at end of file