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)
- [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)
- - [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.
* <br/>
* <br/>
* <p>
* 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>
* SpringValueProcessor</a></code>

@ -31,8 +31,7 @@ import org.springframework.util.StringUtils;
/**
* Placeholder helper functions.
* <br/>
* <br/>
* <p>
* 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>
* PlaceholderHelper</a></code>

@ -26,8 +26,7 @@ import org.springframework.core.MethodParameter;
/**
* Spring @Value method info.
* <br/>
* <br/>
* <p>
* 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>
* SpringValue</a></code>

@ -19,8 +19,7 @@ package com.tencent.cloud.polaris.config.spring.property;
/**
* Spring value.
* <br/>
* <br/>
* <p>
* 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>
* SpringValueDefinition</a></code>

@ -36,8 +36,7 @@ import org.springframework.beans.factory.BeanFactory;
/**
* Spring value auto registry.
* <br/>
* <br/>
* <p>
* 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>
* SpringValueRegistry</a></code>

@ -24,6 +24,7 @@ spring:
### Maven依赖
```xml
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
@ -41,11 +42,11 @@ spring:
##### IDEA启动
分别启动
- ```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-backend```的```MetadataBackendService```
##### Maven打包启动
在```spring-cloud-tencent-examples/metadata-transfer-example```下执行
@ -76,7 +77,7 @@ spring:
# 示例:本地元数据,默认不在链路中传递
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
# 指定哪个元数据的键值将沿着链接传递
@ -123,16 +124,15 @@ curl -L -X GET 'http://127.0.0.1:48080/metadata/service/frontend/feign/info'
```json
{
"frontend-transitive-metadata": {
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE"
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE-FRONTEND"
},
"frontend-upstream-disposable-metadata": {
},
"frontend-local-disposable-metadata": {
"CUSTOM-METADATA-KEY-DISPOSABLE": "CUSTOM-VALUE-DISPOSABLE-FRONTEND"
},
"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"
},
"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": {
"CUSTOM-METADATA-KEY-DISPOSABLE": "CUSTOM-VALUE-DISPOSABLE-MIDDLE"
},
"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"
},
"backend-upstream-disposable-metadata": {
@ -166,19 +165,17 @@ curl -L -X GET 'http://127.0.0.1:48080/metadata/service/frontend/feign/info'
- 获取全局传递的元数据
```java
```
MetadataContext context=MetadataContextHolder.get();
Map<String, String> customMetadataMap=context.getFragmentContext(MetadataContext.FRAGMENT_TRANSITIVE);
customMetadataMap.forEach((key,value)->{
// ...
});
```
- 获取上游传递过来的一次性元数据
```java
```
Map<String, String> upstreamDisposableMetadatas=MetadataContextHolder.getAllDisposableMetadata(true);
upstreamDisposableMetadatas.forEach((key,value)->{
// ...
@ -187,14 +184,13 @@ upstreamDisposableMetadatas.forEach((key, value) -> {
- 获取本地配置的一次性元数据
```java
```
Map<String, String> localDisposableMetadatas=MetadataContextHolder.getAllDisposableMetadata(false);
localDisposableMetadatas.forEach((key,value)->{
// ...
});
```
### 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,6 +25,7 @@ spring:
### Maven Dependency
```xml
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
@ -62,10 +63,10 @@ java -jar ${app.jar}
Launch application, change ${app.jar} to jar's package name.
### 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
spring:
@ -77,7 +78,7 @@ spring:
# Example: intransitive
CUSTOM-METADATA-KEY-LOCAL: CUSTOM-VALUE-LOCAL
# Example: transitive
CUSTOM-METADATA-KEY-TRANSITIVE: CUSTOM-VALUE-TRANSITIVE
CUSTOM-METADATA-KEY-TRANSITIVE: CUSTOM-VALUE-TRANSITIVE-FRONTEND
# Example: disposable
CUSTOM-METADATA-KEY-DISPOSABLE: CUSTOM-VALUE-DISPOSABLE-FRONTEND
# 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
spring:
@ -110,7 +112,6 @@ spring:
# Specify which metadata key value will be passed only once (one-step)
disposable:
- CUSTOM-METADATA-KEY-DISPOSABLE
```
### Verify
@ -126,7 +127,7 @@ Expected return rate
```
{
"frontend-transitive-metadata": {
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE"
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE-FRONTEND"
},
"frontend-upstream-disposable-metadata": {
},
@ -135,7 +136,7 @@ Expected return rate
},
"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"
},
"middle-upstream-disposable-metadata": {
@ -146,7 +147,7 @@ Expected return rate
},
"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"
},
"backend-upstream-disposable-metadata": {
@ -162,14 +163,16 @@ Response value description
> `*` (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 `*-upstream-disposable-metadata` indicates the one-time transmissible metadata obtained from upstream requests in the service.
- Key `*-local-disposable-metadata` indicates the one-time metadata passed downstream as configured by the current service.
- Key `*-upstream-disposable-metadata` indicates the one-time transmissible metadata obtained from upstream requests in
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
- Get the metadata passed globally
```java
```
MetadataContext context=MetadataContextHolder.get();
Map<String, String> customMetadataMap=context.getFragmentContext(MetadataContext.FRAGMENT_TRANSITIVE);
@ -180,7 +183,7 @@ customMetadataMap.forEach((key, value) -> {
- Get disposable(one-time) metadata passed from upstream
```java
```
Map<String, String> upstreamDisposableMetadatas=MetadataContextHolder.getAllDisposableMetadata(true);
upstreamDisposableMetadatas.forEach((key,value)->{
// ...
@ -189,14 +192,14 @@ upstreamDisposableMetadatas.forEach((key, value) -> {
- Get disposable(one-time) metadata for local configuration
```java
```
Map<String, String> localDisposableMetadatas=MetadataContextHolder.getAllDisposableMetadata(false);
localDisposableMetadatas.forEach((key,value)->{
// ...
});
```
### 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.

@ -18,6 +18,26 @@
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</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>
<build>

@ -18,6 +18,31 @@
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</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>
<build>

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

@ -18,6 +18,31 @@
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</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>
<build>

@ -19,31 +19,4 @@
<module>metadata-middle</module>
<module>metadata-backend</module>
</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>

@ -19,6 +19,11 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-circuitbreaker</artifactId>
@ -39,6 +44,11 @@
<artifactId>spring-cloud-circuitbreaker-spring-retry</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>

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

@ -31,5 +31,4 @@ public class ProviderBFallback implements ProviderB {
public String info() {
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

@ -18,6 +18,16 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</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>
<build>

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>polaris-circuitbreaker-example</artifactId>
@ -12,12 +12,21 @@
<artifactId>polaris-circuitbreaker-example-b2</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</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>
<build>

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

@ -19,17 +19,4 @@
<module>polaris-circuitbreaker-example-b</module>
<module>polaris-circuitbreaker-example-b2</module>
</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>

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

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

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

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

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

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

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

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

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

@ -42,6 +42,7 @@
<artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>

@ -37,5 +37,4 @@ public interface DiscoveryCalleeService {
*/
@GetMapping("/discovery/service/callee/sum")
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) {
return 0;
}
}

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

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

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

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

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>spring-cloud-tencent-examples</artifactId>
@ -18,27 +18,4 @@
<module>router-callee-service2</module>
<module>router-caller-service</module>
</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>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>polaris-router-example</artifactId>
@ -18,6 +18,16 @@
<artifactId>spring-cloud-starter-tencent-polaris-discovery</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-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>polaris-router-example</artifactId>
@ -18,6 +18,16 @@
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</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>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>polaris-router-example</artifactId>
@ -23,6 +23,26 @@
<artifactId>spring-cloud-starter-tencent-polaris-router</artifactId>
</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>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>

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

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

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

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

@ -23,7 +23,8 @@ import org.aspectj.lang.annotation.Aspect;
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
*/
@Aspect

Loading…
Cancel
Save