1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package com.fdkankan.scene.config;//package com.fdkankan.scene.config;
- //
- //import com.alibaba.cloud.sentinel.SentinelProperties;
- //import com.alibaba.cloud.sentinel.datasource.config.NacosDataSourceProperties;
- //import com.alibaba.csp.sentinel.datasource.ReadableDataSource;
- //import com.alibaba.csp.sentinel.datasource.nacos.NacosDataSource;
- //import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
- //import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
- //import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
- //import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
- //import com.alibaba.fastjson.JSON;
- //import com.alibaba.fastjson.TypeReference;
- //import java.util.List;
- //import lombok.extern.slf4j.Slf4j;
- //import org.springframework.beans.factory.annotation.Autowired;
- //import org.springframework.context.annotation.Bean;
- //import org.springframework.context.annotation.Configuration;
- //
- ///**
- // * <p>
- // * -
- // * </p>
- // *
- // * @author dengsixing
- // * @since 2022/2/14
- // **/
- //@Configuration
- //@Slf4j
- //public class DataSourceInitFunc {
- //
- // @Autowired
- // private SentinelProperties sentinelProperties;
- //
- // @Bean
- // public DataSourceInitFunc init() throws Exception {
- //
- // log.info("[NacosSource初始化,从Nacos中获取熔断规则]");
- //
- // sentinelProperties.getDatasource().entrySet().stream().filter(map -> {
- // return map.getValue().getNacos() != null;
- // }).forEach(map -> {
- // NacosDataSourceProperties nacos = map.getValue().getNacos();
- // // 限流规则,需要Nacos的dataId中包含flow字符串
- // if (nacos.getDataId().contains("flow")) {
- // ReadableDataSource<String, List<FlowRule>> flowRuleDataSource = new NacosDataSource<>(nacos.getServerAddr(),
- // nacos.getGroupId(), nacos.getDataId(),
- // source -> JSON.parseObject(source, new TypeReference<List<FlowRule>>() {
- // }));
- // FlowRuleManager.register2Property(flowRuleDataSource.getProperty());
- // }
- //
- // // 降级规则,需要Nacos的dataId中包含degrade字符串
- // if (nacos.getDataId().contains("degrade")) {
- // ReadableDataSource<String, List<DegradeRule>> degradeRuleDataSource = new NacosDataSource<>(nacos.getServerAddr(),
- // nacos.getGroupId(), nacos.getDataId(),
- // source -> JSON.parseObject(source, new TypeReference<List<DegradeRule>>() {
- // }));
- // DegradeRuleManager.register2Property(degradeRuleDataSource.getProperty());
- // }
- //
- // });
- // return new DataSourceInitFunc();
- // }
- //
- //}
|