Added the instance id to the DefaultServiceInstance (#456)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,6 +38,7 @@ import static org.springframework.cloud.consul.discovery.ConsulServerUtils.getMe
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
* @author Joe Athman
|
||||
* @author Tim Ysewyn
|
||||
*/
|
||||
public class ConsulDiscoveryClient implements DiscoveryClient {
|
||||
|
||||
@@ -99,7 +100,7 @@ public class ConsulDiscoveryClient implements DiscoveryClient {
|
||||
if (metadata.containsKey("secure")) {
|
||||
secure = Boolean.parseBoolean(metadata.get("secure"));
|
||||
}
|
||||
instances.add(new DefaultServiceInstance(serviceId, host, service
|
||||
instances.add(new DefaultServiceInstance(service.getService().getId(), serviceId, host, service
|
||||
.getService().getPort(), secure, metadata));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,6 +37,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
* @author Tim Ysewyn
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = ConsulDiscoveryClientCustomizedTests.MyTestConfig.class,
|
||||
@@ -75,6 +76,9 @@ public class ConsulDiscoveryClientCustomizedTests {
|
||||
}
|
||||
|
||||
private void assertInstance(ServiceInstance instance) {
|
||||
assertEquals("instance id was wrong", "testConsulDiscovery2Id", instance.getInstanceId());
|
||||
assertEquals("service id was wrong", "testConsulDiscovery2", instance.getServiceId());
|
||||
|
||||
Map<String, String> metadata = instance.getMetadata();
|
||||
assertNotNull("metadata was null", metadata);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user