org.zodiac.autoconfigure.loadbalancer.ribbon.InternalRibbonClientAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.loadbalancer.ribbon;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.zodiac.autoconfigure.bootstrap.breaker.routing.AppRoutingProperties;
import org.zodiac.autoconfigure.bootstrap.breaker.routing.AppRoutingServerAutoConfiguration;
import org.zodiac.autoconfigure.bootstrap.condition.ConditionalOnAppDiscoveryEnabled;
import org.zodiac.autoconfigure.bootstrap.condition.ConditionalOnBreakerRoutingEnabled;
import org.zodiac.autoconfigure.bootstrap.condition.ConditionalOnSpringCloudBootstrapDisabled;
import org.zodiac.autoconfigure.loadbalancer.ribbon.condition.ConditionalOnRibbonEnabled;
import org.zodiac.autoconfigure.loadbalancer.ribbon.condition.ConditionalOnRibbonRuleEnabled;
import org.zodiac.core.application.AppInstance;
import org.zodiac.core.bootstrap.breaker.routing.AbstractAppRouter;
import org.zodiac.core.bootstrap.breaker.routing.service.OrderedAppRoutingService;
import org.zodiac.core.bootstrap.discovery.AppDiscoveryClient;
import org.zodiac.loadbalancer.ribbon.RibbonPropertiesFactory;
import org.zodiac.loadbalancer.ribbon.config.InternalRibbonClientConfigurer;
import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.Server;
import com.netflix.loadbalancer.ServerList;
@SpringBootConfiguration
@ConditionalOnRibbonEnabled
@ConditionalOnAppDiscoveryEnabled
@ConditionalOnRibbonRuleEnabled
@ConditionalOnSpringCloudBootstrapDisabled
@AutoConfigureAfter(value = {AppRoutingServerAutoConfiguration.class})
public class InternalRibbonClientAutoConfiguration extends InternalRibbonClientConfigurer {
public InternalRibbonClientAutoConfiguration(AppRoutingProperties appRoutingProperties, PlatformRibbonClientProperties platformRibbonClientProperties,
RibbonPropertiesFactory ribbonPropertiesFactory) {
super(appRoutingProperties, platformRibbonClientProperties, ribbonPropertiesFactory);
}
@Bean
@ConditionalOnMissingBean(value = {OrderedAppRoutingService.class})
@Override
protected ServerList ribbonServerList(AppDiscoveryClient appDiscoveryClient, IClientConfig config) {
return super.ribbonServerList(appDiscoveryClient, config);
}
@Bean
@ConditionalOnBreakerRoutingEnabled
@Override
protected IRule rule(IClientConfig config, AbstractAppRouter serviceRoutingRouter,
AppDiscoveryClient appDiscoveryClient) {
return super.rule(config, serviceRoutingRouter, appDiscoveryClient);
}
}