diff --git a/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulDiscoveryClient.java b/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulDiscoveryClient.java index 1a44895e..2dc23ea0 100644 --- a/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulDiscoveryClient.java +++ b/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulDiscoveryClient.java @@ -110,7 +110,7 @@ public class ConsulDiscoveryClient implements DiscoveryClient { private void addInstancesToList(List instances, String serviceId) { Response> services = client.getHealthServices(serviceId, - false, QueryParams.DEFAULT); + this.properties.isQueryPassing(), QueryParams.DEFAULT); for (HealthService service : services.getValue()) { String host = findHost(service); instances.add(new DefaultServiceInstance(serviceId, host, service diff --git a/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulDiscoveryProperties.java b/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulDiscoveryProperties.java index 7318ecab..987fcb1d 100644 --- a/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulDiscoveryProperties.java +++ b/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulDiscoveryProperties.java @@ -114,6 +114,12 @@ public class ConsulDiscoveryProperties { */ private Map serverListQueryTags = new HashMap<>(); + /** + * Add the 'passing` parameter to /v1/health/service/serviceName. + * This pushes health check passing to the server. + */ + private boolean queryPassing = false; + @SuppressWarnings("unused") private ConsulDiscoveryProperties() {} diff --git a/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulServerList.java b/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulServerList.java index bceccad9..ad70ef08 100644 --- a/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulServerList.java +++ b/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/ConsulServerList.java @@ -58,12 +58,13 @@ public class ConsulServerList extends AbstractServerList { } private List getServers() { - if (client == null) { + if (this.client == null) { return Collections.emptyList(); } String tag = getTag(); // null is ok - Response> response = client.getHealthServices( - this.serviceId, tag, false, QueryParams.DEFAULT); + Response> response = this.client.getHealthServices( + this.serviceId, tag, this.properties.isQueryPassing(), + QueryParams.DEFAULT); if (response.getValue() == null || response.getValue().isEmpty()) { return Collections.emptyList(); }