api网关集成Sentinel网关流控组件

This commit is contained in:
zlt
2019-08-03 16:40:23 +08:00
parent d61d0645bf
commit 567d646ea2
2 changed files with 18 additions and 12 deletions
+5
View File
@@ -32,6 +32,11 @@
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
@@ -2,28 +2,29 @@ spring:
# sentinel动态配置规则 # sentinel动态配置规则
cloud: cloud:
sentinel: sentinel:
zuul:
enabled: true
order:
pre: 2000
post: 500
error: -100
filter:
enabled: false
datasource: datasource:
# 限流 # 限流
ds1: ds1:
nacos: nacos:
server-addr: ${zlt.nacos.server-addr} server-addr: ${zlt.nacos.server-addr}
dataId: ${spring.application.name}-sentinel-flow dataId: ${spring.application.name}-sentinel-gw-flow
groupId: DEFAULT_GROUP groupId: DEFAULT_GROUP
rule-type: flow rule-type: gw-flow
# 熔断 # api分组
ds2: ds2:
nacos: nacos:
server-addr: ${zlt.nacos.server-addr} server-addr: ${zlt.nacos.server-addr}
dataId: ${spring.application.name}-sentinel-degrade dataId: ${spring.application.name}-sentinel-gw-api-group
groupId: DEFAULT_GROUP groupId: DEFAULT_GROUP
rule-type: degrade rule-type: gw-api-group
# 系统负载保护
ds4:
nacos:
server-addr: ${zlt.nacos.server-addr}
dataId: ${spring.application.name}-sentinel-system
groupId: DEFAULT_GROUP
rule-type: system
zlt: zlt:
oauth2: oauth2: