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

release: 0.0.3 #24

Merged
merged 1 commit into from
Feb 8, 2025
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
14 changes: 12 additions & 2 deletions src/main/kotlin/me/misik/api/app/GetReviewFacade.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.misik.api.app

import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import me.misik.api.core.GracefulShutdownDispatcher
Expand All @@ -16,8 +17,17 @@ class GetReviewFacade(
fun getReview(id: Long): Review {
return runBlocking(GracefulShutdownDispatcher.dispatcher) {
withTimeout(60.seconds) {
reviewService.getReview(id)
}.get()
var result: Review? = null
while (result == null) {
delay(500)
reviewService.getById(id)
.takeIf { it.isCompleted }
.let {
result = it
}
}
return@withTimeout result!!
}
}
}
}
3 changes: 0 additions & 3 deletions src/main/kotlin/me/misik/api/domain/ReviewService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,4 @@ class ReviewService(

fun getById(id: Long): Review = reviewRepository.findByIdOrNull(id)
?: throw IllegalArgumentException("Cannot find review by id \"$id\"")

fun getReview(id: Long) = reviewRepository.findById(id)
?: throw IllegalArgumentException("Cannot find review by id \"$id\"")
}
Loading