Merge pull request #56 from jmnarloch/discovery-metadata
* discovery-metadata: Introduced ServiceInstance metadata map.
This commit is contained in:
@@ -17,8 +17,11 @@
|
||||
package org.springframework.cloud.client;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link ServiceInstance}.
|
||||
@@ -26,6 +29,7 @@ import lombok.Data;
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class DefaultServiceInstance implements ServiceInstance {
|
||||
|
||||
private final String serviceId;
|
||||
@@ -36,11 +40,22 @@ public class DefaultServiceInstance implements ServiceInstance {
|
||||
|
||||
private final boolean secure;
|
||||
|
||||
private final Map<String, String> metadata;
|
||||
|
||||
public DefaultServiceInstance(String serviceId, String host, int port, boolean secure) {
|
||||
this(serviceId, host, port, secure, Collections.<String, String>emptyMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getUri() {
|
||||
return getUri(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a uri from the given ServiceInstance's host:port
|
||||
* @param instance
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cloud.client;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents an instance of a Service in a Discovery System
|
||||
@@ -27,23 +28,30 @@ public interface ServiceInstance {
|
||||
/**
|
||||
* @return the service id as register by the DiscoveryClient
|
||||
*/
|
||||
public String getServiceId();
|
||||
String getServiceId();
|
||||
|
||||
/**
|
||||
* @return the hostname of the registered ServiceInstance
|
||||
*/
|
||||
public String getHost();
|
||||
String getHost();
|
||||
|
||||
/**
|
||||
* @return the port of the registered ServiceInstance
|
||||
*/
|
||||
public int getPort();
|
||||
int getPort();
|
||||
|
||||
/**
|
||||
* @return ifthe port of the registered ServiceInstance is https or not
|
||||
* @return if the port of the registered ServiceInstance is https or not
|
||||
*/
|
||||
public boolean isSecure();
|
||||
boolean isSecure();
|
||||
|
||||
public URI getUri();
|
||||
/**
|
||||
* @return the service uri address
|
||||
*/
|
||||
URI getUri();
|
||||
|
||||
/**
|
||||
* @return the key value pair metadata associated with the service instance
|
||||
*/
|
||||
Map<String, String> getMetadata();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user