Class DefaultLoadBalancerResolver

  • All Implemented Interfaces:
    LoadBalancerResolver

    @Singleton
    public class DefaultLoadBalancerResolver
    extends java.lang.Object
    implements LoadBalancerResolver

    Abstraction over LoadBalancer lookup. The strategy is as follows:

    • If a reference starts with '/' then we attempt to look up the EmbeddedServer
    • If the reference contains a '/' assume it is a URL and try to create a URL reference to it
    • Otherwise delegate to the DiscoveryClient to attempt to resolve the URIs
    Since:
    1.0
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultLoadBalancerResolver​(io.micronaut.context.BeanContext beanContext, io.micronaut.discovery.ServiceInstanceList... serviceInstanceLists)
      The default server loadbalance resolver.
      DefaultLoadBalancerResolver​(io.micronaut.context.BeanContext beanContext, java.util.List<io.micronaut.discovery.ServiceInstanceList> serviceInstanceLists)
      The default server loadbalance resolver.
    • Constructor Detail

      • DefaultLoadBalancerResolver

        public DefaultLoadBalancerResolver​(io.micronaut.context.BeanContext beanContext,
                                           io.micronaut.discovery.ServiceInstanceList... serviceInstanceLists)
        The default server loadbalance resolver.
        Parameters:
        beanContext - The bean context
        serviceInstanceLists - Any other providers
      • DefaultLoadBalancerResolver

        @Inject
        public DefaultLoadBalancerResolver​(io.micronaut.context.BeanContext beanContext,
                                           java.util.List<io.micronaut.discovery.ServiceInstanceList> serviceInstanceLists)
        The default server loadbalance resolver.
        Parameters:
        beanContext - The bean context
        serviceInstanceLists - Any other providers
    • Method Detail

      • resolve

        public java.util.Optional<? extends LoadBalancer> resolve​(java.lang.String... serviceReferences)
        Description copied from interface: LoadBalancerResolver
        Resolve a LoadBalancer for the given references.
        Specified by:
        resolve in interface LoadBalancerResolver
        Parameters:
        serviceReferences - The references. These could be service IDs or fully HTTP URLs
        Returns:
        A LoadBalancer or empty of non can be resolved
      • resolveLoadBalancerForServiceID

        protected java.util.Optional<? extends LoadBalancer> resolveLoadBalancerForServiceID​(java.lang.String serviceID)
        Parameters:
        serviceID - The service Id
        Returns:
        An Optional with the load balancer