package org.springframework.cloud.client.loadbalancer
类型:interface
说明
代表一个客户端侧的负载均衡器
Represents a client-side load balancer.
类图
LoadBalancerClient类图类图说明
LoadBalancerClient接口继承了ServiceInstanceChooser接口。
LoadBalancerClient有一个实现类[RibbonLoadcerClient]。
源代码
/**
* Represents a client-side load balancer.
* @author Spencer Gibb
*/
public interface LoadBalancerClient extends ServiceInstanceChooser {
/**
* Executes request using a ServiceInstance from the LoadBalancer for the specified
* service.
* 使用一个从负载均衡器中得到的ServiceInstance执行指定的服务请求
*
* @param serviceId The service ID to look up the LoadBalancer. serviceId用来查找负载均衡器
* @param request Allows implementations to execute pre and post actions, such as
* incrementing metrics.允许子类进行扩展,例如添加监控等.
* @return The result of the LoadBalancerRequest callback on the selected
* ServiceInstance.
*/
<T> T execute(String serviceId, LoadBalancerRequest<T> request) throws IOException;
/**
* Executes request using a ServiceInstance from the LoadBalancer for the specified
* service.
* @param serviceId The service ID to look up the LoadBalancer.
* @param serviceInstance The service to execute the request to. 用来执行请求的服务实例
* @param request Allows implementations to execute pre and post actions, such as
* incrementing metrics.
* @return The result of the LoadBalancerRequest callback on the selected
* ServiceInstance.
*/
<T> T execute(String serviceId, ServiceInstance serviceInstance, LoadBalancerRequest<T> request) throws IOException;
/**
* Creates a proper URI with a real host and port for systems to utilize.
* 创建一个合适的URI(有真是的HOST和端口)
* Some systems use a URI with the logical service name as the host,
* such as http://myservice/path/to/service. This will replace the
* service name with the host:port from the ServiceInstance.
* @param instance
* @param original A URI with the host as a logical service name. 带有逻辑服务名称的URI
* @return A reconstructed URI.
*/
URI reconstructURI(ServiceInstance instance, URI original);
}
网友评论