Implement http check timeout + polish

This commit is contained in:
Spencer Gibb
2016-01-11 15:34:00 -07:00
parent 1d52344ac8
commit 0d2dc42f55
4 changed files with 13 additions and 29 deletions

View File

@@ -41,7 +41,7 @@ public class ConsulDiscoveryClientConfiguration {
@Bean
public ConsulLifecycle consulLifecycle(ConsulDiscoveryProperties discoveryProperties) {
return new ConsulLifecycle(consulClient, lifecycleProperties(), discoveryProperties, heartbeatProperties());
return new ConsulLifecycle(consulClient, discoveryProperties, heartbeatProperties());
}
@Bean
@@ -55,11 +55,6 @@ public class ConsulDiscoveryClientConfiguration {
return new HeartbeatProperties();
}
@Bean
public LifecycleProperties lifecycleProperties() {
return new LifecycleProperties();
}
@Bean
public ConsulDiscoveryProperties consulDiscoveryProperties(InetUtils inetUtils) {
return new ConsulDiscoveryProperties(inetUtils);

View File

@@ -16,9 +16,6 @@
package org.springframework.cloud.consul.discovery;
import static org.springframework.cloud.util.InetUtils.getFirstNonLoopbackAddress;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -60,10 +57,14 @@ public class ConsulDiscoveryProperties {
private String healthCheckInterval = "10s";
private String healthCheckTimeout;
private String ipAddress;
private String hostname;
private Lifecycle lifecycle = new Lifecycle();
/**
* Use ip address rather than hostname during registration
*/
@@ -90,4 +91,9 @@ public class ConsulDiscoveryProperties {
public String getHostname() {
return this.preferIpAddress ? this.ipAddress : this.hostname;
}
@Data
public class Lifecycle {
private boolean enabled = true;
}
}

View File

@@ -43,8 +43,6 @@ public class ConsulLifecycle extends AbstractDiscoveryLifecycle {
private ConsulDiscoveryProperties properties;
private LifecycleProperties lifecycleProperties;
private HeartbeatProperties ttlConfig;
@Autowired(required = false)
@@ -55,9 +53,8 @@ public class ConsulLifecycle extends AbstractDiscoveryLifecycle {
private NewService service = new NewService();
public ConsulLifecycle(ConsulClient client, LifecycleProperties lifecycleProperties, ConsulDiscoveryProperties properties, HeartbeatProperties ttlConfig) {
public ConsulLifecycle(ConsulClient client, ConsulDiscoveryProperties properties, HeartbeatProperties ttlConfig) {
this.client = client;
this.lifecycleProperties = lifecycleProperties;
this.properties = properties;
this.ttlConfig = ttlConfig;
}
@@ -107,7 +104,7 @@ public class ConsulLifecycle extends AbstractDiscoveryLifecycle {
properties.getHealthCheckPath()));
}
check.setInterval(properties.getHealthCheckInterval());
//TODO support http check timeout
check.setTimeout(properties.getHealthCheckTimeout());
return check;
}
@@ -178,7 +175,7 @@ public class ConsulLifecycle extends AbstractDiscoveryLifecycle {
@Override
protected boolean isEnabled() {
return lifecycleProperties.isEnabled();
return this.properties.getLifecycle().isEnabled();
}
/**

View File

@@ -1,14 +0,0 @@
package org.springframework.cloud.consul.discovery;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* @author Aleksandr Tarasov (aatarasoff)
*/
@ConfigurationProperties(prefix = "spring.cloud.consul.discovery.lifecycle")
@Data
public class LifecycleProperties {
private boolean enabled = true;
}