Added the instance id to the DefaultServiceInstance (#456)

This commit is contained in:
Tim Ysewyn
2018-12-06 20:28:28 +00:00
committed by Ryan Baxter
parent 0256f9bd89
commit 0e5456aab7
2 changed files with 8 additions and 3 deletions

View File

@@ -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));
}
}

View File

@@ -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);