The documentation you are viewing is for Dapr v1.8 which is an older version of Dapr. For up-to-date documentation, see the latest version.
Sentinel fault-tolerance middleware component
Sentinel is a powerful fault-tolerance component that takes “flow” as the breakthrough point and covers multiple fields including flow control, traffic shaping, concurrency limiting, circuit breaking, and adaptive system protection to guarantee the reliability and resiliency of microservices.
The Sentinel HTTP middleware enables Dapr to facilitate Sentinel’s powerful abilities to protect your application. You can refer to Sentinel Wiki for more details on Sentinel.
配置
根据下述定义,请求正文转换为大写字母:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: sentinel
spec:
type: middleware.http.sentinel
version: v1
metadata:
- name: appName
value: "nodeapp"
- name: logDir
value: "/var/tmp"
- name: flowRules
value: >-
[
{
"resource": "POST:/v1.0/invoke/nodeapp/method/neworder",
"threshold": 10,
"tokenCalculateStrategy": 0,
"controlBehavior": 0
}
]
元数据字段规范
字段 | 详情 | Example |
---|---|---|
appName | the name of current running service | nodeapp |
logDir | the log directory path | /var/tmp/sentinel |
flowRules | json array of sentinel flow control rules | flow control rule |
circuitBreakerRules | json array of sentinel circuit breaker rules | circuit breaker rule |
hotSpotParamRules | json array of sentinel hotspot parameter flow control rules | hotspot rule |
isolationRules | json array of sentinel isolation rules | isolation rule |
systemRules | json array of sentinel system rules | system rule |
一旦达到上限,请求将返回 HTTP Status code 429: Too Many Requests。
Special note to resource
field in each rule’s definition. In Dapr, it follows the following format:
POST/GET/PUT/DELETE:Dapr HTTP API Request Path
All concrete HTTP API information can be found from [Dapr API Reference]https://v1-8.docs.dapr.io/zh-hans/reference/api/. In the above sample config, the resource
field is set to POST:/v1.0/invoke/nodeapp/method/neworder.
Dapr配置
To be applied, the middleware must be referenced in configuration. See middleware pipelines.
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: daprConfig
spec:
httpPipeline:
handlers:
- name: sentinel
type: middleware.http.sentinel
相关链接
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.