Skip to content
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

Improve the parameter flow module and refactor API gateway adapter common module #758

Merged
merged 4 commits into from
May 22, 2019

Conversation

sczyh30
Copy link
Member

@sczyh30 sczyh30 commented May 13, 2019

Describe what this PR does / why we need it

Improve the parameter flow module and refactor the API gateway adapter common module. See #756 for details.

Does this pull request fix one issue?

Resolves #756

Describe how you did it

  • Refactor FlowRuleChecker to improve code reuse. Add checkFlow method to support applying rule retrieving function and then check.
  • Separate parameter metric storage from ParamFlowSlot and improve ParamFlowRuleUtil
  • Add a ParameterMetricStorage specific for caching ParameterMetric (moved from ParamSlot)
  • Add rule map building helper method in ParamFlowRuleUtil so that we can reuse it in other rule managers
  • Refactor API gateway common module to separate converted rules from other rule managers
    • Separate converted parameter rules from ParamFlowManager. Now the converted rules will be kept in GatewayRuleManager directly.
    • Add a GatewayFlowSlot to do separate flow checking for generated rules.
    • Refactor rule converting mechanism: now non-param gateway rules (normal mode) will also be converted to parameter flow rules. The index will be the las position. In GatewayParamParser we put a constant value to the last position to achieve the effect of non-param flow control.

Describe how to verify it

Run the test cases and demo.

Special notes for reviews

Please take care of the internal breaking changes.

…mFlowRuleUtil

- Add a ParameterMetricStorage specific for caching ParameterMetric (moved from ParamSlot)
- Add rule map building helper method in ParamFlowRuleUtil so that we can reuse it in other rule managers

Signed-off-by: Eric Zhao <[email protected]>
…ther rule managers

- Separate converted parameter rules from ParamFlowManager. Now the converted rules will be kept in GatewayRuleManager directly.
- Add a GatewayFlowSlot to do separate flow checking for generated rules.
- Refactor rule converting mechanism: now gateway rules in normal mode (without parameter) will also be converted to a parameter flow rule. The index will be the last (the last position). In GatewayParamParser we put a constant value to the last position.

Signed-off-by: Eric Zhao <[email protected]>
@sczyh30 sczyh30 added kind/enhancement Category issues or prs related to enhancement. to-review To review labels May 13, 2019
@codecov-io
Copy link

codecov-io commented May 13, 2019

Codecov Report

Merging #758 into master will increase coverage by 0.65%.
The diff coverage is 66.16%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #758      +/-   ##
============================================
+ Coverage        41%   41.66%   +0.65%     
- Complexity     1335     1369      +34     
============================================
  Files           301      304       +3     
  Lines          8630     8767     +137     
  Branches       1159     1191      +32     
============================================
+ Hits           3539     3653     +114     
+ Misses         4666     4662       -4     
- Partials        425      452      +27
Impacted Files Coverage Δ Complexity Δ
...ots/statistic/ParamFlowStatisticEntryCallback.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...r/gateway/common/slot/GatewaySlotChainBuilder.java 0% <0%> (ø) 0 <0> (?)
...l/adapter/gateway/common/slot/GatewayFlowSlot.java 0% <0%> (ø) 0 <0> (?)
...lots/statistic/ParamFlowStatisticExitCallback.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...sentinel/slots/block/flow/param/ParamFlowSlot.java 83.87% <100%> (+2.51%) 10 <0> (-11) ⬇️
...tinel/slots/block/flow/param/ParamFlowChecker.java 56.08% <100%> (ø) 30 <1> (ø) ⬇️
...pter/gateway/common/rule/GatewayRuleConverter.java 100% <100%> (ø) 3 <1> (+1) ⬆️
...libaba/csp/sentinel/slots/block/flow/FlowSlot.java 100% <100%> (ø) 5 <3> (-3) ⬇️
...slots/block/flow/param/ParameterMetricStorage.java 69.23% <69.23%> (ø) 8 <8> (?)
...apter/gateway/common/param/GatewayParamParser.java 68.25% <75%> (+68.25%) 17 <0> (+17) ⬆️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4ec0462...6e794b8. Read the comment docs.

@sczyh30 sczyh30 force-pushed the refactor/gateway-flow-161 branch from 430d0d9 to 6e794b8 Compare May 21, 2019 08:53
Copy link
Contributor

@CarpenterLee CarpenterLee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Good works!

@sczyh30 sczyh30 merged commit 8d0bb69 into master May 22, 2019
@sczyh30 sczyh30 removed the to-review To review label May 22, 2019
@sczyh30 sczyh30 deleted the refactor/gateway-flow-161 branch May 22, 2019 02:06
CST11021 pushed a commit to CST11021/Sentinel that referenced this pull request Nov 3, 2021
…a#758)

 [RIP-9] Add the introduction of the basic samples in RocketMQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Category issues or prs related to enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improvement for API gateway adapter common module
3 participants