LoadBalancerRequest.apply方法接受一个ServiceInstance
这是对一个服务实例的抽象定义,RibbonServer
是对他的一个实现
public interface ServiceInstance {
String getServiceId();
String getHost();
int getPort();
boolean isSecure();
URI getUri();
Map<String, String> getMetadata();
}
RibbonServer 这里是定义在RibbonLoadBalancerClient里的内部类
protected static class RibbonServer implements ServiceInstance {
private final String serviceId;
private final Server server;
//是否使用HTTPS标识
private final boolean secure;
//元数据
private Map<String, String> metadata;
protected RibbonServer(String serviceId, Server server) {
this(serviceId, server, false, Collections.<String, String> emptyMap());
}
protected RibbonServer(String serviceId, Server server, boolean secure,
Map<String, String> metadata) {
this.serviceId = serviceId;
this.server = server;
this.secure = secure;
this.metadata = metadata;
}
@Override
public String getHost() {
return this.server.getHost();
}
@Override
public int getPort() {
return this.server.getPort();
}
@Override
public URI getUri() {
return DefaultServiceInstance.getUri(this);
}
}