Skip to content

Commit cdeb281

Browse files
committed
feat:init from 1.6.0-Hoxton.SR12 of Spring Cloud Tencent.
1 parent dd21880 commit cdeb281

File tree

125 files changed

+6076
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+6076
-18
lines changed

.gitignore

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,56 @@
1-
# Compiled class file
2-
*.class
1+
# Eclipse project files
2+
.project
3+
.classpath
4+
.settings
5+
6+
# IntelliJ IDEA project files and directories
7+
*.iml
8+
*.ipr
9+
*.iws
10+
.idea/
11+
12+
# Build targets
13+
/target
14+
*/target
15+
target
16+
/applog
17+
*/applog
18+
applog
19+
20+
# Mac-specific directory that no other operating system needs.
21+
.DS_Store
322

4-
# Log file
5-
*.log
23+
# JVM crash logs
24+
hs_err_pid*.log
625

7-
# BlueJ files
8-
*.ctxt
26+
dependency-reduced-pom.xml
927

10-
# Mobile Tools for Java (J2ME)
11-
.mtj.tmp/
28+
*/.unison.*
29+
30+
# exclude docker-sync stuff
31+
.docker-sync
32+
*/.docker-sync
33+
34+
# exclude vscode files
35+
.vscode/
36+
!.vscode/settings.json
37+
!.vscode/tasks.json
38+
!.vscode/launch.json
39+
!.vscode/extensions.json
40+
*.factorypath
41+
42+
# misc
43+
*classes
44+
*.class
45+
.svn
46+
logs/
47+
lib/
48+
applog/
1249

13-
# Package Files #
14-
*.jar
15-
*.war
16-
*.nar
17-
*.ear
18-
*.zip
19-
*.tar.gz
20-
*.rar
50+
# Maven ignore
51+
.flattened-pom.xml
2152

