mirror of https://github.com/usbharu/Hideout.git
test: 結合テストが壊れていたので修正
This commit is contained in:
parent
6a4921cfac
commit
5f534d83e9
|
@ -18,6 +18,8 @@ package activitypub.inbox
|
||||||
|
|
||||||
import dev.usbharu.hideout.SpringApplication
|
import dev.usbharu.hideout.SpringApplication
|
||||||
import dev.usbharu.hideout.util.Base64Util
|
import dev.usbharu.hideout.util.Base64Util
|
||||||
|
import dev.usbharu.owl.producer.api.OwlProducer
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.flywaydb.core.Flyway
|
import org.flywaydb.core.Flyway
|
||||||
import org.junit.jupiter.api.AfterAll
|
import org.junit.jupiter.api.AfterAll
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
|
@ -150,9 +152,12 @@ class InboxTest {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@AfterAll
|
@AfterAll
|
||||||
fun dropDatabase(@Autowired flyway: Flyway) {
|
fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) {
|
||||||
flyway.clean()
|
flyway.clean()
|
||||||
flyway.migrate()
|
flyway.migrate()
|
||||||
|
runBlocking {
|
||||||
|
owlProducer.stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
package activitypub.note
|
package activitypub.note
|
||||||
|
|
||||||
import dev.usbharu.hideout.SpringApplication
|
import dev.usbharu.hideout.SpringApplication
|
||||||
|
import dev.usbharu.owl.producer.api.OwlProducer
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.flywaydb.core.Flyway
|
import org.flywaydb.core.Flyway
|
||||||
import org.junit.jupiter.api.AfterAll
|
import org.junit.jupiter.api.AfterAll
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
|
@ -230,9 +232,12 @@ class NoteTest {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@AfterAll
|
@AfterAll
|
||||||
fun dropDatabase(@Autowired flyway: Flyway) {
|
fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) {
|
||||||
flyway.clean()
|
flyway.clean()
|
||||||
flyway.migrate()
|
flyway.migrate()
|
||||||
|
runBlocking {
|
||||||
|
owlProducer.stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ package activitypub.webfinger
|
||||||
|
|
||||||
import dev.usbharu.hideout.SpringApplication
|
import dev.usbharu.hideout.SpringApplication
|
||||||
import dev.usbharu.hideout.application.external.Transaction
|
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.flywaydb.core.Flyway
|
||||||
import org.junit.jupiter.api.AfterAll
|
import org.junit.jupiter.api.AfterAll
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
@ -103,9 +105,12 @@ class WebFingerTest {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@AfterAll
|
@AfterAll
|
||||||
fun dropDatabase(@Autowired flyway: Flyway) {
|
fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) {
|
||||||
flyway.clean()
|
flyway.clean()
|
||||||
flyway.migrate()
|
flyway.migrate()
|
||||||
|
runBlocking {
|
||||||
|
owlProducer.stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ import com.fasterxml.jackson.core.type.TypeReference
|
||||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||||
import dev.usbharu.hideout.SpringApplication
|
import dev.usbharu.hideout.SpringApplication
|
||||||
import dev.usbharu.hideout.domain.mastodon.model.generated.Status
|
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.assertj.core.api.Assertions.assertThat
|
||||||
import org.flywaydb.core.Flyway
|
import org.flywaydb.core.Flyway
|
||||||
import org.junit.jupiter.api.AfterAll
|
import org.junit.jupiter.api.AfterAll
|
||||||
|
@ -152,9 +154,13 @@ class AccountApiPaginationTest {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@AfterAll
|
@AfterAll
|
||||||
fun dropDatabase(@Autowired flyway: Flyway) {
|
fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) {
|
||||||
flyway.clean()
|
flyway.clean()
|
||||||
flyway.migrate()
|
flyway.migrate()
|
||||||
|
runBlocking {
|
||||||
|
owlProducer.stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,6 +19,8 @@ package mastodon.account
|
||||||
import dev.usbharu.hideout.SpringApplication
|
import dev.usbharu.hideout.SpringApplication
|
||||||
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
import dev.usbharu.hideout.core.domain.model.actor.ActorRepository
|
||||||
import dev.usbharu.hideout.core.infrastructure.exposedquery.FollowerQueryServiceImpl
|
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 kotlinx.coroutines.test.runTest
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.flywaydb.core.Flyway
|
import org.flywaydb.core.Flyway
|
||||||
|
@ -462,9 +464,12 @@ class AccountApiTest {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@AfterAll
|
@AfterAll
|
||||||
fun dropDatabase(@Autowired flyway: Flyway) {
|
fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) {
|
||||||
flyway.clean()
|
flyway.clean()
|
||||||
flyway.migrate()
|
flyway.migrate()
|
||||||
|
runBlocking {
|
||||||
|
owlProducer.stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ package mastodon.apps
|
||||||
|
|
||||||
import dev.usbharu.hideout.SpringApplication
|
import dev.usbharu.hideout.SpringApplication
|
||||||
import dev.usbharu.hideout.core.infrastructure.springframework.oauth2.RegisteredClient
|
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.assertj.core.api.Assertions.assertThat
|
||||||
import org.flywaydb.core.Flyway
|
import org.flywaydb.core.Flyway
|
||||||
import org.jetbrains.exposed.sql.selectAll
|
import org.jetbrains.exposed.sql.selectAll
|
||||||
|
@ -107,9 +109,12 @@ class AppTest {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@AfterAll
|
@AfterAll
|
||||||
fun dropDatabase(@Autowired flyway: Flyway) {
|
fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) {
|
||||||
flyway.clean()
|
flyway.clean()
|
||||||
flyway.migrate()
|
flyway.migrate()
|
||||||
|
runBlocking {
|
||||||
|
owlProducer.stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.FilterPostRequest
|
||||||
import dev.usbharu.hideout.domain.mastodon.model.generated.FilterPostRequestKeyword
|
import dev.usbharu.hideout.domain.mastodon.model.generated.FilterPostRequestKeyword
|
||||||
import dev.usbharu.hideout.domain.mastodon.model.generated.V1FilterPostRequest
|
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 kotlinx.coroutines.test.runTest
|
||||||
import org.flywaydb.core.Flyway
|
import org.flywaydb.core.Flyway
|
||||||
import org.junit.jupiter.api.AfterAll
|
import org.junit.jupiter.api.AfterAll
|
||||||
|
@ -702,9 +704,12 @@ class FilterTest {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@AfterAll
|
@AfterAll
|
||||||
fun dropDatabase(@Autowired flyway: Flyway) {
|
fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) {
|
||||||
flyway.clean()
|
flyway.clean()
|
||||||
flyway.migrate()
|
flyway.migrate()
|
||||||
|
runBlocking {
|
||||||
|
owlProducer.stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,6 +20,8 @@ import dev.usbharu.hideout.SpringApplication
|
||||||
import dev.usbharu.hideout.core.service.media.MediaDataStore
|
import dev.usbharu.hideout.core.service.media.MediaDataStore
|
||||||
import dev.usbharu.hideout.core.service.media.MediaSaveRequest
|
import dev.usbharu.hideout.core.service.media.MediaSaveRequest
|
||||||
import dev.usbharu.hideout.core.service.media.SuccessSavedMedia
|
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 kotlinx.coroutines.test.runTest
|
||||||
import org.flywaydb.core.Flyway
|
import org.flywaydb.core.Flyway
|
||||||
import org.junit.jupiter.api.AfterAll
|
import org.junit.jupiter.api.AfterAll
|
||||||
|
@ -131,9 +133,12 @@ class MediaTest {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@AfterAll
|
@AfterAll
|
||||||
fun dropDatabase(@Autowired flyway: Flyway) {
|
fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) {
|
||||||
flyway.clean()
|
flyway.clean()
|
||||||
flyway.migrate()
|
flyway.migrate()
|
||||||
|
runBlocking {
|
||||||
|
owlProducer.stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ import com.fasterxml.jackson.core.type.TypeReference
|
||||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||||
import dev.usbharu.hideout.SpringApplication
|
import dev.usbharu.hideout.SpringApplication
|
||||||
import dev.usbharu.hideout.domain.mastodon.model.generated.Notification
|
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 kotlinx.coroutines.test.runTest
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.flywaydb.core.Flyway
|
import org.flywaydb.core.Flyway
|
||||||
|
@ -172,9 +174,12 @@ class ExposedNotificationsApiPaginationTest {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@AfterAll
|
@AfterAll
|
||||||
fun dropDatabase(@Autowired flyway: Flyway) {
|
fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) {
|
||||||
flyway.clean()
|
flyway.clean()
|
||||||
flyway.migrate()
|
flyway.migrate()
|
||||||
|
runBlocking {
|
||||||
|
owlProducer.stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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.MastodonNotification
|
||||||
import dev.usbharu.hideout.mastodon.domain.model.NotificationType
|
import dev.usbharu.hideout.mastodon.domain.model.NotificationType
|
||||||
import dev.usbharu.hideout.mastodon.infrastructure.mongorepository.MongoMastodonNotificationRepository
|
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 kotlinx.coroutines.test.runTest
|
||||||
import org.assertj.core.api.Assertions
|
import org.assertj.core.api.Assertions
|
||||||
import org.flywaydb.core.Flyway
|
import org.flywaydb.core.Flyway
|
||||||
|
@ -178,7 +180,7 @@ class MongodbNotificationsApiPaginationTest {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
fun setupMongodb(
|
fun setupMongodb(
|
||||||
@Autowired mongoMastodonNotificationRepository: MongoMastodonNotificationRepository
|
@Autowired mongoMastodonNotificationRepository: MongoMastodonNotificationRepository,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
mongoMastodonNotificationRepository.deleteAll()
|
mongoMastodonNotificationRepository.deleteAll()
|
||||||
|
@ -203,11 +205,14 @@ class MongodbNotificationsApiPaginationTest {
|
||||||
@AfterAll
|
@AfterAll
|
||||||
fun dropDatabase(
|
fun dropDatabase(
|
||||||
@Autowired flyway: Flyway,
|
@Autowired flyway: Flyway,
|
||||||
@Autowired mongodbMastodonNotificationRepository: MongoMastodonNotificationRepository
|
@Autowired mongodbMastodonNotificationRepository: MongoMastodonNotificationRepository,
|
||||||
|
@Autowired owlProducer: OwlProducer,
|
||||||
) {
|
) {
|
||||||
flyway.clean()
|
flyway.clean()
|
||||||
flyway.migrate()
|
flyway.migrate()
|
||||||
|
runBlocking {
|
||||||
|
owlProducer.stop()
|
||||||
|
}
|
||||||
mongodbMastodonNotificationRepository.deleteAll()
|
mongodbMastodonNotificationRepository.deleteAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.CustomEmojis
|
||||||
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Reactions
|
import dev.usbharu.hideout.core.infrastructure.exposedrepository.Reactions
|
||||||
import dev.usbharu.hideout.core.infrastructure.exposedrepository.toReaction
|
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.assertj.core.api.Assertions.assertThat
|
||||||
import org.flywaydb.core.Flyway
|
import org.flywaydb.core.Flyway
|
||||||
import org.jetbrains.exposed.sql.and
|
import org.jetbrains.exposed.sql.and
|
||||||
|
@ -236,9 +238,12 @@ class StatusTest {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@AfterAll
|
@AfterAll
|
||||||
fun dropDatabase(@Autowired flyway: Flyway) {
|
fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) {
|
||||||
flyway.clean()
|
flyway.clean()
|
||||||
flyway.migrate()
|
flyway.migrate()
|
||||||
|
runBlocking {
|
||||||
|
owlProducer.stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
package mastodon.timelines
|
package mastodon.timelines
|
||||||
|
|
||||||
import dev.usbharu.hideout.SpringApplication
|
import dev.usbharu.hideout.SpringApplication
|
||||||
|
import dev.usbharu.owl.producer.api.OwlProducer
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.flywaydb.core.Flyway
|
import org.flywaydb.core.Flyway
|
||||||
import org.junit.jupiter.api.AfterAll
|
import org.junit.jupiter.api.AfterAll
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
|
@ -123,9 +125,12 @@ class TimelineApiTest {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@AfterAll
|
@AfterAll
|
||||||
fun dropDatabase(@Autowired flyway: Flyway) {
|
fun dropDatabase(@Autowired flyway: Flyway, @Autowired owlProducer: OwlProducer) {
|
||||||
flyway.clean()
|
flyway.clean()
|
||||||
flyway.migrate()
|
flyway.migrate()
|
||||||
|
runBlocking {
|
||||||
|
owlProducer.stop()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,17 +19,25 @@ package dev.usbharu.hideout.application.external
|
||||||
import dev.usbharu.owl.common.task.TaskDefinition
|
import dev.usbharu.owl.common.task.TaskDefinition
|
||||||
import dev.usbharu.owl.producer.api.OwlProducer
|
import dev.usbharu.owl.producer.api.OwlProducer
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import org.springframework.beans.factory.DisposableBean
|
||||||
import org.springframework.boot.ApplicationArguments
|
import org.springframework.boot.ApplicationArguments
|
||||||
import org.springframework.boot.ApplicationRunner
|
import org.springframework.boot.ApplicationRunner
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
class OwlProducerRunner(private val owlProducer: OwlProducer, private val taskDefinitions: List<TaskDefinition<*>>) :
|
class OwlProducerRunner(private val owlProducer: OwlProducer, private val taskDefinitions: List<TaskDefinition<*>>) :
|
||||||
ApplicationRunner {
|
ApplicationRunner, DisposableBean {
|
||||||
override fun run(args: ApplicationArguments?) {
|
override fun run(args: ApplicationArguments?) {
|
||||||
runBlocking {
|
runBlocking {
|
||||||
owlProducer.start()
|
owlProducer.start()
|
||||||
taskDefinitions.forEach { taskDefinition -> owlProducer.registerTask(taskDefinition) }
|
taskDefinitions.forEach { taskDefinition -> owlProducer.registerTask(taskDefinition) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
override fun destroy() {
|
||||||
|
System.err.println("destroy aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
|
||||||
|
runBlocking {
|
||||||
|
owlProducer.stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -31,5 +31,4 @@ data class DeliverCreateTask(
|
||||||
data object DeliverCreateTaskDef : TaskDefinition<DeliverCreateTask> {
|
data object DeliverCreateTaskDef : TaskDefinition<DeliverCreateTask> {
|
||||||
override val type: Class<DeliverCreateTask>
|
override val type: Class<DeliverCreateTask>
|
||||||
get() = DeliverCreateTask::class.java
|
get() = DeliverCreateTask::class.java
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,5 +31,4 @@ data class DeliverDeleteTask(
|
||||||
data object DeliverDeleteTaskDef : TaskDefinition<DeliverDeleteTask> {
|
data object DeliverDeleteTaskDef : TaskDefinition<DeliverDeleteTask> {
|
||||||
override val type: Class<DeliverDeleteTask>
|
override val type: Class<DeliverDeleteTask>
|
||||||
get() = DeliverDeleteTask::class.java
|
get() = DeliverDeleteTask::class.java
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,5 +31,4 @@ data class DeliverUndoTask(
|
||||||
data object DeliverUndoTaskDef : TaskDefinition<DeliverUndoTask> {
|
data object DeliverUndoTaskDef : TaskDefinition<DeliverUndoTask> {
|
||||||
override val type: Class<DeliverUndoTask>
|
override val type: Class<DeliverUndoTask>
|
||||||
get() = DeliverUndoTask::class.java
|
get() = DeliverUndoTask::class.java
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ jackson = ["jackson-databind", "jackson-module-kotlin"]
|
||||||
[plugins]
|
[plugins]
|
||||||
|
|
||||||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
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" }
|
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
|
||||||
kotlin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" }
|
kotlin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" }
|
||||||
kover = { id = "org.jetbrains.kotlinx.kover", version = "0.7.6" }
|
kover = { id = "org.jetbrains.kotlinx.kover", version = "0.7.6" }
|
||||||
|
|
|
@ -48,4 +48,6 @@ interface OwlProducer {
|
||||||
* @return 公開されたタスク
|
* @return 公開されたタスク
|
||||||
*/
|
*/
|
||||||
suspend fun <T : Task> publishTask(task: T): PublishedTask<T>
|
suspend fun <T : Task> publishTask(task: T): PublishedTask<T>
|
||||||
|
|
||||||
|
suspend fun stop()
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,4 +87,8 @@ class DefaultOwlProducer(private val defaultOwlProducerConfig: DefaultOwlProduce
|
||||||
now
|
now
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun stop() {
|
||||||
|
defaultOwlProducerConfig.channel.shutdownNow()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -19,6 +19,7 @@ package dev.usbharu.owl.producer.defaultimpl
|
||||||
import dev.usbharu.owl.common.property.PropertySerializerFactory
|
import dev.usbharu.owl.common.property.PropertySerializerFactory
|
||||||
import dev.usbharu.owl.producer.api.OwlProducerConfig
|
import dev.usbharu.owl.producer.api.OwlProducerConfig
|
||||||
import io.grpc.Channel
|
import io.grpc.Channel
|
||||||
|
import io.grpc.ManagedChannel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* デフォルトの[dev.usbharu.owl.producer.api.OwlProducer]の構成
|
* デフォルトの[dev.usbharu.owl.producer.api.OwlProducer]の構成
|
||||||
|
@ -28,7 +29,7 @@ class DefaultOwlProducerConfig : OwlProducerConfig {
|
||||||
/**
|
/**
|
||||||
* gRPCで使用する[Channel]
|
* gRPCで使用する[Channel]
|
||||||
*/
|
*/
|
||||||
lateinit var channel: Channel
|
lateinit var channel: ManagedChannel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* プロデューサー名
|
* プロデューサー名
|
||||||
|
|
|
@ -55,4 +55,8 @@ class EmbeddedGrpcOwlProducer(
|
||||||
override suspend fun <T : Task> publishTask(task: T): PublishedTask<T> {
|
override suspend fun <T : Task> publishTask(task: T): PublishedTask<T> {
|
||||||
return config.owlProducer.publishTask(task)
|
return config.owlProducer.publishTask(task)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun stop() {
|
||||||
|
config.owlProducer.stop()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -27,6 +27,7 @@ import dev.usbharu.owl.common.task.Task
|
||||||
import dev.usbharu.owl.common.task.TaskDefinition
|
import dev.usbharu.owl.common.task.TaskDefinition
|
||||||
import dev.usbharu.owl.producer.api.OwlProducer
|
import dev.usbharu.owl.producer.api.OwlProducer
|
||||||
import org.koin.core.Koin
|
import org.koin.core.Koin
|
||||||
|
import org.koin.core.context.GlobalContext
|
||||||
import org.koin.core.context.GlobalContext.startKoin
|
import org.koin.core.context.GlobalContext.startKoin
|
||||||
import org.koin.dsl.module
|
import org.koin.dsl.module
|
||||||
import org.koin.ksp.generated.defaultModule
|
import org.koin.ksp.generated.defaultModule
|
||||||
|
@ -42,9 +43,12 @@ class EmbeddedOwlProducer(
|
||||||
|
|
||||||
private lateinit var application: Koin
|
private lateinit var application: Koin
|
||||||
|
|
||||||
|
private lateinit var brokerApplication: OwlBrokerApplication
|
||||||
|
|
||||||
private val taskMap: MutableMap<Class<*>, TaskDefinition<*>> = mutableMapOf()
|
private val taskMap: MutableMap<Class<*>, TaskDefinition<*>> = mutableMapOf()
|
||||||
|
|
||||||
override suspend fun start() {
|
override suspend fun start() {
|
||||||
|
GlobalContext.stopKoin()
|
||||||
application = startKoin {
|
application = startKoin {
|
||||||
printLogger()
|
printLogger()
|
||||||
|
|
||||||
|
@ -71,7 +75,8 @@ class EmbeddedOwlProducer(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
application.get<OwlBrokerApplication>().start(embeddedOwlProducerConfig.port.toInt())
|
brokerApplication = application.get<OwlBrokerApplication>()
|
||||||
|
brokerApplication.start(embeddedOwlProducerConfig.port.toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun <T : Task> registerTask(taskDefinition: TaskDefinition<T>) {
|
override suspend fun <T : Task> registerTask(taskDefinition: TaskDefinition<T>) {
|
||||||
|
@ -108,4 +113,8 @@ class EmbeddedOwlProducer(
|
||||||
Instant.now()
|
Instant.now()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun stop() {
|
||||||
|
brokerApplication.stop()
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue