Skip to content

Commit 71da202

Browse files
authored
Merge pull request #24 from Nexters/main
release: 0.0.3
2 parents 6b0ae8f + 3d37760 commit 71da202

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/main/kotlin/me/misik/api/app/GetReviewFacade.kt

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.misik.api.app
22

3+
import kotlinx.coroutines.delay
34
import kotlinx.coroutines.runBlocking
45
import kotlinx.coroutines.withTimeout
56
import me.misik.api.core.GracefulShutdownDispatcher
@@ -16,8 +17,17 @@ class GetReviewFacade(
1617
fun getReview(id: Long): Review {
1718
return runBlocking(GracefulShutdownDispatcher.dispatcher) {
1819
withTimeout(60.seconds) {
19-
reviewService.getReview(id)
20-
}.get()
20+
var result: Review? = null
21+
while (result == null) {
22+
delay(500)
23+
reviewService.getById(id)
24+
.takeIf { it.isCompleted }
25+
.let {
26+
result = it
27+
}
28+
}
29+
return@withTimeout result!!
30+
}
2131
}
2232
}
2333
}

src/main/kotlin/me/misik/api/domain/ReviewService.kt

-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,4 @@ class ReviewService(
4646

4747
fun getById(id: Long): Review = reviewRepository.findByIdOrNull(id)
4848
?: throw IllegalArgumentException("Cannot find review by id \"$id\"")
49-
50-
fun getReview(id: Long) = reviewRepository.findById(id)
51-
?: throw IllegalArgumentException("Cannot find review by id \"$id\"")
5249
}

0 commit comments

Comments
 (0)