diff --git a/README-zh.md b/README-zh.md index 500d0573..ba912d0c 100644 --- a/README-zh.md +++ b/README-zh.md @@ -14,6 +14,7 @@ Spring Cloud Tencent包含了分布式应用微服务开发过程中所需的组 * **服务路由与负载均衡**:基于 Ribbon 的接口标准,提供场景更丰富的动态路由以及负载均衡的能力。 * **故障节点熔断**:提供故障节点的熔断剔除以及主/被动探测恢复的能力,保证分布式服务的可靠性。 * **服务限流**:支持微服务被调接入层和网关主动调用的限流功能,保证后台微服务稳定性,可通过控制台动态配置规则,及查看流量监控数据。 +* **元数据传递**: 支持网关及微服务应用之间的自定义元数据传递。 ## 如何构建 @@ -55,8 +56,6 @@ Example 列表: - [PolarisMesh](https://github.com/polarismesh)接入相关的样例: - - [快速入门](spring-cloud-tencent-examples/polaris-quickstart-example/README-zh.md) - - [服务发现](spring-cloud-tencent-examples/polaris-discovery-example/README-zh.md) - [故障熔断](spring-cloud-tencent-examples/polaris-circuitbreaker-example/README-zh.md) diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/README-zh.md b/spring-cloud-tencent-examples/polaris-quickstart-example/README-zh.md deleted file mode 100644 index 73f0454c..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/README-zh.md +++ /dev/null @@ -1,87 +0,0 @@ -# Spring Cloud Polaris Quickstart example - -[English](./README.md) | 简体中文 - ---- - -## 样例简介 - -本样例将介绍如何使应用快速接入Spring Cloud Tencent。 - -## 使用说明 - -### 修改配置 - -在 ```polaris-quickstart-example/quickstart-provider``` 以及 ```polaris-quickstart-example/quickstart-consumer``` 两个项目中,修改```bootstrap.yml```,修改后配置如下所示。 -其中,```${ip}```和${port}为Polaris后端服务的IP地址与端口号。 - -```yaml -spring: - application: - name: EchoService - cloud: - polaris: - address: grpc://${ip}:${port} -``` - -### 启动样例 - -#### 启动Provider - -- IDEA启动 - - 找到 ```polaris-quickstart-example/quickstart-provider``` 项目的主类 ```EchoServerApplication```,执行 main 方法启动样例。 - -- Maven打包启动 - -在```polaris-quickstart-example/quickstart-provider```下执行 - -```sh -mvn clean package -``` - -然后找到生成的jar包,运行 - -``` -java -jar ${app.jar} -``` - -启动应用,其中`${app.jar}`替换为对应的jar包名。 - -#### 启动Consumer - -- IDEA启动 - - 找到 ```polaris-quickstart-example/quickstart-consumer``` 项目的主类 ```EchoClientApplication```,执行 main 方法启动样例。 - -- Maven打包启动 - -在```polaris-quickstart-example/quickstart-consumer```下执行 - -```sh -mvn clean package -``` - -然后找到生成的jar包,运行 - -``` -java -jar ${app.jar} -``` - -启动应用,其中`${app.jar}`替换为对应的jar包名。 - -### 验证 - -#### HTTP调用 - -Consumer 和 Provider 启动端口都是随机生成的,因此需要记录Consumer启动时候的端口: -``` -11:26:53 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 58838 (http) with context path '' -``` -执行http调用,其中`${app.port}`替换为启动的端口。 -```shell -curl -L -X GET 'http://localhost:${app.port}/echo?value=hello_world'' -``` - -预期返回值:`echo: hello_world` - diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/README.md b/spring-cloud-tencent-examples/polaris-quickstart-example/README.md deleted file mode 100644 index 93611059..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/README.md +++ /dev/null @@ -1,85 +0,0 @@ -# Spring Cloud Polaris Quickstart example - -English | [简体中文](./README-zh.md) - ---- - -## Introduction - -This example shows how to make application integrated with spring-cloud-tencent rapidly. - -## Instruction - -### Configuration - -Modify ```bootstrap.yml```, ${ip} and ${port} is the address of polaris server. - -```yaml -spring: - application: - name: EchoService - cloud: - polaris: - address: grpc://${ip}:${port} -``` - -### Start Application - -#### Start Provider - -- Start in IDEA - -Find main class ```EchoServerApplication``` in project ```polaris-quickstart-example/quickstart-provider```, and execute the main method. - -- Start by fatjar - -Run build command in ```polaris-quickstart-example/quickstart-provider```: - -```sh -mvn clean package -``` - -find the generated fatjar, run: - -``` -java -jar ${app.jar} -``` - -${app.jar} replace to the built jar name. - -#### Start Consumer - -- Start in IDEA - -Find main class ```EchoClientApplication``` in project ```polaris-quickstart-example/quickstart-consumer```, and execute the main method. - -- Start by fatjar - -Run build command in ```polaris-quickstart-example/quickstart-consumer```: - -```sh -mvn clean package -``` - -find the generated fatjar, run: - -``` -java -jar ${app.jar} -``` - -${app.jar} replace to the built jar name. - -### Verify - -#### Invoke by http call - -Consumer and Provider application use random generated port, so you need to record the consumer port from start log. - ``` - 11:26:53 [main] INFO o.s.b.w.e.tomcat.TomcatWebServer - Tomcat started on port(s): 58838 (http) with context path '' - ``` -Invoke http call,replace `${app.port}` to the consumer port. -```shell -curl -L -X GET 'http://localhost:47080/quickstart/feign?msg=hello_world'' -``` - -expect:`echo: hello_world` \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/pom.xml b/spring-cloud-tencent-examples/polaris-quickstart-example/pom.xml deleted file mode 100644 index 92a83dff..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - spring-cloud-tencent-examples - com.tencent.cloud - ${revision} - ../pom.xml - - 4.0.0 - - polaris-quickstart-example - Spring Cloud Tencent Polaris QuickStart Example - - pom - - quickstart-provider - quickstart-consumer - - - \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/pom.xml b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/pom.xml deleted file mode 100644 index 51ee5d94..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - polaris-quickstart-example - com.tencent.cloud - ${revision} - ../pom.xml - - 4.0.0 - - quickstart-consumer - - - - spring-cloud-starter-tencent-polaris-discovery - com.tencent.cloud - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.cloud - spring-cloud-starter-openfeign - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoClientApplication.java b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoClientApplication.java deleted file mode 100644 index 9819c5ea..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoClientApplication.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the BSD 3-Clause License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - * - * Unless required by applicable law or agreed to in writing, software distributed - * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - * CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.tencent.cloud.polaris.quickstart.consumer; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.client.discovery.EnableDiscoveryClient; -import org.springframework.cloud.openfeign.EnableFeignClients; - -@SpringBootApplication -@EnableDiscoveryClient -@EnableFeignClients -public class EchoClientApplication { - - public static void main(String[] args) { - SpringApplication.run(EchoClientApplication.class, args); - } -} diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoClientController.java b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoClientController.java deleted file mode 100644 index e8f75cef..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoClientController.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the BSD 3-Clause License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - * - * Unless required by applicable law or agreed to in writing, software distributed - * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - * CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.tencent.cloud.polaris.quickstart.consumer; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/") -public class EchoClientController { - - - @Autowired - private EchoServer echoServer; - - @GetMapping("/echo") - public String echo(@RequestParam String value) { - return echoServer.echo(value); - } - -} diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoServer.java b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoServer.java deleted file mode 100644 index 3965f046..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/java/com/tencent/cloud/polaris/quickstart/consumer/EchoServer.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the BSD 3-Clause License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - * - * Unless required by applicable law or agreed to in writing, software distributed - * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - * CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.tencent.cloud.polaris.quickstart.consumer; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@FeignClient(value = "EchoServer") -public interface EchoServer { - - @GetMapping("/quickstart/echo") - String echo(@RequestParam("value") String value); -} diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/bootstrap.yml deleted file mode 100644 index 99d00fbb..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,8 +0,0 @@ -server: - port: 0 -spring: - application: - name: EchoClient - cloud: - polaris: - address: grpc://127.0.0.1:8091 \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/log4j.properties b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/log4j.properties deleted file mode 100644 index 9e520cb7..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/log4j.properties +++ /dev/null @@ -1,15 +0,0 @@ -log4j.rootLogger=DEBUG,console,FILE - -log4j.appender.console=org.apache.log4j.ConsoleAppender -log4j.appender.console.threshold=INFO -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%5p] - %c -%F(%L) -%m%n - -log4j.appender.FILE=org.apache.log4j.RollingFileAppender -log4j.appender.FILE.Append=true - -log4j.appender.FILE.File=applog/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log -log4j.appender.FILE.Threshold=INFO -log4j.appender.FILE.layout=org.apache.log4j.PatternLayout -log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%5p] - %c -%F(%L) -%m%n -log4j.appender.FILE.MaxFileSize=10MB \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/logback-spring.xml b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/logback-spring.xml deleted file mode 100644 index 57f025c4..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-consumer/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - logback - - - - %d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - - - - - true - - - applog/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log - - - - - %d{yyyy-MM-dd HH:mm:ss} -%msg%n - - - - - - - - - - diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/pom.xml b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/pom.xml deleted file mode 100644 index f4f1b628..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - polaris-quickstart-example - com.tencent.cloud - ${revision} - ../pom.xml - - 4.0.0 - - quickstart-provider - - - - spring-cloud-starter-tencent-polaris-discovery - com.tencent.cloud - - - org.springframework.boot - spring-boot-starter-web - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/java/com/tencent/cloud/polaris/quickstart/provider/EchoServerApplication.java b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/java/com/tencent/cloud/polaris/quickstart/provider/EchoServerApplication.java deleted file mode 100644 index 1f0dbefe..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/java/com/tencent/cloud/polaris/quickstart/provider/EchoServerApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the BSD 3-Clause License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - * - * Unless required by applicable law or agreed to in writing, software distributed - * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - * CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.tencent.cloud.polaris.quickstart.provider; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class EchoServerApplication { - - public static void main(String[] args) { - SpringApplication.run(EchoServerApplication.class, args); - } -} diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/java/com/tencent/cloud/polaris/quickstart/provider/EchoServerController.java b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/java/com/tencent/cloud/polaris/quickstart/provider/EchoServerController.java deleted file mode 100644 index 093ae1a7..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/java/com/tencent/cloud/polaris/quickstart/provider/EchoServerController.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the BSD 3-Clause License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - * - * Unless required by applicable law or agreed to in writing, software distributed - * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - * CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.tencent.cloud.polaris.quickstart.provider; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * main http controller for EchoService - */ -@RestController -@RequestMapping("/quickstart") -public class EchoServerController { - - @GetMapping("/echo") - public String echo(@RequestParam(value = "value") String value) { - return "echo: " + value; - } - -} diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/bootstrap.yml deleted file mode 100644 index c4bfa75b..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,8 +0,0 @@ -server: - port: 0 -spring: - application: - name: EchoServer - cloud: - polaris: - address: grpc://127.0.0.1:8091 \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/log4j.properties b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/log4j.properties deleted file mode 100644 index 9e520cb7..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/log4j.properties +++ /dev/null @@ -1,15 +0,0 @@ -log4j.rootLogger=DEBUG,console,FILE - -log4j.appender.console=org.apache.log4j.ConsoleAppender -log4j.appender.console.threshold=INFO -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%5p] - %c -%F(%L) -%m%n - -log4j.appender.FILE=org.apache.log4j.RollingFileAppender -log4j.appender.FILE.Append=true - -log4j.appender.FILE.File=applog/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log -log4j.appender.FILE.Threshold=INFO -log4j.appender.FILE.layout=org.apache.log4j.PatternLayout -log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%5p] - %c -%F(%L) -%m%n -log4j.appender.FILE.MaxFileSize=10MB \ No newline at end of file diff --git a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/logback-spring.xml b/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/logback-spring.xml deleted file mode 100644 index 57f025c4..00000000 --- a/spring-cloud-tencent-examples/polaris-quickstart-example/quickstart-provider/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - logback - - - - %d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - - - - - true - - - applog/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log - - - - - %d{yyyy-MM-dd HH:mm:ss} -%msg%n - - - - - - - - - - diff --git a/spring-cloud-tencent-examples/pom.xml b/spring-cloud-tencent-examples/pom.xml index 34e709ec..73e7d84e 100644 --- a/spring-cloud-tencent-examples/pom.xml +++ b/spring-cloud-tencent-examples/pom.xml @@ -1,6 +1,6 @@ - spring-cloud-tencent @@ -20,7 +20,6 @@ polaris-ratelimit-example polaris-circuitbreaker-example polaris-gateway-example - polaris-quickstart-example