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

Feature spring cloud zuul adapter #188

Merged
merged 19 commits into from
Jan 12, 2019

Conversation

tigerMoon
Copy link
Contributor

@tigerMoon tigerMoon commented Oct 16, 2018

Describe what this PR does / why we need it

Spring cloud zuul lack the capability of flow control. this starter implements this.

Does this pull request fix one issue?

Fixes #63

Describe how you did it

Implement ZuulFilter at pre, post, and error phase. provide ServiceId and API PATH level flow control.

2018-10-22 11 39 51

Describe how to verify it

  1. run test cases.
  2. include starter in local spring cloud project.

Special notes for reviews

no

@codecov-io
Copy link

codecov-io commented Oct 16, 2018

Codecov Report

Merging #188 into master will increase coverage by 1.18%.
The diff coverage is 64.51%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #188      +/-   ##
============================================
+ Coverage     37.05%   38.24%   +1.18%     
- Complexity      940      992      +52     
============================================
  Files           224      235      +11     
  Lines          7221     7407     +186     
  Branches        984     1014      +30     
============================================
+ Hits           2676     2833     +157     
+ Misses         4207     4205       -2     
- Partials        338      369      +31
Impacted Files Coverage Δ Complexity Δ
...tinel/adapter/zuul/fallback/DefaultUrlCleaner.java 0% <0%> (ø) 0 <0> (?)
...er/zuul/fallback/DefaultBlockFallbackProvider.java 100% <100%> (ø) 4 <4> (?)
...pter/zuul/fallback/DefaultRequestOriginParser.java 100% <100%> (ø) 2 <2> (?)
...dapter/zuul/properties/SentinelZuulProperties.java 45.45% <45.45%> (ø) 3 <3> (?)
.../sentinel/adapter/zuul/fallback/BlockResponse.java 46.66% <46.66%> (ø) 3 <3> (?)
...inel/adapter/zuul/filters/SentinelErrorFilter.java 56.25% <56.25%> (ø) 5 <5> (?)
...aba/csp/sentinel/adapter/zuul/util/FilterUtil.java 59.67% <59.67%> (ø) 12 <12> (?)
...tinel/adapter/zuul/filters/SentinelPostFilter.java 62.5% <62.5%> (ø) 3 <3> (?)
...dapter/zuul/fallback/ZuulBlockFallbackManager.java 71.42% <71.42%> (ø) 4 <4> (?)
...l/adapter/zuul/filters/AbstractSentinelFilter.java 83.33% <83.33%> (ø) 2 <2> (?)
... and 15 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 e42551a...85e089a. Read the comment docs.

@sczyh30 sczyh30 added the to-review To review label Oct 16, 2018
@sczyh30
Copy link
Member

sczyh30 commented Oct 25, 2018

Thanks for contributing. I'll do the review these days.

@tigerMoon
Copy link
Contributor Author

this pr has decoupled sentinel zuul adapter from Spring Cloud Zuul. the Spring Cloud Zuul adapter will put into spring cloud alibaba project and dependant with this adapter.

@junjiex123
Copy link

这个adapter什么时候可以搞定?

@sczyh30
Copy link
Member

sczyh30 commented Jan 10, 2019

Implement ZuulFilter at pre, post, and error phase. provide ServiceId and API PATH level flow control.
2018-10-22 11 39 51

这里有个问题哈:有没有可能出现以下 entry/exit 匹配不上的情况(按时间线):

  1. 请求 1 进入 SentinelPreFilter,调用 SphU.entry(res1)
  2. 请求 2 进入 SentinelPreFilter(与之前同一线程),调用 SphU.entry(res2)
  3. 请求 1 完成,从 SentinelPostFilter 处调 entry.exit()(与之前同一线程或不同线程),此时 currentContext 的 entry 可能不是 entry1,exit 的时候不匹配会抛出异常

entryexit 需要成对出现,匹配调用,否则调用链会不正确,不匹配会抛出异常。


Is it possible that resource entry/exit in SentinelPreFilter/SentinelPostFilter does not match, which causes error?

@tigerMoon
Copy link
Contributor Author

Implement ZuulFilter at pre, post, and error phase. provide ServiceId and API PATH level flow control.
2018-10-22 11 39 51

这里有个问题哈:有没有可能出现以下 entry/exit 匹配不上的情况(按时间线):

  1. 请求 1 进入 SentinelPreFilter,调用 SphU.entry(res1)
  2. 请求 2 进入 SentinelPreFilter(与之前同一线程),调用 SphU.entry(res2)
  3. 请求 1 完成,从 SentinelPostFilter 处调 entry.exit()(与之前同一线程或不同线程),此时 currentContext 的 entry 可能不是 entry1,exit 的时候不匹配会抛出异常

entryexit 需要成对出现,匹配调用,否则调用链会不正确,不匹配会抛出异常。

Is it possible that resource entry/exit in SentinelPreFilter/SentinelPostFilter does not match, which causes error?

不会出现entry/exit 匹配不上的情况。
Zuul 使用的单线程单请求的模型,SphU.entry(res1) 之后,success 之后会走SentinelPostFilter, exit.
抛异常会走ErrorFilter, exit.

Copy link
Member

@sczyh30 sczyh30 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 merged commit 3a1eb56 into alibaba:master Jan 12, 2019
@sczyh30
Copy link
Member

sczyh30 commented Jan 12, 2019

Awesome, thanks for contributing!

@sczyh30 sczyh30 removed the to-review To review label Jan 12, 2019
@sczyh30
Copy link
Member

sczyh30 commented Jan 12, 2019

@tigerMoon Could you please add Chinese document here: https://github.com/sentinel-group/sentinel-website/blob/master/docs/zh-cn/open-source-framework-integrations.md

We'll merge this with wiki later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Flow control for Netflix Zuul 1.x
4 participants