forked from alibaba/spring-cloud-alibaba
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
109 changed files
with
1,827 additions
and
243 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,13 @@ | |
<parent> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-build</artifactId> | ||
<version>2.1.6.RELEASE</version> | ||
<version>2.2.0.BUILD-SNAPSHOT</version> | ||
<relativePath/> | ||
</parent> | ||
|
||
<groupId>com.alibaba.cloud</groupId> | ||
<artifactId>spring-cloud-alibaba</artifactId> | ||
<version>2.1.1.BUILD-SNAPSHOT</version> | ||
<version>2.2.0.BUILD-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
<name>Spring Cloud Alibaba</name> | ||
<description>Spring Cloud Alibaba</description> | ||
|
@@ -45,8 +45,10 @@ | |
<email>[email protected]</email> | ||
</developer> | ||
<developer> | ||
<name>fangjian</name> | ||
<name>Jim Fang</name> | ||
<email>[email protected]</email> | ||
<organization>Alibaba</organization> | ||
<url>https://github.com/fangjian0423</url> | ||
</developer> | ||
<developer> | ||
<name>xiaolongzuo</name> | ||
|
@@ -71,16 +73,23 @@ | |
|
||
<properties> | ||
<!-- Dependency Versions --> | ||
<spring-cloud-commons.version>2.1.2.RELEASE</spring-cloud-commons.version> | ||
<spring-cloud-netflix.version>2.1.2.RELEASE</spring-cloud-netflix.version> | ||
<spring-cloud-openfeign.version>2.1.2.RELEASE</spring-cloud-openfeign.version> | ||
<spring-cloud-bus.version>2.1.2.RELEASE</spring-cloud-bus.version> | ||
<spring-cloud-gateway.version>2.1.2.RELEASE</spring-cloud-gateway.version> | ||
<spring-cloud-commons.version>2.2.0.BUILD-SNAPSHOT</spring-cloud-commons.version> | ||
<spring-cloud-netflix.version>2.2.0.BUILD-SNAPSHOT</spring-cloud-netflix.version> | ||
<spring-cloud-openfeign.version>2.2.0.BUILD-SNAPSHOT</spring-cloud-openfeign.version> | ||
<spring-cloud-bus.version>2.2.0.BUILD-SNAPSHOT</spring-cloud-bus.version> | ||
<spring-cloud-gateway.version>2.2.0.BUILD-SNAPSHOT</spring-cloud-gateway.version> | ||
<spring-cloud-stream.version>Horsham.BUILD-SNAPSHOT</spring-cloud-stream.version> | ||
|
||
<junit.version>4.12</junit.version> | ||
<javax-servlet-api>3.0</javax-servlet-api> | ||
<slf4j-api.version>1.7.25</slf4j-api.version> | ||
|
||
<!-- Apache Dubbo --> | ||
<dubbo-spring-boot.version>2.7.1</dubbo-spring-boot.version> | ||
<dubbo.version>2.7.3</dubbo.version> | ||
|
||
<!-- Apache RocketMQ --> | ||
<rocketmq.starter.version>2.0.2</rocketmq.starter.version> | ||
|
||
<!-- Maven Plugin Versions --> | ||
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version> | ||
|
@@ -95,6 +104,7 @@ | |
<module>spring-cloud-alibaba-sentinel</module> | ||
<module>spring-cloud-alibaba-sentinel-datasource</module> | ||
<module>spring-cloud-alibaba-sentinel-gateway</module> | ||
<module>spring-cloud-circuitbreaker-sentinel</module> | ||
<module>spring-cloud-alibaba-nacos-config</module> | ||
<module>spring-cloud-alibaba-nacos-discovery</module> | ||
<module>spring-cloud-alibaba-seata</module> | ||
|
@@ -180,6 +190,46 @@ | |
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-stream-dependencies</artifactId> | ||
<version>${spring-cloud-stream.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-spring-boot-starter</artifactId> | ||
<version>${dubbo-spring-boot.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo</artifactId> | ||
<version>${dubbo.version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.rocketmq</groupId> | ||
<artifactId>rocketmq-spring-boot-starter</artifactId> | ||
<version>${rocketmq.starter.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
73 changes: 73 additions & 0 deletions
73
spring-cloud-alibaba-docs/src/main/asciidoc/circuitbreaker-sentinel.adoc
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} | ||
---- | ||
==== |
This file contains 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
This file contains 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
Oops, something went wrong.