use of com.github.howinfun.sentinel.pojo.SentinelFlowRule in project study-by-myself by Howinfun.
the class AbstractSentinelRulesListener method reloadSentinelRules.
public void reloadSentinelRules(List<SentinelFlowRule> flowRuleList, List<SentinelDegradeRule> degradeRuleList) {
final List<FlowRule> flowRules = new ArrayList<>();
final List<DegradeRule> degradeRules = new ArrayList<>();
// 处理流控规则
flowRuleList.forEach(sentinelFlowRule -> {
FlowRule flowRule = new FlowRule();
BeanUtils.copyProperties(sentinelFlowRule, flowRule);
flowRules.add(flowRule);
});
// 处理熔断规则
degradeRuleList.forEach(sentinelDegradeRule -> {
DegradeRule degradeRule = new DegradeRule();
BeanUtils.copyProperties(sentinelDegradeRule, degradeRule);
degradeRules.add(degradeRule);
});
FlowRuleManager.loadRules(flowRules);
DegradeRuleManager.loadRules(degradeRules);
}
use of com.github.howinfun.sentinel.pojo.SentinelFlowRule in project study-by-myself by Howinfun.
the class SentinelRulesGenerateConfig method onApplicationEvent.
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
SentinelRulesProperties sentinelRulesProperties = this.applicationContext.getBean(SentinelRulesProperties.class);
List<SentinelFlowRule> flowRuleList = sentinelRulesProperties.getFlowRuleList();
List<SentinelDegradeRule> degradeRuleList = sentinelRulesProperties.getDegradeRuleList();
final List<FlowRule> flowRules = new ArrayList<>();
final List<DegradeRule> degradeRules = new ArrayList<>();
// 处理流控规则
flowRuleList.forEach(sentinelFlowRule -> {
FlowRule flowRule = new FlowRule();
BeanUtils.copyProperties(sentinelFlowRule, flowRule);
flowRules.add(flowRule);
});
// 处理熔断规则
degradeRuleList.forEach(sentinelDegradeRule -> {
DegradeRule degradeRule = new DegradeRule();
BeanUtils.copyProperties(sentinelDegradeRule, degradeRule);
degradeRules.add(degradeRule);
});
FlowRuleManager.loadRules(flowRules);
DegradeRuleManager.loadRules(degradeRules);
}
Aggregations