-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Append/Update flow Rule #213
Conversation
core/flow/rule_manager.go
Outdated
} | ||
return m | ||
} | ||
|
||
func isAppend(rulesOfRes []*TrafficShapingController, ruleId uint64) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use []*Rule as first argument is better?
@sanxun0325 Could you please illustrate your design in PR description? |
# Conflicts: # core/circuitbreaker/rule_manager.go
# Conflicts: # core/flow/rule_manager.go
Codecov Report
@@ Coverage Diff @@
## master #213 +/- ##
==========================================
+ Coverage 42.93% 43.22% +0.28%
==========================================
Files 74 74
Lines 4316 4396 +80
==========================================
+ Hits 1853 1900 +47
- Misses 2230 2250 +20
- Partials 233 246 +13
Continue to review full report at Codecov.
|
@sczyh30 It has been updated, please check |
Could you please resolve conflict? |
core/flow/rule_manager.go
Outdated
return nil | ||
} | ||
|
||
//Append Rule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exported function need more detailed comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll add more description information
081aabe
to
92ad527
Compare
return errors.New("Ignoring the rule due to bad generated traffic controller") | ||
} | ||
resTcs[idx] = tsc | ||
tcMap[rule.Resource] = resTcs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't have to do this step . tcMap[rule.Resource] = resTcs
…olang into append_update_rule # Conflicts: # core/flow/rule_manager.go
Using resource level updates and append rules is sufficient |
Describe what this PR does / why we need it
Append and update the rule
Does this pull request fix one issue?
#174
Support appending rule for flow control/circuit breaker/system adaptive #174
Describe how you did it
append Rule 设计思路:
append flow rule 和 loadRule 基本相同,loadRule 加载Rule集合,append 只考虑追加一个Rule的情况即可。
loadRule func 每次生成新的临时TrafficControllerMap(存储resource对应的TrafficShapingController),用来替换原来全局的 tcMap
appendRule 不需要生成新的临时TrafficControllerMap,直接操作tcMap追加rule即可
实现步骤:
1:验证rule合规性
2:根据append rule resouce 查看全局tcMap中是否存在对应TrafficShapingController
3:根据当前追加Rule构建TrafficShapingController
update Rule 设计思路:
更新Rule ,需要传递要更新的Rule id 以及Rule. 更新的rule 对应的resouce 在tcMap中必须存在。
根据resource获取tcMap中的TrafficShapingController 集合
遍历集合 找到要更新的ruleId 对应的TrafficShapingController,进行更新.
实现步骤:
1:验证rule合规性
2:根据append rule resouce 查看全局tcMap中是否存在对应TrafficShapingController
3:遍历集合 找到要更新的ruleId 对应的TrafficShapingController,进行更新.
Describe how to verify it
Special notes for reviews