Interface LoadBalancerClient
- All Superinterfaces:
ServiceInstanceChooser
Represents a client-side load balancer.
- Author:
- Spencer Gibb
-
Method Summary
Modifier and TypeMethodDescription<T> Texecute(String serviceId, LoadBalancerRequest<T> request) Executes request using a ServiceInstance from the LoadBalancer for the specified service.<T> Texecute(String serviceId, ServiceInstance serviceInstance, LoadBalancerRequest<T> request) Executes request using a ServiceInstance from the LoadBalancer for the specified service.reconstructURI(ServiceInstance instance, URI original) Creates a proper URI with a real host and port for systems to utilize.Methods inherited from interface ServiceInstanceChooser
choose, choose
-
Method Details
-
execute
Executes request using a ServiceInstance from the LoadBalancer for the specified service.- Type Parameters:
T- type of the response- Parameters:
serviceId- The service ID to look up the LoadBalancer.request- Allows implementations to execute pre and post actions, such as incrementing metrics.- Returns:
- The result of the LoadBalancerRequest callback on the selected ServiceInstance.
- Throws:
IOException- in case of IO issues.
-
execute
<T> T execute(String serviceId, ServiceInstance serviceInstance, LoadBalancerRequest<T> request) throws IOException Executes request using a ServiceInstance from the LoadBalancer for the specified service.- Type Parameters:
T- type of the response- Parameters:
serviceId- The service ID to look up the LoadBalancer.serviceInstance- The service to execute the request to.request- Allows implementations to execute pre and post actions, such as incrementing metrics.- Returns:
- The result of the LoadBalancerRequest callback on the selected ServiceInstance.
- Throws:
IOException- in case of IO issues.
-
reconstructURI
Creates a proper URI with a real host and port for systems to utilize. 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.- Parameters:
instance- service instance to reconstruct the URIoriginal- A URI with the host as a logical service name.- Returns:
- A reconstructed URI.
-