Skip to content

Commit

Permalink
#1272 Don't use firstCompletedOf to find the right Cortex client
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jul 9, 2020
1 parent 6867871 commit 3d0dfcd
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ class ActionSrv @Inject() (
.find(_.name == cortexId)
.fold[Future[CortexClient]](Future.failed(NotFoundError(s"Cortex $cortexId not found")))(Future.successful)
case None if cortexClients.nonEmpty =>
Future.firstCompletedOf {
cortexClients
.map(client => client.getResponder(workerId).map(_ => client))
}
Future
.traverse(cortexClients) { client =>
client.getResponder(workerId).map(_ => Some(client)).recover { case _ => None }
}
.flatMap(
_.flatten.headOption.fold[Future[CortexClient]](Future.failed(NotFoundError(s"Responder $workerId not found")))(Future.successful)
)

case None => Future.failed(NotFoundError(s"Responder $workerId not found"))
}
Expand Down

0 comments on commit 3d0dfcd

Please sign in to comment.