Interface LoadBalancerClient

    • Method Detail

      • execute

        <T> T execute​(String serviceId,
                      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.
        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

        URI reconstructURI​(ServiceInstance instance,
                           URI original)
        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 URI
        original - A URI with the host as a logical service name.
        Returns:
        A reconstructed URI.