Skip to content

Commit 8be43a3

Browse files
committed
refactor: check for health status of nearest node first
- This avoids operations based on healthcheck due status as it will exit early if it finds the heatlh status of the nearest node to be true
1 parent 56629df commit 8be43a3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/org/typesense/api/ApiCall.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ boolean isDueForHealthCheck(Node node) {
6161
// Loops in a round-robin fashion to check for a healthy node and returns it
6262
Node getNode() {
6363
if (configuration.nearestNode != null) {
64-
if (isDueForHealthCheck((configuration.nearestNode)) || configuration.nearestNode.isHealthy) {
64+
if (configuration.nearestNode.isHealthy || isDueForHealthCheck((configuration.nearestNode)) ) {
6565
return configuration.nearestNode;
6666
}
6767
}

0 commit comments

Comments
 (0)