feat:optimize examples. (#578)

pull/580/head
Haotian Zhang 2 years ago committed by GitHub
parent 9dc3d054ea
commit 9ea84328f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -35,4 +35,5 @@
- [Optimize: optimize report call result for restTemplate.](https://github.com/Tencent/spring-cloud-tencent/pull/565) - [Optimize: optimize report call result for restTemplate.](https://github.com/Tencent/spring-cloud-tencent/pull/565)
- [feat:add spring-cloud-starter-tencent-all and quickstart examples.](https://github.com/Tencent/spring-cloud-tencent/pull/569) - [feat:add spring-cloud-starter-tencent-all and quickstart examples.](https://github.com/Tencent/spring-cloud-tencent/pull/569)
- [refactor:optimize project and code.](https://github.com/Tencent/spring-cloud-tencent/pull/571) - [refactor:optimize project and code.](https://github.com/Tencent/spring-cloud-tencent/pull/571)
- - [Optimize:change default dynamic config refresh type to reflect.](https://github.com/Tencent/spring-cloud-tencent/pull/575) - [Optimize:change default dynamic config refresh type to reflect.](https://github.com/Tencent/spring-cloud-tencent/pull/575)
- [feat:optimize examples.](https://github.com/Tencent/spring-cloud-tencent/pull/578)

@ -48,8 +48,7 @@ import org.springframework.lang.NonNull;
/** /**
* Spring value processor of field or method which has @Value and xml config placeholders. * Spring value processor of field or method which has @Value and xml config placeholders.
* <br/> * <p>
* <br/>
* This source file was originally from: * This source file was originally from:
* <code><a href=https://github.com/apolloconfig/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/SpringValueProcessor.java> * <code><a href=https://github.com/apolloconfig/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/SpringValueProcessor.java>
* SpringValueProcessor</a></code> * SpringValueProcessor</a></code>

@ -31,8 +31,7 @@ import org.springframework.util.StringUtils;
/** /**
* Placeholder helper functions. * Placeholder helper functions.
* <br/> * <p>
* <br/>
* This source file was originally from: * This source file was originally from:
* <code><a href=https://github.com/apolloconfig/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/PlaceholderHelper.java> * <code><a href=https://github.com/apolloconfig/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/PlaceholderHelper.java>
* PlaceholderHelper</a></code> * PlaceholderHelper</a></code>

@ -26,8 +26,7 @@ import org.springframework.core.MethodParameter;
/** /**
* Spring @Value method info. * Spring @Value method info.
* <br/> * <p>
* <br/>
* This source file was originally from: * This source file was originally from:
* <code><a href=https://github.com/apolloconfig/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/SpringValue.java> * <code><a href=https://github.com/apolloconfig/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/SpringValue.java>
* SpringValue</a></code> * SpringValue</a></code>

@ -19,8 +19,7 @@ package com.tencent.cloud.polaris.config.spring.property;
/** /**
* Spring value. * Spring value.
* <br/> * <p>
* <br/>
* This source file was originally from: * This source file was originally from:
* <code><a href=https://github.com/apolloconfig/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/SpringValueDefinition.java> * <code><a href=https://github.com/apolloconfig/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/SpringValueDefinition.java>
* SpringValueDefinition</a></code> * SpringValueDefinition</a></code>

@ -36,8 +36,7 @@ import org.springframework.beans.factory.BeanFactory;
/** /**
* Spring value auto registry. * Spring value auto registry.
* <br/> * <p>
* <br/>
* This source file was originally from: * This source file was originally from:
* <code><a href=https://github.com/apolloconfig/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/SpringValueRegistry.java> * <code><a href=https://github.com/apolloconfig/apollo/blob/master/apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/SpringValueRegistry.java>
* SpringValueRegistry</a></code> * SpringValueRegistry</a></code>

@ -24,9 +24,10 @@ spring:
### Maven依赖 ### Maven依赖
```xml ```xml
<dependency> <dependency>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId> <artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
</dependency> </dependency>
``` ```
@ -41,11 +42,11 @@ spring:
##### IDEA启动 ##### IDEA启动
分别启动 分别启动
- ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-frontend```的```MetadataFrontendService``` - ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-frontend```的```MetadataFrontendService```
- ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-middle```的```MetadataMiddleService``` - ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-middle```的```MetadataMiddleService```
- ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-backend```的```MetadataBackendService``` - ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-backend```的```MetadataBackendService```
##### Maven打包启动 ##### Maven打包启动
在```spring-cloud-tencent-examples/metadata-transfer-example```下执行 在```spring-cloud-tencent-examples/metadata-transfer-example```下执行
@ -76,7 +77,7 @@ spring:
# 示例:本地元数据,默认不在链路中传递 # 示例:本地元数据,默认不在链路中传递
CUSTOM-METADATA-KEY-LOCAL: CUSTOM-VALUE-LOCAL CUSTOM-METADATA-KEY-LOCAL: CUSTOM-VALUE-LOCAL
# 示例:可传递元数据 # 示例:可传递元数据
CUSTOM-METADATA-KEY-TRANSITIVE: CUSTOM-VALUE-TRANSITIVE CUSTOM-METADATA-KEY-TRANSITIVE: CUSTOM-VALUE-TRANSITIVE-FRONTEND
# 示例:一次性元数据 # 示例:一次性元数据
CUSTOM-METADATA-KEY-DISPOSABLE: CUSTOM-VALUE-DISPOSABLE-FRONTEND CUSTOM-METADATA-KEY-DISPOSABLE: CUSTOM-VALUE-DISPOSABLE-FRONTEND
# 指定哪个元数据的键值将沿着链接传递 # 指定哪个元数据的键值将沿着链接传递
@ -123,16 +124,15 @@ curl -L -X GET 'http://127.0.0.1:48080/metadata/service/frontend/feign/info'
```json ```json
{ {
"frontend-transitive-metadata": { "frontend-transitive-metadata": {
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE" "CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE-FRONTEND"
}, },
"frontend-upstream-disposable-metadata": { "frontend-upstream-disposable-metadata": {
}, },
"frontend-local-disposable-metadata": { "frontend-local-disposable-metadata": {
"CUSTOM-METADATA-KEY-DISPOSABLE": "CUSTOM-VALUE-DISPOSABLE-FRONTEND" "CUSTOM-METADATA-KEY-DISPOSABLE": "CUSTOM-VALUE-DISPOSABLE-FRONTEND"
}, },
"middle-transitive-metadata": { "middle-transitive-metadata": {
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE", "CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE-FRONTEND",
"CUSTOM-METADATA-KEY-TRANSITIVE-2": "CUSTOM-VALUE-TRANSITIVE-2" "CUSTOM-METADATA-KEY-TRANSITIVE-2": "CUSTOM-VALUE-TRANSITIVE-2"
}, },
"middle-upstream-disposable-metadata": { "middle-upstream-disposable-metadata": {
@ -141,9 +141,8 @@ curl -L -X GET 'http://127.0.0.1:48080/metadata/service/frontend/feign/info'
"middle-local-disposable-metadata": { "middle-local-disposable-metadata": {
"CUSTOM-METADATA-KEY-DISPOSABLE": "CUSTOM-VALUE-DISPOSABLE-MIDDLE" "CUSTOM-METADATA-KEY-DISPOSABLE": "CUSTOM-VALUE-DISPOSABLE-MIDDLE"
}, },
"backend-transitive-metadata": { "backend-transitive-metadata": {
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE", "CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE-FRONTEND",
"CUSTOM-METADATA-KEY-TRANSITIVE-2": "CUSTOM-VALUE-TRANSITIVE-2" "CUSTOM-METADATA-KEY-TRANSITIVE-2": "CUSTOM-VALUE-TRANSITIVE-2"
}, },
"backend-upstream-disposable-metadata": { "backend-upstream-disposable-metadata": {
@ -166,35 +165,32 @@ curl -L -X GET 'http://127.0.0.1:48080/metadata/service/frontend/feign/info'
- 获取全局传递的元数据 - 获取全局传递的元数据
```java ```
MetadataContext context = MetadataContextHolder.get(); MetadataContext context=MetadataContextHolder.get();
Map<String, String> customMetadataMap = context.getFragmentContext(MetadataContext.FRAGMENT_TRANSITIVE); Map<String, String> customMetadataMap=context.getFragmentContext(MetadataContext.FRAGMENT_TRANSITIVE);
customMetadataMap.forEach((key,value)->{
customMetadataMap.forEach((key, value) -> { // ...
// ...
}); });
``` ```
- 获取上游传递过来的一次性元数据 - 获取上游传递过来的一次性元数据
```java ```
Map<String, String> upstreamDisposableMetadatas = MetadataContextHolder.getAllDisposableMetadata(true); Map<String, String> upstreamDisposableMetadatas=MetadataContextHolder.getAllDisposableMetadata(true);
upstreamDisposableMetadatas.forEach((key, value) -> { upstreamDisposableMetadatas.forEach((key,value)->{
// ... // ...
}); });
``` ```
- 获取本地配置的一次性元数据 - 获取本地配置的一次性元数据
```java ```
Map<String, String> localDisposableMetadatas = MetadataContextHolder.getAllDisposableMetadata(false); Map<String, String> localDisposableMetadatas=MetadataContextHolder.getAllDisposableMetadata(false);
localDisposableMetadatas.forEach((key, value) -> { localDisposableMetadatas.forEach((key,value)->{
// ... // ...
}); });
``` ```
### Wiki参考 ### Wiki参考
查看 [Spring Cloud Tencent Metadata Transfer 使用指南](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Metadata-Transfer-%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97) . 查看 [Spring Cloud Tencent Metadata Transfer 使用指南](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Metadata-Transfer-%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97)

@ -25,9 +25,10 @@ spring:
### Maven Dependency ### Maven Dependency
```xml ```xml
<dependency> <dependency>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId> <artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
</dependency> </dependency>
``` ```
@ -62,10 +63,10 @@ java -jar ${app.jar}
Launch application, change ${app.jar} to jar's package name. Launch application, change ${app.jar} to jar's package name.
### Metadata Configuration ### Metadata Configuration
- In the ```bootstrap.yml``` configuration file of the ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-frontend``` project - In the ```bootstrap.yml``` configuration file of
the ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-frontend``` project
```yaml ```yaml
spring: spring:
@ -77,7 +78,7 @@ spring:
# Example: intransitive # Example: intransitive
CUSTOM-METADATA-KEY-LOCAL: CUSTOM-VALUE-LOCAL CUSTOM-METADATA-KEY-LOCAL: CUSTOM-VALUE-LOCAL
# Example: transitive # Example: transitive
CUSTOM-METADATA-KEY-TRANSITIVE: CUSTOM-VALUE-TRANSITIVE CUSTOM-METADATA-KEY-TRANSITIVE: CUSTOM-VALUE-TRANSITIVE-FRONTEND
# Example: disposable # Example: disposable
CUSTOM-METADATA-KEY-DISPOSABLE: CUSTOM-VALUE-DISPOSABLE-FRONTEND CUSTOM-METADATA-KEY-DISPOSABLE: CUSTOM-VALUE-DISPOSABLE-FRONTEND
# Assigned which metadata key-value will be passed along the link # Assigned which metadata key-value will be passed along the link
@ -89,7 +90,8 @@ spring:
``` ```
- In the ```bootstrap.yml``` configuration file of the ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-middle``` project - In the ```bootstrap.yml``` configuration file of
the ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-middle``` project
```yaml ```yaml
spring: spring:
@ -110,7 +112,6 @@ spring:
# Specify which metadata key value will be passed only once (one-step) # Specify which metadata key value will be passed only once (one-step)
disposable: disposable:
- CUSTOM-METADATA-KEY-DISPOSABLE - CUSTOM-METADATA-KEY-DISPOSABLE
``` ```
### Verify ### Verify
@ -126,7 +127,7 @@ Expected return rate
``` ```
{ {
"frontend-transitive-metadata": { "frontend-transitive-metadata": {
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE" "CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE-FRONTEND"
}, },
"frontend-upstream-disposable-metadata": { "frontend-upstream-disposable-metadata": {
}, },
@ -135,7 +136,7 @@ Expected return rate
}, },
"middle-transitive-metadata": { "middle-transitive-metadata": {
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE", "CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE-FRONTEND",
"CUSTOM-METADATA-KEY-TRANSITIVE-2": "CUSTOM-VALUE-TRANSITIVE-2" "CUSTOM-METADATA-KEY-TRANSITIVE-2": "CUSTOM-VALUE-TRANSITIVE-2"
}, },
"middle-upstream-disposable-metadata": { "middle-upstream-disposable-metadata": {
@ -146,7 +147,7 @@ Expected return rate
}, },
"backend-transitive-metadata": { "backend-transitive-metadata": {
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE", "CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE-FRONTEND",
"CUSTOM-METADATA-KEY-TRANSITIVE-2": "CUSTOM-VALUE-TRANSITIVE-2" "CUSTOM-METADATA-KEY-TRANSITIVE-2": "CUSTOM-VALUE-TRANSITIVE-2"
}, },
"backend-upstream-disposable-metadata": { "backend-upstream-disposable-metadata": {
@ -162,41 +163,43 @@ Response value description
> `*` (asterisk), representing `frontend`, `middle`, `backend` in the example. > `*` (asterisk), representing `frontend`, `middle`, `backend` in the example.
- Key `*-transitive-metadata` represents all the passable (fully linked) metadata configured by default in the service. - Key `*-transitive-metadata` represents all the passable (fully linked) metadata configured by default in the service.
- Key `*-upstream-disposable-metadata` indicates the one-time transmissible metadata obtained from upstream requests in the service. - Key `*-upstream-disposable-metadata` indicates the one-time transmissible metadata obtained from upstream requests in
- Key `*-local-disposable-metadata` indicates the one-time metadata passed downstream as configured by the current service. the service.
- Key `*-local-disposable-metadata` indicates the one-time metadata passed downstream as configured by the current
service.
### How to get the passed metadata via Api ### How to get the passed metadata via Api
- Get the metadata passed globally - Get the metadata passed globally
```java ```
MetadataContext context = MetadataContextHolder.get(); MetadataContext context=MetadataContextHolder.get();
Map<String, String> customMetadataMap = context.getFragmentContext(MetadataContext.FRAGMENT_TRANSITIVE); Map<String, String> customMetadataMap=context.getFragmentContext(MetadataContext.FRAGMENT_TRANSITIVE);
customMetadataMap.forEach((key, value) -> { customMetadataMap.forEach((key,value)->{
// ... // ...
}); });
``` ```
- Get disposable(one-time) metadata passed from upstream - Get disposable(one-time) metadata passed from upstream
```java ```
Map<String, String> upstreamDisposableMetadatas = MetadataContextHolder.getAllDisposableMetadata(true); Map<String, String> upstreamDisposableMetadatas=MetadataContextHolder.getAllDisposableMetadata(true);
upstreamDisposableMetadatas.forEach((key, value) -> { upstreamDisposableMetadatas.forEach((key,value)->{
// ... // ...
}); });
``` ```
- Get disposable(one-time) metadata for local configuration - Get disposable(one-time) metadata for local configuration
```java ```
Map<String, String> localDisposableMetadatas = MetadataContextHolder.getAllDisposableMetadata(false); Map<String, String> localDisposableMetadatas=MetadataContextHolder.getAllDisposableMetadata(false);
localDisposableMetadatas.forEach((key, value) -> { localDisposableMetadatas.forEach((key,value)->{
// ... // ...
}); });
``` ```
### Wiki Reference ### Wiki Reference
See [Spring Cloud Tencent Metadata Transfer Usage Document](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Metadata-Transfer-Usage-Document) for more reference . See [Spring Cloud Tencent Metadata Transfer Usage Document](https://github.com/Tencent/spring-cloud-tencent/wiki/Spring-Cloud-Tencent-Metadata-Transfer-Usage-Document)
for more reference.

@ -1,51 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>metadata-transfer-example</artifactId> <artifactId>metadata-transfer-example</artifactId>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<version>${revision}</version> <version>${revision}</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>metadata-backend</artifactId> <artifactId>metadata-backend</artifactId>
<name>Spring Cloud Tencent Metadata Transfer Backend Service</name> <name>Spring Cloud Tencent Metadata Transfer Backend Service</name>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<goals> <goals>
<goal>repackage</goal> <goal>repackage</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<id>attach-sources</id> <id>attach-sources</id>
<goals> <goals>
<goal>jar</goal> <goal>jar</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

@ -17,4 +17,4 @@ management:
web: web:
exposure: exposure:
include: include:
- polaris-metadata - polaris-metadata

@ -1,51 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>metadata-transfer-example</artifactId> <artifactId>metadata-transfer-example</artifactId>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<version>${revision}</version> <version>${revision}</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>metadata-frontend</artifactId> <artifactId>metadata-frontend</artifactId>
<name>Spring Cloud Tencent Metadata Transfer Frontent Service</name> <name>Spring Cloud Tencent Metadata Transfer Frontent Service</name>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<goals> <goals>
<goal>repackage</goal> <goal>repackage</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<id>attach-sources</id> <id>attach-sources</id>
<goals> <goals>
<goal>jar</goal> <goal>jar</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

@ -20,7 +20,7 @@ spring:
# Example: intransitive # Example: intransitive
CUSTOM-METADATA-KEY-LOCAL: CUSTOM-VALUE-LOCAL CUSTOM-METADATA-KEY-LOCAL: CUSTOM-VALUE-LOCAL
# Example: disposable # Example: disposable
CUSTOM-METADATA-KEY-DISPOSABLE: CUSTOM-VALUE-DISPOSABLE CUSTOM-METADATA-KEY-DISPOSABLE: CUSTOM-VALUE-DISPOSABLE-FRONTEND
# Example: transitive # Example: transitive
CUSTOM-METADATA-KEY-TRANSITIVE: CUSTOM-VALUE-TRANSITIVE-FRONTEND CUSTOM-METADATA-KEY-TRANSITIVE: CUSTOM-VALUE-TRANSITIVE-FRONTEND
# Assigned which metadata key-value will be passed along the link # Assigned which metadata key-value will be passed along the link
@ -33,4 +33,4 @@ management:
web: web:
exposure: exposure:
include: include:
- polaris-metadata - polaris-metadata

@ -1,51 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>metadata-transfer-example</artifactId> <artifactId>metadata-transfer-example</artifactId>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<version>${revision}</version> <version>${revision}</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>metadata-middle</artifactId> <artifactId>metadata-middle</artifactId>
<name>Spring Cloud Tencent Metadata Transfer Middle Service</name> <name>Spring Cloud Tencent Metadata Transfer Middle Service</name>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<goals> <goals>
<goal>repackage</goal> <goal>repackage</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<id>attach-sources</id> <id>attach-sources</id>
<goals> <goals>
<goal>jar</goal> <goal>jar</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

@ -32,4 +32,4 @@ management:
web: web:
exposure: exposure:
include: include:
- polaris-metadata - polaris-metadata

@ -19,31 +19,4 @@
<module>metadata-middle</module> <module>metadata-middle</module>
<module>metadata-backend</module> <module>metadata-backend</module>
</modules> </modules>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
</dependencies>
</project> </project>

@ -19,6 +19,11 @@
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-circuitbreaker</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-circuitbreaker</artifactId>
@ -39,39 +44,44 @@
<artifactId>spring-cloud-circuitbreaker-spring-retry</artifactId> <artifactId>spring-cloud-circuitbreaker-spring-retry</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.owasp.esapi</groupId> <groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId> <artifactId>esapi</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<goals> <goals>
<goal>repackage</goal> <goal>repackage</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<id>attach-sources</id> <id>attach-sources</id>
<goals> <goals>
<goal>jar</goal> <goal>jar</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

@ -30,9 +30,9 @@ public interface ProviderB {
/** /**
* Get info of service B. * Get info of service B.
*
* @return info of service B * @return info of service B
*/ */
@GetMapping("/example/service/b/info") @GetMapping("/example/service/b/info")
String info(); String info();
} }

@ -31,5 +31,4 @@ public class ProviderBFallback implements ProviderB {
public String info() { public String info() {
return "trigger the refuse for service b"; return "trigger the refuse for service b";
} }
} }

@ -1,14 +0,0 @@
consumer:
circuitBreaker:
checkPeriod: 100ms
chain:
- errorCount
- errorRate
plugin:
errorCount:
continuousErrorThreshold: 1
metricNumBuckets: 1
errorRate:
errorRateThreshold: 100
metricStatTimeWindow: 1s
requestVolumeThreshold: 1

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>polaris-circuitbreaker-example</artifactId> <artifactId>polaris-circuitbreaker-example</artifactId>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<version>${revision}</version> <version>${revision}</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>polaris-circuitbreaker-example-b</artifactId> <artifactId>polaris-circuitbreaker-example-b</artifactId>
<name>Polaris Circuit Breaker Example B</name> <name>Polaris Circuit Breaker Example B</name>
<dependencies> <dependencies>
@ -18,34 +18,44 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId> <artifactId>spring-boot-starter-webflux</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<goals> <goals>
<goal>repackage</goal> <goal>repackage</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<id>attach-sources</id> <id>attach-sources</id>
<goals> <goals>
<goal>jar</goal> <goal>jar</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

@ -33,6 +33,7 @@ public class ServiceBController {
/** /**
* Get service information. * Get service information.
*
* @return service information * @return service information
*/ */
@GetMapping("/info") @GetMapping("/info")

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>polaris-circuitbreaker-example</artifactId> <artifactId>polaris-circuitbreaker-example</artifactId>
@ -12,12 +12,21 @@
<artifactId>polaris-circuitbreaker-example-b2</artifactId> <artifactId>polaris-circuitbreaker-example-b2</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId> <artifactId>spring-boot-starter-webflux</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

@ -35,6 +35,7 @@ public class ServiceBController {
/** /**
* Get service information. * Get service information.
*
* @return service information * @return service information
*/ */
@GetMapping("/info") @GetMapping("/info")

@ -19,17 +19,4 @@
<module>polaris-circuitbreaker-example-b</module> <module>polaris-circuitbreaker-example-b</module>
<module>polaris-circuitbreaker-example-b2</module> <module>polaris-circuitbreaker-example-b2</module>
</modules> </modules>
<dependencies>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
</dependencies>
</project> </project>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>spring-cloud-tencent-examples</artifactId> <artifactId>spring-cloud-tencent-examples</artifactId>
@ -28,7 +28,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>spring-cloud-tencent-examples</artifactId> <artifactId>spring-cloud-tencent-examples</artifactId>
@ -34,7 +34,6 @@
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId> <artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>

@ -51,5 +51,4 @@ public class ConfigController {
public String person() { public String person() {
return person.toString(); return person.toString();
} }
} }

@ -45,5 +45,4 @@ public final class PersonConfigChangeListener {
System.out.printf("%s = %s \n", changedKey, event.getChange(changedKey)); System.out.printf("%s = %s \n", changedKey, event.getChange(changedKey));
} }
} }
} }

@ -31,5 +31,4 @@ public class PolarisConfigExampleApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(PolarisConfigExampleApplication.class, args); SpringApplication.run(PolarisConfigExampleApplication.class, args);
} }
} }

@ -28,7 +28,13 @@
<!-- <groupId>org.springframework.cloud</groupId>--> <!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>--> <!-- <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>-->
<!-- </dependency>--> <!-- </dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>

@ -61,5 +61,4 @@ public class DiscoveryCalleeController {
LOG.info("Discovery Service Callee is called and sum is {}.", value1 + value2); LOG.info("Discovery Service Callee is called and sum is {}.", value1 + value2);
return value1 + value2; return value1 + value2;
} }
} }

@ -31,5 +31,4 @@ public class DiscoveryCalleeService {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(DiscoveryCalleeService.class, args); SpringApplication.run(DiscoveryCalleeService.class, args);
} }
} }

@ -11,9 +11,6 @@ spring:
discovery: discovery:
enabled: true enabled: true
register: true register: true
rpc-enhancement:
reporter:
enabled: true
stat: stat:
enabled: true enabled: true
port: 28082 port: 28082
@ -24,6 +21,9 @@ spring:
metadata: metadata:
content: content:
region: shanghai region: shanghai
rpc-enhancement:
reporter:
enabled: true
# consul: # consul:
# port: 8500 # port: 8500
# host: 127.0.0.1 # host: 127.0.0.1

