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

Add support for request item pattern matching in API gateway flow control #842

Merged
merged 2 commits into from
Jun 18, 2019

Conversation

sczyh30
Copy link
Member

@sczyh30 sczyh30 commented Jun 17, 2019

Signed-off-by: Eric Zhao [email protected]

Describe what this PR does / why we need it

Support pattern matching for request items in API gateway flow control.

Does this pull request fix one issue?

Resolves #839

Describe how you did it

  • Update the GatewayParamParser to support matching the request item.
    • Till now three matching strategies has been supported: exact, contains and regex.
    • The items that are not matched will be unified as a constant parameter (SentinelGatewayConstants.GATEWAY_NOT_MATCH_PARAM)
  • Update the internal logic of converting gateway rules to parameter flow rules. The unified mismatched parameters (SentinelGatewayConstants.GATEWAY_NOT_MATCH_PARAM) will be configured as an exception item with a large threshold (indicating always pass).
  • Add a GatewayRegexCache to cache the compiled regex for performance.
  • Constant rename: separate URL matching strategy from parameter matching strategy

Describe how to verify it

Run the test cases and demo.

Special notes for reviews

NONE

- Update GatewayParamParser to support matching the request item.
- Update the internal logic of converting gateway rules to parameter flow rules.
- Add a GatewayRegexCache to cache the compiled regex for performance
- Update test cases and demo

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

codecov-io commented Jun 17, 2019

Codecov Report

Merging #842 into master will increase coverage by 0.21%.
The diff coverage is 74.35%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #842      +/-   ##
============================================
+ Coverage     41.73%   41.95%   +0.21%     
- Complexity     1383     1400      +17     
============================================
  Files           305      306       +1     
  Lines          8807     8843      +36     
  Branches       1188     1196       +8     
============================================
+ Hits           3676     3710      +34     
  Misses         4677     4677              
- Partials        454      456       +2
Impacted Files Coverage Δ Complexity Δ
.../gateway/sc/api/matcher/WebExchangeApiMatcher.java 56.25% <ø> (ø) 6 <0> (ø) ⬇️
...way/zuul/api/matcher/RequestContextApiMatcher.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...apter/gateway/common/api/ApiPathPredicateItem.java 23.52% <100%> (+4.77%) 2 <0> (ø) ⬇️
...apter/gateway/common/param/GatewayParamParser.java 74.66% <50%> (+6.09%) 27 <0> (+8) ⬆️
...pter/gateway/common/rule/GatewayRuleConverter.java 90.9% <66.66%> (-9.1%) 5 <1> (+2)
...dapter/gateway/common/param/GatewayRegexCache.java 85.71% <85.71%> (ø) 5 <5> (?)
...dapter/gateway/common/rule/GatewayRuleManager.java 69.35% <85.71%> (+0.97%) 13 <0> (ø) ⬇️
...ava/com/alibaba/csp/sentinel/node/ClusterNode.java 100% <0%> (+4.76%) 8% <0%> (+1%) ⬆️

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 254ccbb...267ead8. Read the comment docs.

1 similar comment
@codecov-io
Copy link

Codecov Report

Merging #842 into master will increase coverage by 0.21%.
The diff coverage is 74.35%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #842      +/-   ##
============================================
+ Coverage     41.73%   41.95%   +0.21%     
- Complexity     1383     1400      +17     
============================================
  Files           305      306       +1     
  Lines          8807     8843      +36     
  Branches       1188     1196       +8     
============================================
+ Hits           3676     3710      +34     
  Misses         4677     4677              
- Partials        454      456       +2
Impacted Files Coverage Δ Complexity Δ
.../gateway/sc/api/matcher/WebExchangeApiMatcher.java 56.25% <ø> (ø) 6 <0> (ø) ⬇️
...way/zuul/api/matcher/RequestContextApiMatcher.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...apter/gateway/common/api/ApiPathPredicateItem.java 23.52% <100%> (+4.77%) 2 <0> (ø) ⬇️
...apter/gateway/common/param/GatewayParamParser.java 74.66% <50%> (+6.09%) 27 <0> (+8) ⬆️
...pter/gateway/common/rule/GatewayRuleConverter.java 90.9% <66.66%> (-9.1%) 5 <1> (+2)
...dapter/gateway/common/param/GatewayRegexCache.java 85.71% <85.71%> (ø) 5 <5> (?)
...dapter/gateway/common/rule/GatewayRuleManager.java 69.35% <85.71%> (+0.97%) 13 <0> (ø) ⬇️
...ava/com/alibaba/csp/sentinel/node/ClusterNode.java 100% <0%> (+4.76%) 8% <0%> (+1%) ⬆️

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 254ccbb...267ead8. Read the comment docs.

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

@sczyh30 sczyh30 added this to the 1.6.2 milestone Jun 18, 2019
@sczyh30 sczyh30 merged commit 56e463e into master Jun 18, 2019
@sczyh30 sczyh30 deleted the feature/gateway-param-pattern branch June 18, 2019 06:09
@sczyh30 sczyh30 removed the to-review To review label Jun 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Category issues or prs related to feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support pattern matching for request items in API gateway flow control
3 participants