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

Support extensible slot chain builder using SPI mechanism #145

Merged
merged 2 commits into from
Sep 12, 2018

Conversation

sczyh30
Copy link
Member

@sczyh30 sczyh30 commented Sep 12, 2018

Describe what this PR does / why we need it

Support extensible slot chain builder.

Due to the fact that the order between slots in slot chain is essential, we make the slot chain builder extensible so that users can implement their own builder, where they can arrange the order between slots.

Does this pull request fix one issue?

Resolves #55

Describe how you did it

  • The SlotChainBuilder is extensible now using Java SPI mechanism. sentinel-core provides the basic implementation DefaultSlotChainBuilder.
  • Add a SlotChainProvider to load slot chain builder and create new slot chain. The rule:
    • If there is no user-defined SlotChainBuilder, then use the default builder
    • If user-defined SlotChainBuilder exists, the provider will pick the first loaded slot chain builder, then cache the builder.

Describe how to verify it

Integration test between modules to verify the load order of multi slot chain builders.

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
@sczyh30 sczyh30 added the to-review To review label Sep 12, 2018
@codecov-io
Copy link

Codecov Report

Merging #145 into master will increase coverage by 0.16%.
The diff coverage is 66.66%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #145      +/-   ##
============================================
+ Coverage     45.72%   45.88%   +0.16%     
- Complexity      556      562       +6     
============================================
  Files           114      115       +1     
  Lines          3823     3844      +21     
  Branches        532      536       +4     
============================================
+ Hits           1748     1764      +16     
- Misses         1860     1863       +3     
- Partials        215      217       +2
Impacted Files Coverage Δ Complexity Δ
...re/src/main/java/com/alibaba/csp/sentinel/Env.java 80% <ø> (-3.34%) 1 <0> (ø)
...ba/csp/sentinel/slots/DefaultSlotChainBuilder.java 100% <100%> (ø) 2 <1> (?)
.../src/main/java/com/alibaba/csp/sentinel/CtSph.java 65.9% <100%> (ø) 8 <0> (ø) ⬇️
...baba/csp/sentinel/slotchain/SlotChainProvider.java 63.63% <63.63%> (ø) 5 <5> (?)
...ntinel/slots/statistic/metric/WindowLeapArray.java 80% <0%> (+12%) 6% <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 d142a07...948013f. 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 merged commit ca2f4d9 into alibaba:master Sep 12, 2018
@sczyh30 sczyh30 removed the to-review To review label Sep 12, 2018
Arlmls pushed a commit to Arlmls/Sentinel that referenced this pull request Jan 8, 2019
- Support extensible `SlotChainBuilder` using SPI mechanism
- Add a `SlotChainProvider` to load slot chain builder and create new slot chains

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
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.

Extensible rule manager and processor slot chain
3 participants