@ -1,24 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>polaris-discovery-example</artifactId> <artifactId>polaris-discovery-example</artifactId>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<version>${revision}</version> <version>${revision}</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>discovery-caller-service</artifactId> <artifactId>discovery-caller-service</artifactId>
<name>Polaris Discovery Caller Service</name> <name>Polaris Discovery Caller Service</name>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency> </dependency>
@ -42,32 +42,33 @@
<artifactId>spring-cloud-loadbalancer</artifactId> <artifactId>spring-cloud-loadbalancer</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins> <build>
<plugin> <plugins>
<groupId>org.springframework.boot</groupId> <plugin>
<artifactId>spring-boot-maven-plugin</artifactId> <groupId>org.springframework.boot</groupId>
<executions> <artifactId>spring-boot-maven-plugin</artifactId>
<execution> <executions>
<goals> <execution>
<goal>repackage</goal> <goals>
</goals> <goal>repackage</goal>
</execution> </goals>
</executions> </execution>
</plugin> </executions>
<plugin> </plugin>
<groupId>org.apache.maven.plugins</groupId> <plugin>
<artifactId>maven-source-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>3.2.0</version> <artifactId>maven-source-plugin</artifactId>
<executions> <version>3.2.0</version>
<execution> <executions>
<id>attach-sources</id> <execution>
<goals> <id>attach-sources</id>
<goal>jar</goal> <goals>
</goals> <goal>jar</goal>
</execution> </goals>
</executions> </execution>
</plugin> </executions>
</plugins> </plugin>
</build> </plugins>
</build>
</project> </project>

