All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.opensabre.rpc.openfeign.config.OpensabreLoadBalancerBean Maven / Gradle / Ivy

There is a newer version: 0.1.0
Show newest version
package io.github.opensabre.rpc.openfeign.config;

import io.github.opensabre.rpc.loadbalance.OpensabreLoadBalancer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.loadbalancer.core.ReactorLoadBalancer;
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;

public class OpensabreLoadBalancerBean {
    @Bean
    @ConditionalOnMissingBean
    public ReactorLoadBalancer reactorServiceInstanceLoadBalancer(Environment environment,
                                                                                   LoadBalancerClientFactory loadBalancerClientFactory) {
        String name = environment.getProperty(LoadBalancerClientFactory.PROPERTY_NAME);
        return new OpensabreLoadBalancer(loadBalancerClientFactory.getLazyProvider(name, ServiceInstanceListSupplier.class), name);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy