diff --git a/owl/owl-broker/build.gradle.kts b/owl/owl-broker/build.gradle.kts index b5aae3ce..427148a9 100644 --- a/owl/owl-broker/build.gradle.kts +++ b/owl/owl-broker/build.gradle.kts @@ -2,11 +2,6 @@ plugins { // alias(libs.plugins.kotlin.jvm) kotlin("jvm") id("com.google.protobuf") version "0.9.4" - id("com.google.devtools.ksp") version "1.9.25-1.0.20" -} - -apply { - plugin("com.google.devtools.ksp") } @@ -26,10 +21,7 @@ dependencies { implementation(project(":owl-common")) implementation("org.apache.logging.log4j:log4j-slf4j2-impl:2.23.1") implementation(platform("io.insert-koin:koin-bom:3.5.6")) - implementation(platform("io.insert-koin:koin-annotations-bom:1.3.1")) implementation("io.insert-koin:koin-core") - compileOnly("io.insert-koin:koin-annotations") - ksp("io.insert-koin:koin-ksp-compiler:1.3.1") } tasks.test { diff --git a/owl/owl-broker/owl-broker-mongodb/build.gradle.kts b/owl/owl-broker/owl-broker-mongodb/build.gradle.kts index 55919411..d1e1196d 100644 --- a/owl/owl-broker/owl-broker-mongodb/build.gradle.kts +++ b/owl/owl-broker/owl-broker-mongodb/build.gradle.kts @@ -1,11 +1,6 @@ plugins { application kotlin("jvm") - id("com.google.devtools.ksp") version "1.9.25-1.0.20" -} - -apply { - plugin("com.google.devtools.ksp") } group = "dev.usbharu" @@ -22,8 +17,6 @@ dependencies { implementation(platform("io.insert-koin:koin-bom:3.5.6")) implementation(platform("io.insert-koin:koin-annotations-bom:1.3.1")) implementation("io.insert-koin:koin-core") - compileOnly("io.insert-koin:koin-annotations") - ksp("io.insert-koin:koin-ksp-compiler:1.3.1") } tasks.test { diff --git a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongoModule.kt b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongoModule.kt deleted file mode 100644 index 9b770dde..00000000 --- a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongoModule.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2024 usbharu - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dev.usbharu.owl.broker.mongodb - -import org.koin.core.annotation.ComponentScan -import org.koin.core.annotation.Module - -@Module -@ComponentScan("dev.usbharu.owl.broker.mongodb") -class MongoModule - diff --git a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongoModuleContext.kt b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongoModuleContext.kt index e3ab269b..5c1af4fb 100644 --- a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongoModuleContext.kt +++ b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongoModuleContext.kt @@ -20,15 +20,20 @@ import com.mongodb.ConnectionString import com.mongodb.MongoClientSettings import com.mongodb.kotlin.client.coroutine.MongoClient import dev.usbharu.owl.broker.ModuleContext +import dev.usbharu.owl.broker.domain.model.consumer.ConsumerRepository +import dev.usbharu.owl.broker.domain.model.producer.ProducerRepository +import dev.usbharu.owl.broker.domain.model.queuedtask.QueuedTaskRepository +import dev.usbharu.owl.broker.domain.model.task.TaskRepository +import dev.usbharu.owl.broker.domain.model.taskdefinition.TaskDefinitionRepository +import dev.usbharu.owl.broker.domain.model.taskresult.TaskResultRepository import org.bson.UuidRepresentation import org.koin.core.module.Module import org.koin.dsl.module -import org.koin.ksp.generated.module class MongoModuleContext : ModuleContext { override fun module(): Module { - val module = MongoModule().module - module.includes(module { + + return module { single { val clientSettings = MongoClientSettings.builder() @@ -46,7 +51,12 @@ class MongoModuleContext : ModuleContext { MongoClient.create(clientSettings) .getDatabase(System.getProperty("owl.broker.mongo.database", "mongo-test")) } - }) - return module + single { MongodbConsumerRepository(get()) } + single { MongodbProducerRepository(get()) } + single { MongodbQueuedTaskRepository(get(), get()) } + single { MongodbTaskDefinitionRepository(get()) } + single { MongodbTaskRepository(get(), get()) } + single { MongodbTaskResultRepository(get(), get()) } + } } } \ No newline at end of file diff --git a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbConsumerRepository.kt b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbConsumerRepository.kt index 43207580..4310b956 100644 --- a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbConsumerRepository.kt +++ b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbConsumerRepository.kt @@ -27,10 +27,8 @@ import kotlinx.coroutines.withContext import org.bson.BsonType import org.bson.codecs.pojo.annotations.BsonId import org.bson.codecs.pojo.annotations.BsonRepresentation -import org.koin.core.annotation.Singleton import java.util.* -@Singleton class MongodbConsumerRepository(database: MongoDatabase) : ConsumerRepository { private val collection = database.getCollection("consumers") diff --git a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbProducerRepository.kt b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbProducerRepository.kt index 3593e5f8..76d9a755 100644 --- a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbProducerRepository.kt +++ b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbProducerRepository.kt @@ -23,11 +23,9 @@ import dev.usbharu.owl.broker.domain.model.producer.Producer import dev.usbharu.owl.broker.domain.model.producer.ProducerRepository import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext -import org.koin.core.annotation.Singleton import java.time.Instant import java.util.* -@Singleton class MongodbProducerRepository(database: MongoDatabase) : ProducerRepository { private val collection = database.getCollection("producers") diff --git a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbQueuedTaskRepository.kt b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbQueuedTaskRepository.kt index a20f1d02..833baca9 100644 --- a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbQueuedTaskRepository.kt +++ b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbQueuedTaskRepository.kt @@ -36,11 +36,9 @@ import kotlinx.coroutines.withContext import org.bson.BsonType import org.bson.codecs.pojo.annotations.BsonId import org.bson.codecs.pojo.annotations.BsonRepresentation -import org.koin.core.annotation.Singleton import java.time.Instant import java.util.* -@Singleton class MongodbQueuedTaskRepository( private val propertySerializerFactory: PropertySerializerFactory, database: MongoDatabase diff --git a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbTaskDefinitionRepository.kt b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbTaskDefinitionRepository.kt index ced2b19a..f3b384a1 100644 --- a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbTaskDefinitionRepository.kt +++ b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbTaskDefinitionRepository.kt @@ -27,9 +27,7 @@ import kotlinx.coroutines.withContext import org.bson.BsonType import org.bson.codecs.pojo.annotations.BsonId import org.bson.codecs.pojo.annotations.BsonRepresentation -import org.koin.core.annotation.Singleton -@Singleton class MongodbTaskDefinitionRepository(database: MongoDatabase) : TaskDefinitionRepository { private val collection = database.getCollection("task_definition") diff --git a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbTaskRepository.kt b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbTaskRepository.kt index 2d7215ae..2745b0cd 100644 --- a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbTaskRepository.kt +++ b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbTaskRepository.kt @@ -33,11 +33,10 @@ import kotlinx.coroutines.withContext import org.bson.BsonType import org.bson.codecs.pojo.annotations.BsonId import org.bson.codecs.pojo.annotations.BsonRepresentation -import org.koin.core.annotation.Singleton import java.time.Instant import java.util.* -@Singleton + class MongodbTaskRepository(database: MongoDatabase, private val propertySerializerFactory: PropertySerializerFactory) : TaskRepository { diff --git a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbTaskResultRepository.kt b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbTaskResultRepository.kt index ed000fe2..2336a45c 100644 --- a/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbTaskResultRepository.kt +++ b/owl/owl-broker/owl-broker-mongodb/src/main/kotlin/dev/usbharu/owl/broker/mongodb/MongodbTaskResultRepository.kt @@ -31,10 +31,8 @@ import kotlinx.coroutines.withContext import org.bson.BsonType import org.bson.codecs.pojo.annotations.BsonId import org.bson.codecs.pojo.annotations.BsonRepresentation -import org.koin.core.annotation.Singleton import java.util.* -@Singleton class MongodbTaskResultRepository( database: MongoDatabase, private val propertySerializerFactory: PropertySerializerFactory 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 265a9487..69274668 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 @@ -16,13 +16,17 @@ package dev.usbharu.owl.broker +import dev.usbharu.owl.broker.interfaces.grpc.* +import dev.usbharu.owl.broker.service.* +import dev.usbharu.owl.broker.service.ProducerService +import dev.usbharu.owl.broker.service.TaskPublishService +import dev.usbharu.owl.common.property.PropertySerializerFactory import dev.usbharu.owl.common.retry.DefaultRetryPolicyFactory import dev.usbharu.owl.common.retry.ExponentialRetryPolicy import dev.usbharu.owl.common.retry.RetryPolicyFactory import kotlinx.coroutines.runBlocking import org.koin.core.context.startKoin import org.koin.dsl.module -import org.koin.ksp.generated.defaultModule import org.slf4j.LoggerFactory import java.util.* @@ -43,8 +47,56 @@ 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(defaultModule, module, moduleContext.module()) + modules(module, moduleContext.module()) } val application = koin.koin.get() diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/OwlBrokerApplication.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/OwlBrokerApplication.kt index 6ed8527e..a67661ca 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/OwlBrokerApplication.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/OwlBrokerApplication.kt @@ -24,9 +24,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.Job import kotlinx.coroutines.launch -import org.koin.core.annotation.Singleton -@Singleton class OwlBrokerApplication( private val assignmentTaskService: AssignmentTaskService, private val definitionTaskService: DefinitionTaskService, diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/AssignmentTaskService.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/AssignmentTaskService.kt index 9c71b8e0..f92faf17 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/AssignmentTaskService.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/AssignmentTaskService.kt @@ -29,12 +29,11 @@ import io.grpc.StatusException import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flatMapMerge import kotlinx.coroutines.flow.map -import org.koin.core.annotation.Singleton import org.slf4j.LoggerFactory import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext -@Singleton + class AssignmentTaskService( coroutineContext: CoroutineContext = EmptyCoroutineContext, private val queuedTaskAssigner: QueuedTaskAssigner, diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/DefinitionTaskService.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/DefinitionTaskService.kt index 3ce2b5b0..d00d584a 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/DefinitionTaskService.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/DefinitionTaskService.kt @@ -22,11 +22,9 @@ import dev.usbharu.owl.DefinitionTask.TaskDefined import dev.usbharu.owl.DefinitionTaskServiceGrpcKt.DefinitionTaskServiceCoroutineImplBase import dev.usbharu.owl.broker.domain.model.taskdefinition.TaskDefinition import dev.usbharu.owl.broker.service.RegisterTaskService -import org.koin.core.annotation.Singleton import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext -@Singleton class DefinitionTaskService(coroutineContext: CoroutineContext = EmptyCoroutineContext,private val registerTaskService: RegisterTaskService) : DefinitionTaskServiceCoroutineImplBase(coroutineContext) { override suspend fun register(request: DefinitionTask.TaskDefinition): TaskDefined { diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/ProducerService.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/ProducerService.kt index c01bec69..47bbb62e 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/ProducerService.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/ProducerService.kt @@ -21,11 +21,10 @@ import dev.usbharu.owl.ProducerServiceGrpcKt.ProducerServiceCoroutineImplBase import dev.usbharu.owl.broker.external.toUUID import dev.usbharu.owl.broker.service.ProducerService import dev.usbharu.owl.broker.service.RegisterProducerRequest -import org.koin.core.annotation.Singleton import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext -@Singleton + class ProducerService( coroutineContext: CoroutineContext = EmptyCoroutineContext, private val producerService: ProducerService diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/SubscribeTaskService.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/SubscribeTaskService.kt index f521ca0c..62539d55 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/SubscribeTaskService.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/SubscribeTaskService.kt @@ -21,11 +21,9 @@ import dev.usbharu.owl.SubscribeTaskServiceGrpcKt.SubscribeTaskServiceCoroutineI import dev.usbharu.owl.broker.external.toUUID import dev.usbharu.owl.broker.service.ConsumerService import dev.usbharu.owl.broker.service.RegisterConsumerRequest -import org.koin.core.annotation.Singleton import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext -@Singleton class SubscribeTaskService( coroutineContext: CoroutineContext = EmptyCoroutineContext, private val consumerService: ConsumerService diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/TaskPublishService.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/TaskPublishService.kt index 13d2f8ed..10b2154f 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/TaskPublishService.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/TaskPublishService.kt @@ -27,12 +27,10 @@ import dev.usbharu.owl.common.property.PropertySerializeUtils import dev.usbharu.owl.common.property.PropertySerializerFactory import io.grpc.Status import io.grpc.StatusException -import org.koin.core.annotation.Singleton import org.slf4j.LoggerFactory import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext -@Singleton class TaskPublishService( coroutineContext: CoroutineContext = EmptyCoroutineContext, private val taskPublishService: TaskPublishService, diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/TaskResultService.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/TaskResultService.kt index 1a82a7ef..90d10f6b 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/TaskResultService.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/TaskResultService.kt @@ -30,13 +30,11 @@ import kotlinx.coroutines.CancellationException import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.onEach -import org.koin.core.annotation.Singleton import org.slf4j.LoggerFactory import java.util.* import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext -@Singleton class TaskResultService( coroutineContext: CoroutineContext = EmptyCoroutineContext, private val taskManagementService: TaskManagementService, diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/TaskResultSubscribeService.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/TaskResultSubscribeService.kt index 287dc449..e0635d9a 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/TaskResultSubscribeService.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/interfaces/grpc/TaskResultSubscribeService.kt @@ -23,11 +23,9 @@ import dev.usbharu.owl.common.property.PropertySerializeUtils import dev.usbharu.owl.common.property.PropertySerializerFactory import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map -import org.koin.core.annotation.Singleton import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext -@Singleton class TaskResultSubscribeService( private val taskManagementService: TaskManagementService, private val propertySerializerFactory: PropertySerializerFactory, diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/AssignQueuedTaskDecider.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/AssignQueuedTaskDecider.kt index e8ff8b41..44dfa36a 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/AssignQueuedTaskDecider.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/AssignQueuedTaskDecider.kt @@ -23,12 +23,10 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.emitAll import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.take -import org.koin.core.annotation.Singleton import java.util.* interface AssignQueuedTaskDecider { fun findAssignableQueue(consumerId: UUID, numberOfConcurrent: Int): Flow } -@Singleton class AssignQueuedTaskDeciderImpl( private val consumerRepository: ConsumerRepository, private val queueStore: QueueStore diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/ConsumerService.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/ConsumerService.kt index 81156832..84b21095 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/ConsumerService.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/ConsumerService.kt @@ -18,7 +18,6 @@ package dev.usbharu.owl.broker.service import dev.usbharu.owl.broker.domain.model.consumer.Consumer import dev.usbharu.owl.broker.domain.model.consumer.ConsumerRepository -import org.koin.core.annotation.Singleton import org.slf4j.LoggerFactory import java.util.* @@ -26,7 +25,6 @@ interface ConsumerService { suspend fun registerConsumer(registerConsumerRequest: RegisterConsumerRequest): UUID } -@Singleton class ConsumerServiceImpl(private val consumerRepository: ConsumerRepository) : ConsumerService { override suspend fun registerConsumer(registerConsumerRequest: RegisterConsumerRequest): UUID { val id = UUID.randomUUID() diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/DefaultPropertySerializerFactory.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/DefaultPropertySerializerFactory.kt index b1caaf51..0eed7b40 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/DefaultPropertySerializerFactory.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/DefaultPropertySerializerFactory.kt @@ -17,9 +17,7 @@ package dev.usbharu.owl.broker.service import dev.usbharu.owl.common.property.* -import org.koin.core.annotation.Singleton -@Singleton(binds = [PropertySerializerFactory::class]) class DefaultPropertySerializerFactory : CustomPropertySerializerFactory( setOf( diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/ProducerService.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/ProducerService.kt index 1c803a02..d781ba45 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/ProducerService.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/ProducerService.kt @@ -18,16 +18,15 @@ package dev.usbharu.owl.broker.service import dev.usbharu.owl.broker.domain.model.producer.Producer import dev.usbharu.owl.broker.domain.model.producer.ProducerRepository -import org.koin.core.annotation.Singleton import org.slf4j.LoggerFactory import java.time.Instant import java.util.* interface ProducerService { - suspend fun registerProducer(producer: RegisterProducerRequest):UUID + suspend fun registerProducer(producer: RegisterProducerRequest): UUID } -@Singleton + class ProducerServiceImpl(private val producerRepository: ProducerRepository) : ProducerService { override suspend fun registerProducer(producer: RegisterProducerRequest): UUID { @@ -43,11 +42,11 @@ class ProducerServiceImpl(private val producerRepository: ProducerRepository) : producerRepository.save(saveProducer) - logger.info("Register a new Producer. name: {} hostname: {}",saveProducer.name,saveProducer.hostname) + logger.info("Register a new Producer. name: {} hostname: {}", saveProducer.name, saveProducer.hostname) return id } - companion object{ + companion object { private val logger = LoggerFactory.getLogger(ProducerServiceImpl::class.java) } } diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/QueueScanner.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/QueueScanner.kt index 5102571a..6368c93e 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/QueueScanner.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/QueueScanner.kt @@ -23,14 +23,13 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.emitAll import kotlinx.coroutines.flow.flow import kotlinx.coroutines.isActive -import org.koin.core.annotation.Singleton import java.time.Instant interface QueueScanner { fun startScan(): Flow } -@Singleton + class QueueScannerImpl(private val queueStore: QueueStore) : QueueScanner { override fun startScan(): Flow { return flow { diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/QueueStore.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/QueueStore.kt index 2630915a..990e2b76 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/QueueStore.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/QueueStore.kt @@ -19,7 +19,6 @@ package dev.usbharu.owl.broker.service import dev.usbharu.owl.broker.domain.model.queuedtask.QueuedTask import dev.usbharu.owl.broker.domain.model.queuedtask.QueuedTaskRepository import kotlinx.coroutines.flow.Flow -import org.koin.core.annotation.Singleton import java.time.Instant interface QueueStore { @@ -33,7 +32,7 @@ interface QueueStore { fun findByQueuedAtBeforeAndIsActiveIsTrue(instant: Instant): Flow } -@Singleton + class QueueStoreImpl(private val queuedTaskRepository: QueuedTaskRepository) : QueueStore { override suspend fun enqueue(queuedTask: QueuedTask) { queuedTaskRepository.save(queuedTask) diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/QueuedTaskAssigner.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/QueuedTaskAssigner.kt index 4f0678fe..33c95413 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/QueuedTaskAssigner.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/QueuedTaskAssigner.kt @@ -19,7 +19,6 @@ package dev.usbharu.owl.broker.service import dev.usbharu.owl.broker.domain.exception.service.QueueCannotDequeueException import dev.usbharu.owl.broker.domain.model.queuedtask.QueuedTask import kotlinx.coroutines.flow.* -import org.koin.core.annotation.Singleton import org.slf4j.LoggerFactory import java.time.Instant import java.util.* @@ -28,7 +27,7 @@ interface QueuedTaskAssigner { fun ready(consumerId: UUID, numberOfConcurrent: Int): Flow } -@Singleton + class QueuedTaskAssignerImpl( private val taskManagementService: TaskManagementService, private val queueStore: QueueStore diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/RegisterTaskService.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/RegisterTaskService.kt index 32436a14..58945d42 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/RegisterTaskService.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/RegisterTaskService.kt @@ -19,7 +19,6 @@ package dev.usbharu.owl.broker.service import dev.usbharu.owl.broker.domain.exception.service.IncompatibleTaskException import dev.usbharu.owl.broker.domain.model.taskdefinition.TaskDefinition import dev.usbharu.owl.broker.domain.model.taskdefinition.TaskDefinitionRepository -import org.koin.core.annotation.Singleton import org.slf4j.LoggerFactory interface RegisterTaskService { @@ -28,7 +27,7 @@ interface RegisterTaskService { suspend fun unregisterTask(name:String) } -@Singleton + class RegisterTaskServiceImpl(private val taskDefinitionRepository: TaskDefinitionRepository) : RegisterTaskService { override suspend fun registerTask(taskDefinition: TaskDefinition) { val definedTask = taskDefinitionRepository.findByName(taskDefinition.name) diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/TaskManagementService.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/TaskManagementService.kt index 3d801972..29133704 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/TaskManagementService.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/TaskManagementService.kt @@ -27,7 +27,6 @@ import dev.usbharu.owl.broker.domain.model.taskresult.TaskResultRepository import dev.usbharu.owl.common.retry.RetryPolicyFactory import kotlinx.coroutines.* import kotlinx.coroutines.flow.* -import org.koin.core.annotation.Singleton import org.slf4j.LoggerFactory import java.time.Instant import java.util.* @@ -43,7 +42,6 @@ interface TaskManagementService { fun subscribeResult(producerId: UUID): Flow } -@Singleton class TaskManagementServiceImpl( private val taskScanner: TaskScanner, private val queueStore: QueueStore, diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/TaskPublishService.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/TaskPublishService.kt index b6f2efe7..a6604d10 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/TaskPublishService.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/TaskPublishService.kt @@ -22,7 +22,6 @@ import dev.usbharu.owl.broker.domain.model.task.TaskRepository import dev.usbharu.owl.broker.domain.model.taskdefinition.TaskDefinitionRepository import dev.usbharu.owl.common.property.PropertyValue import dev.usbharu.owl.common.retry.RetryPolicyFactory -import org.koin.core.annotation.Singleton import org.slf4j.LoggerFactory import java.time.Instant import java.util.* @@ -43,7 +42,6 @@ data class PublishedTask( val id: UUID ) -@Singleton class TaskPublishServiceImpl( private val taskRepository: TaskRepository, private val taskDefinitionRepository: TaskDefinitionRepository, diff --git a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/TaskScanner.kt b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/TaskScanner.kt index 3204f409..5d469533 100644 --- a/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/TaskScanner.kt +++ b/owl/owl-broker/src/main/kotlin/dev/usbharu/owl/broker/service/TaskScanner.kt @@ -24,7 +24,6 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.emitAll import kotlinx.coroutines.flow.flow import kotlinx.coroutines.isActive -import org.koin.core.annotation.Singleton import org.slf4j.LoggerFactory import java.time.Instant @@ -33,7 +32,6 @@ interface TaskScanner { fun startScan(): Flow } -@Singleton class TaskScannerImpl(private val taskRepository: TaskRepository) : TaskScanner { 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 477363a3..c30cb199 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 @@ -25,7 +25,6 @@ import dev.usbharu.owl.producer.api.OwlProducer import org.koin.core.Koin import org.koin.core.context.GlobalContext.startKoin import org.koin.dsl.module -import org.koin.ksp.generated.defaultModule class EmbeddedGrpcOwlProducer( private val config: EmbeddedGrpcOwlProducerConfig, @@ -42,7 +41,7 @@ class EmbeddedGrpcOwlProducer( config.retryPolicyFactory } } - modules(module, defaultModule, config.moduleContext.module()) + modules(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 032f3255..c3323c8f 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 @@ -30,7 +30,6 @@ 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 import java.time.Instant import java.util.* import dev.usbharu.owl.broker.domain.model.taskdefinition.TaskDefinition as BrokerTaskDefinition @@ -60,7 +59,7 @@ class EmbeddedOwlProducer( embeddedOwlProducerConfig.propertySerializerFactory } } - modules(defaultModule, module, embeddedOwlProducerConfig.moduleContext.module()) + modules(module, embeddedOwlProducerConfig.moduleContext.module()) }.koin application.getOrNull()