@ -37,5 +37,4 @@ public interface DiscoveryCalleeService {
*/ */
@GetMapping("/discovery/service/callee/sum") @GetMapping("/discovery/service/callee/sum")
int sum(@RequestParam("value1") int value1, @RequestParam("value2") int value2); int sum(@RequestParam("value1") int value1, @RequestParam("value2") int value2);
} }

@ -31,5 +31,4 @@ public class DiscoveryCalleeServiceFallback implements DiscoveryCalleeService {
public int sum(int value1, int value2) { public int sum(int value1, int value2) {
return 0; return 0;
} }
} }

@ -67,5 +67,4 @@ public class DiscoveryCallerController {
public String healthCheck() { public String healthCheck() {
return "pk ok"; return "pk ok";
} }
} }

@ -44,5 +44,4 @@ public class DiscoveryCallerService {
public RestTemplate restTemplate() { public RestTemplate restTemplate() {
return new RestTemplate(); return new RestTemplate();
} }
} }

@ -9,6 +9,9 @@ spring:
metadata: metadata:
content: content:
region: shanghai region: shanghai
rpc-enhancement:
reporter:
enabled: true
polaris: polaris:
address: grpc://183.47.111.80:8091 address: grpc://183.47.111.80:8091
namespace: default namespace: default
@ -22,10 +25,6 @@ spring:
stat: stat:
enabled: true enabled: true
port: 28081 port: 28081
tencent:
rpc-enhancement:
reporter:
enabled: true
# pushgateway: # pushgateway:
# enabled: true # enabled: true
# address: 127.0.0.1:9091 # address: 127.0.0.1:9091

