Bladeren bron

删除读取nacos限流配置类,因为只要配置中有,限流组件就会自动根据配置从nacos中读取

dengsixing 3 jaren geleden
bovenliggende
commit
0394cc9414
1 gewijzigde bestanden met toevoegingen van 0 en 47 verwijderingen
  1. 0 47
      src/main/java/com/fdkankan/gateway/config/SentinelPersistenceConfig.java

+ 0 - 47
src/main/java/com/fdkankan/gateway/config/SentinelPersistenceConfig.java

@@ -1,47 +0,0 @@
-package com.fdkankan.gateway.config;
-
-
-import com.alibaba.cloud.sentinel.SentinelProperties;
-import com.alibaba.cloud.sentinel.datasource.config.NacosDataSourceProperties;
-import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule;
-import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager;
-import com.alibaba.csp.sentinel.datasource.ReadableDataSource;
-import com.alibaba.csp.sentinel.datasource.nacos.NacosDataSource;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.TypeReference;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.annotation.Order;
-
-import java.util.Set;
-
-/**
- * @Description: 读取nacos限流规则
- */
-@Configuration
-@Order(2)
-public class SentinelPersistenceConfig {
-
-    @Autowired
-    private SentinelProperties sentinelProperties;
-
-    @Bean
-    public SentinelPersistenceConfig init() throws Exception {
-        loadGWFlowRule();
-        return new SentinelPersistenceConfig();
-    }
-
-    private void loadGWFlowRule() {
-        sentinelProperties.getDatasource().entrySet().stream().filter(map -> {
-            return map.getValue().getNacos() != null;
-        }).forEach(map -> {
-            NacosDataSourceProperties nacos = map.getValue().getNacos();
-            ReadableDataSource<String, Set<GatewayFlowRule>> gwFlowRuleDataSource = new NacosDataSource<>(
-                    nacos.getServerAddr(), nacos.getGroupId(), nacos.getDataId(),
-                    source -> JSON.parseObject(source, new TypeReference<Set<GatewayFlowRule>>() {
-                    }));
-            GatewayRuleManager.register2Property(gwFlowRuleDataSource.getProperty());
-        });
-    }
-}