Skip to content

Commit 5e0df81

Browse files
committed
refactor
1 parent 62bb0d2 commit 5e0df81

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

tests-utils/src/main/scala/tech/beshu/ror/utils/misc/EsStartupChecker.scala

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ import tech.beshu.ror.utils.httpclient.HttpResponseHelper.deserializeJsonBody
2525
import tech.beshu.ror.utils.httpclient.RestClient
2626
import tech.beshu.ror.utils.misc.EsStartupChecker.{ClusterNotReady, Mode}
2727

28-
import scala.concurrent.Await
2928
import scala.concurrent.duration.*
3029
import scala.language.postfixOps
31-
import scala.util.{Failure, Success, Try}
3230

3331
class EsStartupChecker private(name: String,
3432
client: RestClient,
@@ -38,17 +36,10 @@ class EsStartupChecker private(name: String,
3836
private implicit val scheduler: Scheduler = Scheduler.global
3937

4038
def waitForStart(): Boolean = {
41-
Try {
42-
Await.result(
43-
retryBackoff(clusterIsReady(client), maxRetries = 30, interval = 2 seconds).executeAsync.runToFuture,
44-
2 minutes
45-
)
46-
} match
47-
case Success(()) =>
48-
true
49-
case Failure(ex) =>
50-
logger.error(s"[$name] ES cluster startup check failed", ex)
51-
false
39+
retryBackoff(clusterIsReady(client), maxRetries = 30, interval = 2 seconds)
40+
.map((_: Unit) => true)
41+
.onErrorRecover(_ => false)
42+
.runSyncUnsafe(2 minutes)
5243
}
5344

5445
private def retryBackoff[A](source: Task[A],

0 commit comments

Comments
 (0)