@ -31,5 +31,4 @@ public class GatewayCalleeApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(GatewayCalleeApplication.class, args); SpringApplication.run(GatewayCalleeApplication.class, args);
} }
} }

@ -75,5 +75,4 @@ public class GatewayCalleeController {
str = ESAPI.encoder().encodeForHTML(str); str = ESAPI.encoder().encodeForHTML(str);
return str; return str;
} }
} }

@ -26,10 +26,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@SpringBootApplication @SpringBootApplication
public class GatewayCalleeApplication { public class GatewayCalleeApplication2 {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(GatewayCalleeApplication.class, args); SpringApplication.run(GatewayCalleeApplication2.class, args);
} }
} }

@ -75,5 +75,4 @@ public class GatewayCalleeController {
str = ESAPI.encoder().encodeForHTML(str); str = ESAPI.encoder().encodeForHTML(str);
return str; return str;
} }
} }

@ -31,5 +31,4 @@ public class GatewayScgApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(GatewayScgApplication.class, args); SpringApplication.run(GatewayScgApplication.class, args);
} }
} }

@ -15,6 +15,11 @@ spring:
router: router:
feature-env: feature-env:
enabled: true enabled: true
metadata:
content:
a: 1
transitive:
- a
polaris: polaris:
address: grpc://183.47.111.80:8091 address: grpc://183.47.111.80:8091
namespace: default namespace: default
@ -54,15 +59,10 @@ spring:
maxBackoff: '''500ms''' maxBackoff: '''500ms'''
factor: 2 factor: 2
basedOnPreviousValue: false basedOnPreviousValue: false
# routes: routes:
# - id: GatewayCalleeService - id: GatewayCalleeService
# uri: lb://GatewayCalleeService uri: lb://GatewayCalleeService
# predicates: predicates:
# - Path=/GatewayCalleeService/** - Path=/GatewayCalleeService/**
# filters: filters:
# - StripPrefix=1 - StripPrefix=1
logging:
level:
org.springframework.cloud.gateway: info
com.tencent.cloud.polaris: debug

