Skip to content

Commit

Permalink
fix(retry): Fix retry strategy when all hosts are down (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElPicador committed Oct 9, 2017
1 parent 7ef09fa commit 6e9056d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/scala/algolia/HostsStatuses.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ case class HostsStatuses(configuration: AlgoliaClientConfiguration,
def queryHostsThatAreUp(): Seq[String] = hostsThatAreUp(queryHosts)

private def hostsThatAreUp(hosts: Seq[String]): Seq[String] = {
hosts.filter(h => isUpOrCouldBeRetried(getHostStatus(h)))
val filteredHosts = hosts.filter(h => isUpOrCouldBeRetried(getHostStatus(h)))
if (filteredHosts.isEmpty) {
hosts
} else {
filteredHosts
}
}

def isUpOrCouldBeRetried(hostStatus: HostStatus): Boolean =
Expand Down

0 comments on commit 6e9056d

Please sign in to comment.