add support for scheme, currently used in http health check
fixes gh-33
This commit is contained in:
@@ -66,6 +66,8 @@ public class ConsulDiscoveryProperties {
|
||||
|
||||
private String instanceId;
|
||||
|
||||
private String scheme = "http";
|
||||
|
||||
public String getHostname() {
|
||||
return this.preferIpAddress ? this.ipAddress : this.hostname;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.cloud.client.discovery.AbstractDiscoveryLifecycle;
|
||||
|
||||
import com.ecwid.consul.v1.ConsulClient;
|
||||
import com.ecwid.consul.v1.agent.model.NewService;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
@@ -56,6 +57,7 @@ public class ConsulLifecycle extends AbstractDiscoveryLifecycle {
|
||||
|
||||
@Override
|
||||
protected void register() {
|
||||
Assert.notNull(service.getPort(), "service.port has not been set");
|
||||
String appName = getAppName();
|
||||
String id;
|
||||
if (properties.getInstanceId() == null) {
|
||||
@@ -74,8 +76,9 @@ public class ConsulLifecycle extends AbstractDiscoveryLifecycle {
|
||||
if (properties.getHealthCheckUrl() != null) {
|
||||
check.setHttp(properties.getHealthCheckUrl());
|
||||
} else {
|
||||
check.setHttp(String.format("http://%s:%s%s", properties.getHostname(),
|
||||
service.getPort(), properties.getHealthCheckPath()));
|
||||
check.setHttp(String.format("%s://%s:%s%s", properties.getScheme(),
|
||||
properties.getHostname(), service.getPort(),
|
||||
properties.getHealthCheckPath()));
|
||||
}
|
||||
check.setInterval(properties.getHealthCheckInterval());
|
||||
//TODO support http check timeout
|
||||
|
||||
@@ -46,7 +46,8 @@ import com.ecwid.consul.v1.agent.model.Service;
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@SpringApplicationConfiguration(classes = TestPropsConfig.class)
|
||||
@WebIntegrationTest(value = {"spring.application.name=myTestService", "spring.cloud.consul.discovery.instanceId=myTestService1"}, randomPort = true)
|
||||
@WebIntegrationTest(value = { "spring.application.name=myTestService",
|
||||
"spring.cloud.consul.discovery.instanceId=myTestService1" }, randomPort = true)
|
||||
public class ConsulLifecycleCustomizedPropsTests {
|
||||
|
||||
@Autowired
|
||||
|
||||
Reference in New Issue
Block a user