@ -44,5 +44,4 @@ public class CustomLabelResolver implements PolarisRateLimiterLabelServletResolv
return labels; return labels;
} }
} }

@ -40,5 +40,4 @@ public class RateLimitCalleeService {
public RestTemplate restTemplate() { public RestTemplate restTemplate() {
return new RestTemplate(); return new RestTemplate();
} }
} }

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>spring-cloud-tencent-examples</artifactId> <artifactId>spring-cloud-tencent-examples</artifactId>
@ -18,27 +18,4 @@
<module>router-callee-service2</module> <module>router-callee-service2</module>
<module>router-caller-service</module> <module>router-caller-service</module>
</modules> </modules>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
</dependencies>
</project> </project>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>polaris-router-example</artifactId> <artifactId>polaris-router-example</artifactId>
@ -18,6 +18,16 @@
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.owasp.esapi</groupId> <groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId> <artifactId>esapi</artifactId>

@ -32,5 +32,4 @@ public class RouterCalleeApplication1 {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(RouterCalleeApplication1.class, args); SpringApplication.run(RouterCalleeApplication1.class, args);
} }
} }

@ -59,5 +59,4 @@ public class RouterCalleeController {
u.setAge(user.getAge()); u.setAge(user.getAge());
return u; return u;
} }
} }

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>polaris-router-example</artifactId> <artifactId>polaris-router-example</artifactId>
@ -18,6 +18,16 @@
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.owasp.esapi</groupId> <groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId> <artifactId>esapi</artifactId>

