mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
add Spring Cloud CircuitBreaker Sentinel docs
This commit is contained in:
parent
aff20a84a7
commit
181116a738
@ -0,0 +1,73 @@
|
|||||||
|
=== Circuit Breaker: Spring Cloud Circuit Breaker With Sentinel & Configuring Sentinel Circuit Breakers
|
||||||
|
|
||||||
|
==== Default Configuration
|
||||||
|
|
||||||
|
To provide a default configuration for all of your circuit breakers create a `Customizer` bean that is passed a
|
||||||
|
`SentinelCircuitBreakerFactory` or `ReactiveSentinelCircuitBreakerFactory`.
|
||||||
|
The `configureDefault` method can be used to provide a default configuration.
|
||||||
|
|
||||||
|
====
|
||||||
|
[source,java]
|
||||||
|
----
|
||||||
|
@Bean
|
||||||
|
public Customizer<SentinelCircuitBreakerFactory> defaultCustomizer() {
|
||||||
|
return factory -> factory.configureDefault(id -> new SentinelConfigBuilder(id)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
----
|
||||||
|
====
|
||||||
|
|
||||||
|
You can choose to provide default circuit breaking rules via `SentinelConfigBuilder#rules(rules)`.
|
||||||
|
You can also choose to load circuit breaking rules later elsewhere using
|
||||||
|
`DegradeRuleManager.loadRules(rules)` API of Sentinel, or via Sentinel dashboard.
|
||||||
|
|
||||||
|
===== Reactive Example
|
||||||
|
|
||||||
|
====
|
||||||
|
[source,java]
|
||||||
|
----
|
||||||
|
@Bean
|
||||||
|
public Customizer<ReactiveSentinelCircuitBreakerFactory> defaultCustomizer() {
|
||||||
|
return factory -> factory.configureDefault(id -> new SentinelConfigBuilder(id)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
----
|
||||||
|
====
|
||||||
|
|
||||||
|
==== Specific Circuit Breaker Configuration
|
||||||
|
|
||||||
|
Similarly to providing a default configuration, you can create a `Customizer` bean this is passed a
|
||||||
|
`SentinelCircuitBreakerFactory`.
|
||||||
|
|
||||||
|
====
|
||||||
|
[source,java]
|
||||||
|
----
|
||||||
|
@Bean
|
||||||
|
public Customizer<SentinelCircuitBreakerFactory> slowCustomizer() {
|
||||||
|
String slowId = "slow";
|
||||||
|
List<DegradeRule> rules = Collections.singletonList(
|
||||||
|
new DegradeRule(slowId).setGrade(RuleConstant.DEGRADE_GRADE_RT)
|
||||||
|
.setCount(100)
|
||||||
|
.setTimeWindow(10)
|
||||||
|
);
|
||||||
|
return factory -> factory.configure(builder -> builder.rules(rules), slowId);
|
||||||
|
}
|
||||||
|
----
|
||||||
|
====
|
||||||
|
|
||||||
|
===== Reactive Example
|
||||||
|
|
||||||
|
====
|
||||||
|
[source,java]
|
||||||
|
----
|
||||||
|
@Bean
|
||||||
|
public Customizer<ReactiveSentinelCircuitBreakerFactory> customizer() {
|
||||||
|
List<DegradeRule> rules = Collections.singletonList(
|
||||||
|
new DegradeRule().setGrade(RuleConstant.DEGRADE_GRADE_RT)
|
||||||
|
.setCount(100)
|
||||||
|
.setTimeWindow(10)
|
||||||
|
);
|
||||||
|
return factory -> factory.configure(builder -> builder.rules(rules), "foo", "bar");
|
||||||
|
}
|
||||||
|
----
|
||||||
|
====
|
@ -114,7 +114,7 @@ All the message types in this code are provided by the `spring-messaging`module.
|
|||||||
|
|
||||||
**The lower layer of Spring Cloud Stream also implements various code abstractions based on the previous code.**
|
**The lower layer of Spring Cloud Stream also implements various code abstractions based on the previous code.**
|
||||||
|
|
||||||
=== How to use Spring Cloud Alibaba RocketMQ Binder ###
|
=== How to use Spring Cloud Alibaba RocketMQ Binder
|
||||||
|
|
||||||
For using the Spring Cloud Alibaba RocketMQ Binder, you just need to add it to your Spring Cloud Stream application, using the following Maven coordinates:
|
For using the Spring Cloud Alibaba RocketMQ Binder, you just need to add it to your Spring Cloud Stream application, using the following Maven coordinates:
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ To learn more about how dynamic data sources work in Sentinel, refer to https://
|
|||||||
|
|
||||||
=== Support Zuul
|
=== Support Zuul
|
||||||
|
|
||||||
https://github.com/alibaba/Sentinel/wiki/%E7%BD%91%E5%85%B3%E9%99%90%E6%B5%81[参考 Sentinel 网关限流]
|
Refer https://github.com/alibaba/Sentinel/wiki/API-Gateway-Flow-Control[API Gateway Flow Control]
|
||||||
|
|
||||||
If you want to use Sentinel Starter with Zuul, you need to add the `spring-cloud-alibaba-sentinel-gateway` dependency, and you need to add the `spring-cloud-starter-netflix-zuul` dependency to let Zuul AutoConfiguration class in the gateway module takes effect:
|
If you want to use Sentinel Starter with Zuul, you need to add the `spring-cloud-alibaba-sentinel-gateway` dependency, and you need to add the `spring-cloud-starter-netflix-zuul` dependency to let Zuul AutoConfiguration class in the gateway module takes effect:
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ If you want to use Sentinel Starter with Zuul, you need to add the `spring-cloud
|
|||||||
|
|
||||||
=== Support Spring Cloud Gateway
|
=== Support Spring Cloud Gateway
|
||||||
|
|
||||||
https://github.com/alibaba/Sentinel/wiki/%E7%BD%91%E5%85%B3%E9%99%90%E6%B5%81[参考 Sentinel 网关限流]
|
Refer https://github.com/alibaba/Sentinel/wiki/API-Gateway-Flow-Control[API Gateway Flow Control]
|
||||||
|
|
||||||
If you want to use Sentinel Starter with Spring Cloud Gateway, you need to add the `spring-cloud-alibaba-sentinel-gateway` dependency and add the `spring-cloud-starter-gateway` dependency to let Spring Cloud Gateway AutoConfiguration class in the module takes effect:
|
If you want to use Sentinel Starter with Spring Cloud Gateway, you need to add the `spring-cloud-alibaba-sentinel-gateway` dependency and add the `spring-cloud-starter-gateway` dependency to let Spring Cloud Gateway AutoConfiguration class in the module takes effect:
|
||||||
|
|
||||||
@ -299,6 +299,8 @@ If you want to use Sentinel Starter with Spring Cloud Gateway, you need to add t
|
|||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
include::circuitbreaker-sentinel.adoc[]
|
||||||
|
|
||||||
=== Sentinel Endpoint
|
=== Sentinel Endpoint
|
||||||
|
|
||||||
Sentinel provides an Endpoint internally with a corresponding endpoint id of `sentinel`.
|
Sentinel provides an Endpoint internally with a corresponding endpoint id of `sentinel`.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user