Interface LoadBalancer


public interface LoadBalancer
Works with a single service name. Provides a single service instance.
Must be non-blocking
  • Method Details

    • selectServiceInstance

      ServiceInstance selectServiceInstance(Collection<ServiceInstance> serviceInstances)
      Select a single ServiceInstance from the given list.
      Parameters:
      serviceInstances - instances to choose from
      Returns:
      a ServiceInstance
      Throws:
      NoServiceInstanceFoundException - if the incoming collection is empty or all the service instances in the collection are deemed invalid for some reason
    • requiresStrictRecording

      default boolean requiresStrictRecording()
      LoadBalancers often record information of the calls being made with instances they return, be it inflight requests, response time, etc.
      These calculations often assume that an operation using a previously selected service instance is marked as started before the next instance selection. This prevents a situation in which multiple parallel invocations of the LoadBalancer return the same service instance (because they have the same input for selection).
      If the load balancer is insusceptible of this problem, this method should return false.
      Returns:
      true if the selecting service instance should be called atomically with marking the operation as started
      See Also: