Browse Source

Introduce Ribbon ServerIntrospector.

Allows ribbon load balancer implementations to answer questions like isSecure(Server).
pull/6/head
Spencer Gibb 9 years ago
parent
commit
aa8626739e
  1. 12
      spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancerClient.java

12
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancerClient.java

@ -105,15 +105,11 @@ public class RibbonLoadBalancerClient implements LoadBalancerClient { @@ -105,15 +105,11 @@ public class RibbonLoadBalancerClient implements LoadBalancerClient {
if (config != null) {
return config.get(CommonClientConfigKey.IsSecure, false);
}
if (ClassUtils.isPresent("com.netflix.niws.loadbalancer.DiscoveryEnabledServer",
null)) {
if (server instanceof DiscoveryEnabledServer) {
DiscoveryEnabledServer enabled = (DiscoveryEnabledServer) server;
return enabled.getInstanceInfo().isPortEnabled(PortType.SECURE);
}
ServerIntrospector serverIntrospector = clientFactory.getInstance(serviceId, ServerIntrospector.class);
if (serverIntrospector == null) {
serverIntrospector = new DefaultServerIntrospector();
}
// Can we do better?
return ("" + server.getPort()).endsWith("443");
return serverIntrospector.isSecure(server);
}
private void recordStats(RibbonLoadBalancerContext context, Stopwatch tracer,

Loading…
Cancel
Save