当前位置:网站首页>SentinelResource注解詳解
SentinelResource注解詳解
2022-06-26 20:11:00 【菜鳥是大神】
SentinelResource注解 屬性總結。
> 本文基於Sentinel 1.6.2,理論支持1.4.0+
| 屬性 | 作用 | 是否必須 |
|---|---|---|
| value | 資源名稱 | 是 |
| entryType | entry類型,標記流量的方向,取值IN/OUT,默認是OUT | 否 |
| blockHandler | 處理BlockException的函數名稱。函數要求: 1. 必須是 public2.返回類型與原方法一致 3. 參數類型需要和原方法相匹配,並在最後加 BlockException 類型的參數。4. 默認需和原方法在同一個類中。若希望使用其他類的函數,可配置 blockHandlerClass ,並指定blockHandlerClass裏面的方法。 | 否 |
| blockHandlerClass | 存放blockHandler的類。對應的處理函數必須static修飾,否則無法解析,其他要求:同blockHandler。 | 否 |
| fallback | 用於在拋出异常的時候提供fallback處理邏輯。fallback函數可以針對所有類型的异常(除了 exceptionsToIgnore 裏面排除掉的异常類型)進行處理。函數要求:1. 返回類型與原方法一致 2. 參數類型需要和原方法相匹配,Sentinel 1.6開始,也可在方法最後加 Throwable 類型的參數。3.默認需和原方法在同一個類中。若希望使用其他類的函數,可配置 fallbackClass ,並指定fallbackClass裏面的方法。 | 否 |
| fallbackClass【1.6】 | 存放fallback的類。對應的處理函數必須static修飾,否則無法解析,其他要求:同fallback。 | 否 |
| defaultFallback【1.6】 | 用於通用的 fallback 邏輯。默認fallback函數可以針對所有類型的异常(除了 exceptionsToIgnore 裏面排除掉的异常類型)進行處理。若同時配置了 fallback 和 defaultFallback,以fallback為准。函數要求:1. 返回類型與原方法一致 2. 方法參數列錶為空,或者有一個 Throwable 類型的參數。3. 默認需要和原方法在同一個類中。若希望使用其他類的函數,可配置 fallbackClass ,並指定 fallbackClass 裏面的方法。 | 否 |
| exceptionsToIgnore【1.6】 | 指定排除掉哪些异常。排除的异常不會計入异常統計,也不會進入fallback邏輯,而是原樣拋出。 | 否 |
| exceptionsToTrace | 需要trace的异常 | Throwable |
> TIPS
>
> - 1.6.0 之前的版本 fallback 函數只針對降級异常(DegradeException)進行處理,不能針對業務异常進行處理。
> - 若 blockHandler 和 fallback 都進行了配置,則被限流降級而拋出 BlockException 時只會進入 blockHandler 處理邏輯。若未配置 blockHandler、fallback 和 defaultFallback,則被限流降級時會將 BlockException 直接拋出。
> - 從 1.4.0 版本開始,注解方式定義資源支持自動統計業務异常,無需手動調用 Tracer.trace(ex) 來記錄業務异常。Sentinel 1.4.0 以前的版本需要自行調用 Tracer.trace(ex) 來記錄業務异常。
边栏推荐
- 开户可以在网上开么?能安全吗?
- Xlua get button registration click event of ugui
- Using cache in vuex to solve the problem of data loss in refreshing state
- uni-app使用canvas绘制二维码
- Uni app uses canvas to draw QR code
- Can I open an account online? Is it safe?
- 超分之VRT
- C language file cursor fseek
- Kubernetes resource topology aware scheduling optimization
- Good thing recommendation: mobile terminal development security tool
猜你喜欢

Feign remote call
Mongodb implements creating and deleting databases, creating and deleting tables (sets), and adding, deleting, modifying, and querying data

The successfully resolved idea cannot use the log normally after referencing Lombok's @slf4j

Convex hull problem

抖音实战~搜索页面~扫描二维码

黑客用机器学习发动攻击的九种方法

关于Qt数据库开发的一些冷知识

Tiktok practice ~ homepage video ~ pull-down refresh

mongoDB的三种基础备份方法
![[recommended collection] these 8 common missing value filling skills must be mastered](/img/ab/353f74ad73ca592a3f97ea478922d9.png)
[recommended collection] these 8 common missing value filling skills must be mastered
随机推荐
Bonne Recommandation: développer des outils de sécurité pour les terminaux mobiles
浏览器事件循环
关于Qt数据库开发的一些冷知识
Xlua get button registration click event of ugui
【最详细】最新最全Redis面试大全(42道)
Unit test of boot
On the escape of inequality value
On the origin of the dispute between the tradition and the future of database -- AWS series column
好物推薦:移動端開發安全工具
Detailed explanation of stored procedures in MySQL
Convex hull problem
WebView load pdf
The successfully resolved idea cannot use the log normally after referencing Lombok's @slf4j
Introduction to single chip microcomputer one-on-one learning strategy, independent development program immediately after reading
8VC Venture Cup 2017 - Final Round C. Nikita and stack
数据库范式和主码的选择
C语言 文件光标 fseek
The king of Internet of things protocol: mqtt
西瓜书重温(七): 贝叶斯分类器(手推+代码demo)
Record of user behavior log in SSO microservice Engineering