feat: システムプロパティからMongoDBへの接続情報を取得するように

This commit is contained in:
usbharu 2024-03-05 14:47:01 +09:00
parent ac6b55e796
commit 8fb5fa416d
2 changed files with 14 additions and 6 deletions

View File

@ -21,20 +21,30 @@ import com.mongodb.MongoClientSettings
import com.mongodb.kotlin.client.coroutine.MongoClient
import dev.usbharu.owl.broker.ModuleContext
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(): org.koin.core.module.Module {
override fun module(): Module {
val module = MongoModule().module
module.includes(org.koin.dsl.module {
module.includes(module {
single {
val clientSettings =
MongoClientSettings.builder()
.applyConnectionString(ConnectionString("mongodb://agent1.build:27017"))
.applyConnectionString(
ConnectionString(
System.getProperty(
"owl.broker.mongo.url",
"mongodb://agent1.build:27017"
)
)
)
.uuidRepresentation(UuidRepresentation.STANDARD).build()
MongoClient.create(clientSettings).getDatabase("mongo-test")
MongoClient.create(clientSettings)
.getDatabase(System.getProperty("owl.broker.mongo.database", "mongo-test"))
}
})
return module

View File

@ -22,8 +22,6 @@ dependencies {
implementation("com.google.protobuf:protobuf-kotlin:3.25.3")
implementation("io.grpc:grpc-netty:1.61.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")
implementation("org.mongodb:mongodb-driver-kotlin-coroutine:4.11.0")
implementation("org.mongodb:bson-kotlinx:4.11.0")
implementation(project(":common"))
implementation("org.apache.logging.log4j:log4j-slf4j2-impl:2.23.0")
implementation(platform("io.insert-koin:koin-bom:3.5.3"))