Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to non-reactive mongodb to fix batch #112

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion batch/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ dependencies {
implementation(project(":core"))

implementation("org.springframework.boot:spring-boot-starter-batch")
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
runtimeOnly("org.postgresql:postgresql")
runtimeOnly("com.h2database:h2")
}
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ subprojects {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")

implementation("com.wafflestudio.truffle.sdk:truffle-spring-boot-starter:1.1.2")
implementation("com.wafflestudio.truffle.sdk:truffle-logback:1.1.2")
Expand Down
3 changes: 2 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ dependencies {
implementation("software.amazon.awssdk:secretsmanager:2.20.66")
implementation("software.amazon.awssdk:sts:2.20.66")

implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive")
implementation("org.springframework.boot:spring-boot-starter-data-redis")

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")

runtimeOnly("com.mysql:mysql-connector-j")
kapt("com.querydsl:querydsl-apt::jakarta")
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
package com.wafflestudio.snuttev.core.domain.mongo

import com.wafflestudio.snuttev.core.domain.lecture.model.LectureRatingDao
import org.springframework.data.mongodb.core.ReactiveMongoTemplate
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.springframework.data.mongodb.core.MongoTemplate
import org.springframework.data.mongodb.core.query.Criteria
import org.springframework.data.mongodb.core.query.Query
import org.springframework.data.mongodb.core.query.Update
import org.springframework.stereotype.Service

@Service
class MongoService(
private val mongoTemplate: ReactiveMongoTemplate,
private val mongoTemplate: MongoTemplate,
) {
fun updateEvInfoToSnuttIds(snuttIds: List<String>, evInfo: LectureRatingDao?) =
mongoTemplate.updateMulti(
Query(Criteria.where("_id").`in`(snuttIds)),
Update().set("evInfo.evId", evInfo?.id)
.set("evInfo.avgRating", evInfo?.avgRating)
.set("evInfo.count", evInfo?.count),
"lectures",
).subscribe()
CoroutineScope(Dispatchers.IO).launch {
runCatching {
mongoTemplate.updateMulti(
Query(Criteria.where("_id").`in`(snuttIds)),
Update().set("evInfo.evId", evInfo?.id)
.set("evInfo.avgRating", evInfo?.avgRating)
.set("evInfo.count", evInfo?.count),
"lectures",
)
}
}
Comment on lines +18 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coroutineScope는 빼도 괜찮을 것 같네요.
어차피 이거 webflux 스택이 아니라서요

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코루틴 의존성 떼고 아예 나중에 virtualThread 붙이는게 훨씬 나을듯해요

}
Loading