[spring-cloud-sleuth/#83] Fixed the way localinstance's id is returned. Fixes spring-cloud-sleuth/#83
This commit is contained in:
@@ -52,7 +52,7 @@ public class ZookeeperDiscoveryClient implements DiscoveryClient {
|
||||
@Override
|
||||
public org.springframework.cloud.client.ServiceInstance getLocalServiceInstance() {
|
||||
ServiceInstance<ZookeeperInstance> serviceInstance = this.serviceDiscovery.getServiceInstance();
|
||||
return serviceInstance == null ? null : createServiceInstance(serviceInstance.getId(), serviceInstance);
|
||||
return serviceInstance == null ? null : createServiceInstance(serviceInstance.getName(), serviceInstance);
|
||||
}
|
||||
|
||||
private static org.springframework.cloud.client.ServiceInstance createServiceInstance(String serviceId, ServiceInstance<ZookeeperInstance> serviceInstance) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import lombok.Data;
|
||||
@AllArgsConstructor
|
||||
public class ZookeeperInstance {
|
||||
private String id;
|
||||
private String name;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private ZookeeperInstance() {
|
||||
|
||||
@@ -113,7 +113,7 @@ public class ZookeeperServiceDiscovery implements ApplicationContextAware {
|
||||
// @formatter:off
|
||||
serviceInstance.set(ServiceInstance.<ZookeeperInstance>builder()
|
||||
.name(appName)
|
||||
.payload(new ZookeeperInstance(context.getId()))
|
||||
.payload(new ZookeeperInstance(context.getId(), appName))
|
||||
.port(port.get())
|
||||
.address(host)
|
||||
.uriSpec(uriSpec).build());
|
||||
|
||||
@@ -68,6 +68,13 @@ class ZookeeperDiscoveryISpec extends Specification implements PollingUtils {
|
||||
'UP' == registeredServiceStatus(instance)
|
||||
}
|
||||
|
||||
def 'should present application name as id of the service instance'() {
|
||||
given:
|
||||
ServiceInstance instance = discoveryClient.getLocalServiceInstance()
|
||||
expect:
|
||||
springAppName == instance.serviceId
|
||||
}
|
||||
|
||||
def 'should find an instance using feign via service id'() {
|
||||
expect:
|
||||
conditions.eventually willPass {
|
||||
|
||||
Reference in New Issue
Block a user