Issue Description
Type: feature request
Describe what happened (or what feature you want)
FlowRuleManager & DegradeRuleManager provide configUpdate()
method to update Rules by implements PropertyListener. But, configUpdate()
like configLoad()
, both of them clear()
ConcurrentHashMap first, then putAll()
Rules. Why dont provide a method to support add a new Rule into Map? This is necessary in the scenario where rule need to be added dynamically.
Describe what you expected to happen
provide a method like: (eg. in DegradeRuleManager)
public static boolean addRule(DegradeRule rule) {
if (null ==rule ) {
return false;
}
return degradeRules.put(rule.getResource(), rule);
}
3条答案
按热度按时间xpcnnkqh1#
Because the rules are full updated actually.
When add,update or delete a flow rule from dashboard, it push all flow rules to application side, and use
FlowRuleManager#loadRules
andconfigUpdate
to update all flow rules.If only push a new rule,
boolean addRule(FlowRule)
is indeed needed. This may be a good suggestion.qkf9rpyu2#
In my usage scenario, Rules are not controlled and updated by using Sentinel dashboard, I initialize it and update it by code.
So, I have to add a new Rule only like below:
but It may also cause concurrency problem.
I will push a PR about this.
w6mmgewl3#
Is there any progress?