Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoworko committed Mar 13, 2024
1 parent 62bb0d2 commit 5e0df81
Showing 1 changed file with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ import tech.beshu.ror.utils.httpclient.HttpResponseHelper.deserializeJsonBody
import tech.beshu.ror.utils.httpclient.RestClient
import tech.beshu.ror.utils.misc.EsStartupChecker.{ClusterNotReady, Mode}

import scala.concurrent.Await
import scala.concurrent.duration.*
import scala.language.postfixOps
import scala.util.{Failure, Success, Try}

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

def waitForStart(): Boolean = {
Try {
Await.result(
retryBackoff(clusterIsReady(client), maxRetries = 30, interval = 2 seconds).executeAsync.runToFuture,
2 minutes
)
} match
case Success(()) =>
true
case Failure(ex) =>
logger.error(s"[$name] ES cluster startup check failed", ex)
false
retryBackoff(clusterIsReady(client), maxRetries = 30, interval = 2 seconds)
.map((_: Unit) => true)
.onErrorRecover(_ => false)
.runSyncUnsafe(2 minutes)
}

private def retryBackoff[A](source: Task[A],
Expand Down

0 comments on commit 5e0df81

Please sign in to comment.