22-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23-
hs_err_pid*
53+
# Polaris
54+
*/backup
55+
/backup
56+
backup
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Spring Cloud Tencent Metadata Transfer example
2+
3+
## 样例简介
4+
5+
本样例将介绍如何在Spring Cloud项目中使用```spring-cloud-starter-tencent-metadata-transfer```以使用其各项功能。
6+
7+
本样例包括```metadata-callee-service``````metadata-caller-service```
8+
9+
## 使用说明
10+
11+
### 修改配置
12+
13+
配置如下所示。其中,${ip}和${port}为Polaris后端服务的IP地址与端口号。
14+
15+
```yaml
16+
spring:
17+
application:
18+
name: ${application.name}
19+
cloud:
20+
polaris:
21+
address: ${ip}:${port}
22+
```
23+
24+
### Maven依赖
25+
26+
```xml
27+
<dependency>
28+
<groupId>com.tencent.cloud</groupId>
29+
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
30+
</dependency>
31+
```
32+
33+
### 启动样例
34+
35+
#### 启动Polaris后端服务
36+
37+
参考[Polaris Getting Started](https://github.com/PolarisMesh/polaris#getting-started)
38+
39+
#### 启动应用
40+
41+
##### IDEA启动
42+
43+
分别启动
44+
- ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-callee-service``````MetadataCalleeService```
45+
- ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-caller-service``````MetadataCallerService```
46+
47+
48+
##### Maven打包启动
49+
50+
```spring-cloud-tencent-examples/metadata-transfer-example```下执行
51+
52+
```sh
53+
mvn clean package
54+
```
55+
56+
然后在```metadata-callee-service``````metadata-caller-service```下找到生成的jar包,运行
57+
58+
```
59+
java -jar ${app.jar}
60+
```
61+
62+
启动应用,其中${app.jar}替换为对应的jar包名。
63+
64+
### 元数据配置
65+
66+
```spring-cloud-tencent-examples/metadata-transfer-example/metadata-caller-service```项目的```bootstrap.yml```配置文件中
67+
68+
```yaml
69+
spring:
70+
cloud:
71+
tencent:
72+
metadata:
73+
# 定义元数据的键值对
74+
content:
75+
# 示例:本地元数据,默认不在链路中传递
76+
CUSTOM-METADATA-KEY-LOCAL: CUSTOM-VALUE-LOCAL
77+
# 示例:可传递元数据
78+
CUSTOM-METADATA-KEY-TRANSITIVE: CUSTOM-VALUE-TRANSITIVE
79+
# 指定哪个元数据的键值将沿着链接传递
80+
transitive:
81+
- CUSTOM-METADATA-KEY-TRANSITIVE
82+
83+
```
84+
85+
### 验证
86+
87+
#### 请求调用
88+
89+
```shell
90+
curl -L -X GET 'http://127.0.0.1:48080/metadata/service/caller/feign/info'
91+
```
92+
93+
预期返回值
94+
95+
```
96+
{
97+
"caller-metadata-contents": {
98+
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE",
99+
"CUSTOM-METADATA-KEY-LOCAL": "CUSTOM-VALUE-LOCAL"
100+
},
101+
"callee-transitive-metadata": {
102+
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE"
103+
},
104+
"caller-transitive-metadata": {
105+
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE"
106+
}
107+
}
108+
```
109+
110+
返回值解析
111+
112+
- Key `caller-metadata-contents` 表示 `metadata-caller-service` 项目中默认配置的所有的元数据。
113+
- Key `caller-transitive-metadata` 表示 `metadata-caller-service` 项目中指定的可以在链路中传递的元数据列表。
114+
- Key `callee-transitive-metadata` 表示 `metadata-callee-service` 项目被 `metadata-caller-service` 调用时传递过来的上游的元数据列表。
115+
116+
### Wiki参考
117+
118+
查看 [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) .

metadata-transfer-example/README.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Spring Cloud Tencent Metadata Transfer example
2+
3+
## Example Introduction
4+
5+
This example shows how to use ```spring-cloud-starter-tencent-metadata-transfer``` in Spring Cloud project for its
6+
features.
7+
8+
This example contains ```metadata-callee-service``````metadata-caller-service```.
9+
10+
## Instruction
11+
12+
### Configuration
13+
14+
The configuration is as the following shows. ${ip} and ${port} are Polaris backend IP address and port number.
15+
16+
```yaml
17+
spring:
18+
application:
19+
name: ${application.name}
20+
cloud:
21+
polaris:
22+
address: ${ip}:${port}
23+
```
24+
25+
### Maven Dependency
26+
27+
```xml
28+
<dependency>
29+
<groupId>com.tencent.cloud</groupId>
30+
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
31+
</dependency>
32+
```
33+
34+
### Launching Example
35+
36+
#### Launching Polaris Backend Service
37+
38+
Reference to [Polaris Getting Started](https://github.com/PolarisMesh/polaris#getting-started)
39+
40+
#### Launching Application
41+
42+
- IDEA Launching
43+
44+
- ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-callee-service```‘s```MetadataCalleeService```
45+
- ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-caller-service```'s```MetadataCallerService```
46+
47+
- Maven Package Launching
48+
49+
Execute under ```spring-cloud-tencent-examples/metadata-transfer-example```
50+
51+
```sh
52+
mvn clean package
53+
```
54+
55+
Then find the jars under ```metadata-callee-service``````metadata-caller-service```, and run it:
56+
57+
```
58+
java -jar ${app.jar}
59+
```
60+
61+
Launch application, change ${app.jar} to jar's package name.
62+
63+
64+
### Metadata Configuration
65+
66+
In the ```bootstrap.yml``` configuration file of the ```spring-cloud-tencent-examples/metadata-transfer-example/metadata-caller-service``` project
67+
68+
```yaml
69+
spring:
70+
cloud:
71+
tencent:
72+
metadata:
73+
# Defined your metadata keys & values
74+
content:
75+
# Example: intransitive
76+
CUSTOM-METADATA-KEY-LOCAL: CUSTOM-VALUE-LOCAL
77+
# Example: transitive
78+
CUSTOM-METADATA-KEY-TRANSITIVE: CUSTOM-VALUE-TRANSITIVE
79+
# Assigned which metadata key-value will be passed along the link
80+
transitive:
81+
- CUSTOM-METADATA-KEY-TRANSITIVE
82+
83+
```
84+
85+
### Verify
86+
87+
#### Request Invoke
88+
89+
```shell
90+
curl -L -X GET 'http://127.0.0.1:48080/metadata/service/caller/feign/info'
91+
```
92+
93+
Expected return rate
94+
95+
```
96+
{
97+
"caller-metadata-contents": {
98+
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE",
99+
"CUSTOM-METADATA-KEY-LOCAL": "CUSTOM-VALUE-LOCAL"
100+
},
101+
"callee-transitive-metadata": {
102+
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE"
103+
},
104+
"caller-transitive-metadata": {
105+
"CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE"
106+
}
107+
}
108+
```
109+
110+
Response value description
111+
112+
- Key `caller-metadata-contents` represents all metadata configured by default in the `metadata-caller-service` project.
113+
- Key `caller-transitive-metadata` represents the list of metadata that can be passed in the link specified in the `metadata-caller-service` item.
114+
- Key `callee-transitive-metadata` represents the list of upstream metadata passed when the `metadata-callee-service` project is called by `metadata-caller-service`.
115+
116+
### Wiki Reference
117+
118+
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 .
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>metadata-transfer-example</artifactId>
7+
<groupId>com.skyebefreeman.examples</groupId>
8+
<version>${revision}</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>metadata-callee-service</artifactId>
14+
<name>Spring Cloud Tencent Metadata Transfer Callee Service</name>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>com.tencent.cloud</groupId>
19+
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
20+
</dependency>
21+
</dependencies>
22+
23+
<build>
24+
<plugins>
25+
<plugin>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-maven-plugin</artifactId>
28+
<executions>
29+
<execution>
30+
<goals>
31+
<goal>repackage</goal>
32+
</goals>
33+
</execution>
34+
</executions>
35+
</plugin>
36+
<plugin>
37+
<groupId>org.apache.maven.plugins</groupId>
38+
<artifactId>maven-source-plugin</artifactId>
39+
<version>3.2.0</version>
40+
<executions>
41+
<execution>
42+
<id>attach-sources</id>
43+
<goals>
44+
<goal>jar</goal>
45+
</goals>
46+
</execution>
47+
</executions>
48+
</plugin>
49+
</plugins>
50+
</build>
51+
</project>

0 commit comments

Comments
 (0)