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

org.zodiac.autoconfigure.bootstrap.loadbalancer.reactive.ReactorAppLoadBalancerClientAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.autoconfigure.bootstrap.loadbalancer.reactive;

import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.zodiac.autoconfigure.bootstrap.condition.ConditionalOnSpringCloudBootstrapDisabled;
import org.zodiac.autoconfigure.bootstrap.loadbalancer.AppLoadBalancerProperties;
import org.zodiac.commons.constants.SystemPropertiesConstants;
import org.zodiac.core.application.AppInstance;
import org.zodiac.core.bootstrap.loadbalancer.reactive.AppLoadBalancerClientRequestTransformer;
import org.zodiac.core.bootstrap.loadbalancer.reactive.AppLoadBalancerRetryPolicy;
import org.zodiac.core.bootstrap.loadbalancer.reactive.AppReactiveLoadBalancer;
import org.zodiac.core.bootstrap.loadbalancer.reactive.AppReactorLoadBalancerExchangeFilterFunction;
import org.zodiac.core.bootstrap.loadbalancer.reactive.AppRetryableExchangeFilterFunctionLoadBalancerRetryPolicy;
import org.zodiac.core.bootstrap.loadbalancer.reactive.AppRetryableLoadBalancerExchangeFilterFunction;

@SpringBootConfiguration
@ConditionalOnSpringCloudBootstrapDisabled
@ConditionalOnBean(value = {AppReactiveLoadBalancer.Factory.class})
@ConditionalOnClass(value = {org.springframework.web.reactive.function.client.WebClient.class})
public class ReactorAppLoadBalancerClientAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnProperty(value = SystemPropertiesConstants.Zodiac.SPRING_BOOTSTRAP_LOADBALANCER_RETRY_ENABLED,
        havingValue = "false", matchIfMissing = true)
    protected AppReactorLoadBalancerExchangeFilterFunction loadBalancerExchangeFilterFunction(
        AppReactiveLoadBalancer.Factory loadBalancerFactory, AppLoadBalancerProperties properties,
        ObjectProvider> transformers) {
        return new AppReactorLoadBalancerExchangeFilterFunction(loadBalancerFactory, properties,
            transformers.getIfAvailable(Collections::emptyList));
    }

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnProperty(value = SystemPropertiesConstants.Zodiac.SPRING_BOOTSTRAP_LOADBALANCER_RETRY_ENABLED,
        havingValue = "true")
    protected AppRetryableLoadBalancerExchangeFilterFunction retryableLoadBalancerExchangeFilterFunction(
        AppReactiveLoadBalancer.Factory loadBalancerFactory, AppLoadBalancerProperties properties,
        AppLoadBalancerRetryPolicy retryPolicy,
        ObjectProvider> transformers) {
        return new AppRetryableLoadBalancerExchangeFilterFunction(retryPolicy, loadBalancerFactory, properties,
            transformers.getIfAvailable(Collections::emptyList));
    }

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnProperty(value = SystemPropertiesConstants.Zodiac.SPRING_BOOTSTRAP_LOADBALANCER_RETRY_ENABLED,
        havingValue = "true")
    protected AppLoadBalancerRetryPolicy loadBalancerRetryPolicy(AppLoadBalancerProperties properties) {
        return new AppRetryableExchangeFilterFunctionLoadBalancerRetryPolicy(properties);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy