Refactor and improve fallback support for @SentinelResource annotation#693
Merged
Refactor and improve fallback support for @SentinelResource annotation#693
Conversation
Codecov Report
@@ Coverage Diff @@
## master #693 +/- ##
===========================================
+ Coverage 41.17% 42.08% +0.9%
- Complexity 1315 1398 +83
===========================================
Files 288 289 +1
Lines 8478 8771 +293
Branches 1147 1257 +110
===========================================
+ Hits 3491 3691 +200
- Misses 4551 4630 +79
- Partials 436 450 +14
Continue to review full report at Codecov.
|
- Refactor logic for blockHandler and fallback to be more useful - Add `fallbackClass` support for fallback in global class - Add `defaultFallback` support - Update test cases Signed-off-by: Eric Zhao <sczyh16@gmail.com>
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
26bb295 to
beae67a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe what this PR does / why we need it
Refactor and improve fallback support for
@SentinelResourceannotation to improve usability.Does this pull request fix one issue?
Resolves #647
Describe how you did it
blockHandlerandfallbackfallbackClasssupport for fallback in global classesdefaultFallbacksupportBreaking changes: the behavior of
fallbackhas changed. In previous versions, the fallback will take effect only whenblockHandleris not configured andDegradeExceptioncaught, which might be confusing and inconvenient for users. So I improved the semantics offallback: now it can handle all kinds of exceptions (except configuredexceptionsToIgnore). And adefaultFallbackis also added to support universal fallback shared for multiple methods.The method signature requirement of
fallbackhas changed. Now it can be:Throwableparameter can be provided to get the actual exception.For
defaultFallback, the requirement:Throwableparameter can be provided to get the actual exception.For
BlockException, whenblockHandleris provided, Sentinel will use theblockHandler, or Sentinel will try to use fallback to handle theBlockException.Describe how to verify it
Run the test cases and demo.
Special notes for reviews
This PR contains breaking changes. Please take care of the changes.