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

org.zodiac.autoconfigure.sentinel.datasource.SentinelRedisDataSourceAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
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());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy