File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
src/main/kotlin/me/misik/api Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 11package me.misik.api.app
22
3+ import kotlinx.coroutines.delay
34import kotlinx.coroutines.runBlocking
45import kotlinx.coroutines.withTimeout
56import 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}
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments