Interface LoadBalancer

All Known Implementing Classes:
AbstractRoundRobinLoadBalancer, DiscoveryClientRoundRobinLoadBalancer, FixedLoadBalancer, ServiceInstanceListRoundRobinLoadBalancer
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface LoadBalancer
Interface to abstract server selection. Allows plugging in load balancing strategies.
Since:
1.0
  • Method Details

    • select

      org.reactivestreams.Publisher<io.micronaut.discovery.ServiceInstance> select(@Nullable @Nullable Object discriminator)
      Parameters:
      discriminator - An object used to discriminate the server to select. Usually the service ID
      Returns:
      The selected ServiceInstance
    • getContextPath

      default Optional<String> getContextPath()
      Returns:
      The context path to use for requests.
    • select

      default org.reactivestreams.Publisher<io.micronaut.discovery.ServiceInstance> select()
      Returns:
      The selected ServiceInstance
    • fixed

      @Deprecated static LoadBalancer fixed(URL url)
      Deprecated.
      Use fixed(URI) instead
      A LoadBalancer that does no load balancing and always hits the given URL.
      Parameters:
      url - The URL
      Returns:
      The LoadBalancer
    • fixed

      static LoadBalancer fixed(URI uri)
      A LoadBalancer that does no load balancing and always hits the given URI.
      Parameters:
      uri - The URI
      Returns:
      The LoadBalancer
    • empty

      static LoadBalancer empty()
      Returns:
      An error because there are no load balancer