org.zodiac.autoconfigure.sentinel.datasource.SentinelRedisDataSourceAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.sentinel.datasource;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.zodiac.autoconfigure.bootstrap.condition.ConditionalOnSpringCloudBootstrapDisabled;
import org.zodiac.autoconfigure.sentinel.condition.ConditionalOnSentinelConfigEnabled;
@SpringBootConfiguration
@ConditionalOnSentinelConfigEnabled
@ConditionalOnSpringCloudBootstrapDisabled
@ConditionalOnClass(value = {com.alibaba.csp.sentinel.Env.class, com.alibaba.csp.sentinel.datasource.ReadableDataSource.class, com.alibaba.csp.sentinel.datasource.redis.RedisDataSource.class, org.zodiac.sentinel.base.model.SentinelRule.class, org.zodiac.sentinel.redis.config.RedisDataSourceListInfo.class})
public class SentinelRedisDataSourceAutoConfiguration {
public SentinelRedisDataSourceAutoConfiguration() {
super();
}
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties(prefix = org.zodiac.sentinel.redis.constants.SentinelRedisSystemPropertiesConstants.Zodiac.SENTINEL_DATASOURCE_REDIS_PREFIX)
protected RedisDataSourceListProperties redisDataSourceListProperties() {
return new RedisDataSourceListProperties();
}
@Bean
@ConditionalOnMissingBean
protected org.zodiac.sentinel.redis.config.configurer.SentinelRedisDataSourceConfigurer sentinelRedisDataSourceConfigurer(
RedisDataSourceListProperties dataSourceListProperties) {
return new org.zodiac.sentinel.redis.config.configurer.SentinelRedisDataSourceConfigurer()
.setId(dataSourceListProperties.getId())
.setList(dataSourceListProperties.getList())
.setOrder(dataSourceListProperties.getOrder());
}
}