@ -32,5 +32,4 @@ public class RouterCalleeApplication2 {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(RouterCalleeApplication2.class, args); SpringApplication.run(RouterCalleeApplication2.class, args);
} }
} }

@ -60,5 +60,4 @@ public class RouterCalleeController {
u.setAge(user.getAge()); u.setAge(user.getAge());
return u; return u;
} }
} }

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>polaris-router-example</artifactId> <artifactId>polaris-router-example</artifactId>
@ -23,6 +23,26 @@
<artifactId>spring-cloud-starter-tencent-polaris-router</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-router</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>

@ -48,5 +48,4 @@ public class CustomSpringWebRouterLabelResolver implements SpringWebRouterLabelR
labels.put("user", user.getName()); labels.put("user", user.getName());
return labels; return labels;
} }
} }

@ -33,5 +33,4 @@ public interface RouterCalleeService {
@PostMapping("/router/service/callee/info") @PostMapping("/router/service/callee/info")
String info(@RequestParam("name") String name, @RequestBody User user); String info(@RequestParam("name") String name, @RequestBody User user);
} }

@ -45,5 +45,4 @@ public class RouterCallerApplication {
public RestTemplate restTemplate() { public RestTemplate restTemplate() {
return new RestTemplate(); return new RestTemplate();
} }
} }

@ -73,5 +73,4 @@ public class RouterCallerController {
public String healthCheck() { public String healthCheck() {
return "pk ok"; return "pk ok";
} }
} }

@ -20,4 +20,11 @@
<module>quickstart-callee-service-a</module> <module>quickstart-callee-service-a</module>
<module>quickstart-callee-service-b</module> <module>quickstart-callee-service-b</module>
</modules> </modules>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
</dependencies>
</project> </project>

@ -23,7 +23,8 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.annotation.Pointcut;
/** /**
* Intercept for LoadBalancerClient, put host&port to thread local. * Intercept for BlockingLoadBalancerClient, put host and port to thread local.
*
* @author lepdou 2022-09-05 * @author lepdou 2022-09-05
*/ */
@Aspect @Aspect

Loading…
Cancel
Save