package org.springframework.cloud.client.loadbalancer
类型:interface
说明
将会被这些类实现该接口。这些类使用负载均衡器来选择一个服务,并给服务发送请求。
根据serviceid查询ServiceInstance的接口.
Implemented by classes which use a load balancer to choose a server to send a request to.
类图
ServiceInstanceChooser类图类图说明
该接口有一个子类(抽象类AbstractLoadBalancingClient)和一个子接口(RibbonLoadBalancingHttpClient);
TODO AbstractLoadBalancingClient源码解析和RibbonLoadBalancingHttpClient源码解析
源码分析
/**
* Implemented by classes which use a load balancer to choose a server to
* send a request to.
* 将会被这些类实现该接口。这些类使用负载均衡器来选择一个服务,并给服务发送请求。
*
* @author Ryan Baxter
*/
public interface ServiceInstanceChooser {
/**
* Chooses a ServiceInstance from the LoadBalancer for the specified service.
* 从负载均衡器中选择一个指定的ServiceInstance
* @param serviceId The service ID to look up the LoadBalancer. serviceId用来检索负载均衡器.
* @return A ServiceInstance that matches the serviceId. 返回一个serviceId为入参的ServiceInstance实例.
*/
ServiceInstance choose(String serviceId);
}
ServiceInstance详细说明详见 springcloud源码解析-ServiceInstance(https://www.jianshu.com/p/08b1fd244ca0)
网友评论