From 06a4d5987801ecba618a3f30a6d5e5fd51ad7c0e Mon Sep 17 00:00:00 2001 From: andrew shan <45474304+andrewshan@users.noreply.github.com> Date: Tue, 14 May 2024 22:03:46 +0800 Subject: [PATCH] fix: remove circuitbreaker example (#183) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: optimize the discovery inject logic and fix nacos config not working issue * feat: 删除无用的导入 * feat: 增加actuator到demo中 * fix: add lossless healthcheck for example * fix: add configuration comments * fix: 修复事件日志不输出的问题 * release: release version to 1.7.0-RC1 * feat: new add java agent for hoxton * feat: support service registry and config * feat: refrator all inject logics into BeanInjector * feat: add gray release example & dispatch bean register into plugins * feat: add environment parameter to obtain the configuration * feat: 增加元数据传输相关拦截器 * feat: 调整example打包脚本 * fix: 修复脚本没法跳转的问题 * fix: 修正样例的配置文件 * fix: 修复熔断无法加载的问题 * fix: 更新北极星的版本号依赖 * fix: 调整版本依赖 * feat:对齐deployment与application中的服务名定义 * feat: optimize default-plugin.conf to load once per lifecyle * feat: 优化日志打印,增加polarisLoggingApplicationListener的配置 * fix: 修复启动脚本配置项错误问题 * fix: 修复无法javaagent无法获取用户的spring.application.name的问题 * fix: remove circuitbreaker example --- .../callee-service-a/Dockerfile | 29 --- .../callee-service-a/deployment.yaml | 48 ----- .../callee-service-a/pom.xml | 110 ----------- .../quickstart/callee/CustomMetadata.java | 46 ----- .../callee/QuickstartCalleeController.java | 136 ------------- .../callee/QuickstartCalleeServiceA.java | 34 ---- .../config/CustomConfigChangeListener.java | 51 ----- .../callee/config/DataSourceProperties.java | 65 ------- .../callee/ratelimit/CustomLabelResolver.java | 63 ------ .../src/main/resources/bootstrap.yml | 48 ----- .../src/main/resources/reject-tips.html | 5 - .../callee-service-b/Dockerfile | 29 --- .../callee-service-b/deployment.yaml | 48 ----- .../callee-service-b/pom.xml | 100 ---------- .../quickstart/callee/CustomMetadata.java | 46 ----- .../callee/QuickstartCalleeController.java | 162 ---------------- .../callee/QuickstartCalleeServiceB.java | 34 ---- .../config/CustomConfigChangeListener.java | 51 ----- .../callee/config/DataSourceProperties.java | 65 ------- .../CustomLabelResolverReactive.java | 60 ------ ...JsonPolarisRateLimiterLimitedFallback.java | 41 ---- .../src/main/resources/bootstrap.yml | 47 ----- .../caller-service/Dockerfile | 29 --- .../caller-service/deployment.yaml | 48 ----- .../caller-service/pom.xml | 109 ----------- .../caller/CustomMetadataProvider.java | 34 ---- .../caller/QuickstartCalleeService.java | 41 ---- .../QuickstartCalleeServiceFallback.java | 34 ---- .../caller/QuickstartCallerApplication.java | 85 -------- .../caller/QuickstartCallerController.java | 182 ------------------ .../CircuitBreakerController.java | 136 ------------- ...CircuitBreakerQuickstartCalleeService.java | 38 ---- ...reakerQuickstartCalleeServiceFallback.java | 34 ---- ...erQuickstartCalleeServiceWithFallback.java | 38 ---- .../caller/circuitbreaker/CustomFallback.java | 43 ----- .../router/CustomRouterLabelResolver.java | 54 ------ .../src/main/resources/bootstrap.yml | 46 ----- .../circuitbreaker-examples/pom.xml | 27 --- .../spring-cloud-hoxton-examples/pom.xml | 1 - 39 files changed, 2297 deletions(-) delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/Dockerfile delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/deployment.yaml delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/pom.xml delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/CustomMetadata.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeServiceA.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/config/CustomConfigChangeListener.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/config/DataSourceProperties.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/ratelimit/CustomLabelResolver.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/resources/bootstrap.yml delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/resources/reject-tips.html delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/Dockerfile delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/deployment.yaml delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/pom.xml delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/CustomMetadata.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeServiceB.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/config/CustomConfigChangeListener.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/config/DataSourceProperties.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/ratelimit/CustomLabelResolverReactive.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/ratelimit/JsonPolarisRateLimiterLimitedFallback.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/resources/bootstrap.yml delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/Dockerfile delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/deployment.yaml delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/pom.xml delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/CustomMetadataProvider.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCalleeService.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCalleeServiceFallback.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCallerApplication.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCallerController.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerController.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerQuickstartCalleeService.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerQuickstartCalleeServiceFallback.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerQuickstartCalleeServiceWithFallback.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CustomFallback.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/router/CustomRouterLabelResolver.java delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/resources/bootstrap.yml delete mode 100644 polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/pom.xml diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/Dockerfile b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/Dockerfile deleted file mode 100644 index e4da5f69..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -FROM alpine:3.19.1 - -ARG file_name -ARG java_version - -COPY ./target/${file_name} /app/main.jar - -WORKDIR /app - -RUN sed -i 's!http://dl-cdn.alpinelinux.org/!https://mirrors.tencent.com/!g' /etc/apk/repositories - -RUN set -eux && \ - apk add openjdk${java_version} && \ - apk add bind-tools && \ - apk add busybox-extras && \ - apk add findutils && \ - apk add tcpdump && \ - apk add tzdata && \ - apk add curl && \ - apk add bash && \ - cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ - echo "Asia/Shanghai" > /etc/timezone && \ - date - -RUN chmod 777 /app/ - -RUN ls -la /app/ - -ENTRYPOINT ["java", "-jar", "/app/main.jar"] \ No newline at end of file diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/deployment.yaml b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/deployment.yaml deleted file mode 100644 index 918c9608..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/deployment.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: hoxton-callee - name: hoxton-callee - namespace: default -spec: - replicas: 1 - selector: - matchLabels: - app: hoxton-callee - template: - metadata: - labels: - app: hoxton-callee - annotations: - polarismesh.cn/javaagent: "true" - polarismesh.cn/javaagentVersion: "1.7.0-RC2" - polarismesh.cn/javaagentFrameworkName: "spring-cloud" - polarismesh.cn/javaagentFrameworkVersion: "hoxton" - spec: - containers: - - image: polarismesh/polaris-javaagent-demo-sc-quickstart-hoxton-callee:1.7.0-java8 - imagePullPolicy: Always - name: provider - resources: - limits: - cpu: "500m" - memory: 1000Mi - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - command: - - /bin/bash - - -c - - cd /app && java -Dserver.port=48083 -jar main.jar - lifecycle: - preStop: - exec: - command: ["curl","-X","PUT","http://127.0.0.1:28080/offline","&&","sleep","30"] - readinessProbe: - httpGet: - path: /online - port: 28080 - initialDelaySeconds: 3 - periodSeconds: 3 - restartPolicy: Always \ No newline at end of file diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/pom.xml b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/pom.xml deleted file mode 100644 index 17b56ae7..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/pom.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - 4.0.0 - - - org.springframework.boot - spring-boot-starter-parent - 2.3.7.RELEASE - - - - - Hoxton.SR12 - 1.14.0-Hoxton.SR12-SNAPSHOT - 2.3.12.RELEASE - 1.7.30 - - - com.tencent.polaris - callee-service-a - jar - 1.7.0 - Quickstart Callee Service A - - - - - com.tencent.cloud - spring-cloud-tencent-dependencies - 1.14.0-Hoxton.SR12-SNAPSHOT - pom - import - - - com.alibaba.cloud - spring-cloud-alibaba-dependencies - 2.2.1.RELEASE - pom - import - - - - org.springframework.cloud - spring-cloud-dependencies - Hoxton.SR12 - pom - import - - - - - - - com.tencent.cloud - spring-cloud-starter-tencent-all - 1.14.0-Hoxton.SR12-SNAPSHOT - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-webflux - - - - org.springframework.cloud - spring-cloud-starter-openfeign - - - - org.springframework.boot - spring-boot-starter-actuator - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - org.apache.maven.plugins - maven-source-plugin - 3.2.0 - - - attach-sources - - jar - - - - - - - diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/CustomMetadata.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/CustomMetadata.java deleted file mode 100644 index bdd60f8e..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/CustomMetadata.java +++ /dev/null @@ -1,46 +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.quickstart.callee; - -import java.util.HashMap; -import java.util.Map; - -import com.tencent.cloud.common.spi.InstanceMetadataProvider; - -import org.springframework.stereotype.Component; - -/** - * Custom metadata for instance. - * - * @author Haotian Zhang - */ -@Component -public class CustomMetadata implements InstanceMetadataProvider { - - @Override - public Map getMetadata() { - Map metadata = new HashMap<>(); - metadata.put("k1", "v1"); - return metadata; - } - - @Override - public String getZone() { - return "shenzhen-zone-1"; - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java deleted file mode 100644 index ce586e97..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java +++ /dev/null @@ -1,136 +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.quickstart.callee; - -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; - -import com.tencent.cloud.common.constant.MetadataConstant; -import com.tencent.cloud.quickstart.callee.config.DataSourceProperties; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import static com.tencent.cloud.common.constant.ContextConstant.UTF_8; - -/** - * Quickstart callee controller. - * - * @author Haotian Zhang - */ -@RestController -@RequestMapping("/quickstart/callee") -public class QuickstartCalleeController { - - private static final Logger LOG = LoggerFactory.getLogger(QuickstartCalleeController.class); - - @Value("${server.port:0}") - private int port; - - @Value("${spring.cloud.client.ip-address:127.0.0.1}") - private String ip; - - @Value("${appName:${spring.application.name}}") - private String appName; - - @Autowired - private DataSourceProperties dataSourceProperties; - - /** - * Get sum of two value. - * @param value1 value 1 - * @param value2 value 2 - * @return sum - */ - @GetMapping("/sum") - public String sum(@RequestParam int value1, @RequestParam int value2) { - LOG.info("Quickstart Callee Service [{}:{}] is called and sum is [{}].", ip, port, value1 + value2); - return String.format("Quickstart Callee Service [%s:%s] is called and sum is [%s].", ip, port, value1 + value2); - } - - /** - * Get information of callee. - * @return information of callee - */ - @GetMapping("/info") - public String info() { - LOG.info("Quickstart [{}] Service [{}:{}] is called. datasource = [{}].", appName, ip, port, dataSourceProperties); - return String.format("Quickstart [%s] Service [%s:%s] is called. datasource = [%s].", appName, ip, port, dataSourceProperties); - } - - /** - * Mock post save value. - * @return true - */ - @PostMapping("/saveValue") - public Boolean saveValue(@RequestParam int value) { - LOG.info("Quickstart [{}] Service [{}:{}] is called. Mock save value = [{}].", appName, ip, port, value); - return true; - } - - /** - * Get path echo of callee. - * @return information of callee - */ - @GetMapping("/path/echo/{param}") - public String pathEcho(@PathVariable String param) { - LOG.info("Quickstart [{}] Service [{}:{}] is called. param = [{}].", appName, ip, port, param); - return String.format("Quickstart [%s] Service [%s:%s] is called. datasource = [%s].", appName, ip, port, param); - } - - /** - * Get metadata in HTTP header. - * - * @param metadataStr metadata string - * @return metadata in HTTP header - * @throws UnsupportedEncodingException encoding exception - */ - @RequestMapping("/echo") - public String echoHeader(@RequestHeader(MetadataConstant.HeaderName.CUSTOM_METADATA) String metadataStr) - throws UnsupportedEncodingException { - LOG.info(URLDecoder.decode(metadataStr, UTF_8)); - metadataStr = URLDecoder.decode(metadataStr, UTF_8); - return metadataStr; - } - - /** - * Check circuit break. - * - * @return circuit break info - */ - @GetMapping("/circuitBreak") - public String circuitBreak() { - LOG.info("Quickstart Callee Service [{}:{}] is called right.", ip, port); - return String.format("Quickstart Callee Service [%s:%s] is called right.", ip, port); - } - - @GetMapping("/faultDetect") - public String health() { - LOG.info("Quickstart Callee Service [{}:{}] is detected right.", ip, port); - return String.format("Quickstart Callee Service [%s:%s] is detected right.", ip, port); - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeServiceA.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeServiceA.java deleted file mode 100644 index fb00d56e..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeServiceA.java +++ /dev/null @@ -1,34 +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.quickstart.callee; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Quickstart callee application. - * - * @author Haotian Zhang - */ -@SpringBootApplication -public class QuickstartCalleeServiceA { - - public static void main(String[] args) { - SpringApplication.run(QuickstartCalleeServiceA.class, args); - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/config/CustomConfigChangeListener.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/config/CustomConfigChangeListener.java deleted file mode 100644 index bd2b1295..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/config/CustomConfigChangeListener.java +++ /dev/null @@ -1,51 +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.quickstart.callee.config; - -import java.util.Set; - -import com.tencent.cloud.polaris.config.annotation.PolarisConfigKVFileChangeListener; -import com.tencent.cloud.polaris.config.listener.ConfigChangeEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.stereotype.Component; - -/** - * Custom Config Listener Example . - * - * @author Haotian Zhang - */ -@Component -public final class CustomConfigChangeListener { - - private static final Logger LOG = LoggerFactory.getLogger(CustomConfigChangeListener.class); - - /** - * PolarisConfigKVFileChangeListener Example . - * @param event instance of {@link ConfigChangeEvent} - */ - @PolarisConfigKVFileChangeListener(interestedKeyPrefixes = "appName") - public void onChange(ConfigChangeEvent event) { - Set changedKeys = event.changedKeys(); - - for (String changedKey : changedKeys) { - LOG.info("{} = {}", changedKey, event.getChange(changedKey)); - } - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/config/DataSourceProperties.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/config/DataSourceProperties.java deleted file mode 100644 index 00ac6717..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/config/DataSourceProperties.java +++ /dev/null @@ -1,65 +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.quickstart.callee.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - * Example for ConfigurationProperties. - * @author lepdou 2022-09-08 - */ -@Component -@ConfigurationProperties("datasource") -public class DataSourceProperties { - - private String jdbcUrl; - private String username; - private String password; - - public String getJdbcUrl() { - return jdbcUrl; - } - - public void setJdbcUrl(String jdbcUrl) { - this.jdbcUrl = jdbcUrl; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - @Override - public String toString() { - return "jdbcUrl='" + jdbcUrl + '\'' + - ", username='" + username + '\'' + - ", password='" + password + '\''; - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/ratelimit/CustomLabelResolver.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/ratelimit/CustomLabelResolver.java deleted file mode 100644 index cdd4b97e..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/java/com/tencent/cloud/quickstart/callee/ratelimit/CustomLabelResolver.java +++ /dev/null @@ -1,63 +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.quickstart.callee.ratelimit; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLabelServletResolver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -/** - * resolver custom label from request. - * - * @author lepdou 2022-03-31 - */ -@Component -public class CustomLabelResolver implements PolarisRateLimiterLabelServletResolver { - private static final Logger LOG = LoggerFactory.getLogger(CustomLabelResolver.class); - - @Value("${label.key-value:}") - private String[] keyValues; - - @Override - public Map resolve(HttpServletRequest request) { - // rate limit by some request params. such as query params, headers .. - - return getLabels(keyValues); - } - - private Map getLabels(String[] keyValues) { - Map labels = new HashMap<>(); - for (String kv : keyValues) { - String key = kv.substring(0, kv.indexOf(":")); - String value = kv.substring(kv.indexOf(":") + 1); - labels.put(key, value); - } - - LOG.info("Current labels:{}", labels); - return labels; - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/resources/bootstrap.yml b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/resources/bootstrap.yml deleted file mode 100644 index ad3c8262..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,48 +0,0 @@ -server: - port: 48083 -spring: - application: - name: QuickstartCalleeService - cloud: - polaris: - address: grpc://127.0.0.1:8091 - namespace: default - enabled: true - discovery: - enabled: true - register: true - contract: - exposure: true - report: - enabled: false - stat: - enabled: true - port: 28083 - # pushgateway: - # enabled: true - # address: 127.0.0.1:9091 - config: - address: grpc://127.0.0.1:8093 - auto-refresh: true - groups: - - name: ${spring.application.name} - files: [ "config/callee.properties" ] - ratelimit: - enabled: true - rejectRequestTipsFilePath: reject-tips.html - maxQueuingTime: 500 - tencent: - metadata: - content: - label1: value1 - region: huanan -management: - endpoints: - web: - exposure: - include: - - polaris-discovery - - polaris-ratelimit - - polaris-config -label: - key-value: user:zhangsan diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/resources/reject-tips.html b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/resources/reject-tips.html deleted file mode 100644 index 693ef256..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-a/src/main/resources/reject-tips.html +++ /dev/null @@ -1,5 +0,0 @@ -

- - Custom reject content. - -

diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/Dockerfile b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/Dockerfile deleted file mode 100644 index e4da5f69..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -FROM alpine:3.19.1 - -ARG file_name -ARG java_version - -COPY ./target/${file_name} /app/main.jar - -WORKDIR /app - -RUN sed -i 's!http://dl-cdn.alpinelinux.org/!https://mirrors.tencent.com/!g' /etc/apk/repositories - -RUN set -eux && \ - apk add openjdk${java_version} && \ - apk add bind-tools && \ - apk add busybox-extras && \ - apk add findutils && \ - apk add tcpdump && \ - apk add tzdata && \ - apk add curl && \ - apk add bash && \ - cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ - echo "Asia/Shanghai" > /etc/timezone && \ - date - -RUN chmod 777 /app/ - -RUN ls -la /app/ - -ENTRYPOINT ["java", "-jar", "/app/main.jar"] \ No newline at end of file diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/deployment.yaml b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/deployment.yaml deleted file mode 100644 index 1a2236e7..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/deployment.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: hoxton-callee-1 - name: hoxton-callee-1 - namespace: default -spec: - replicas: 1 - selector: - matchLabels: - app: hoxton-callee-1 - template: - metadata: - labels: - app: hoxton-callee-1 - annotations: - polarismesh.cn/javaagent: "true" - polarismesh.cn/javaagentVersion: "1.7.0-RC2" - polarismesh.cn/javaagentFrameworkName: "spring-cloud" - polarismesh.cn/javaagentFrameworkVersion: "hoxton" - spec: - containers: - - image: polarismesh/polaris-javaagent-demo-sc-quickstart-hoxton-callee-1:1.7.0-java8 - imagePullPolicy: Always - name: provider - resources: - limits: - cpu: "500m" - memory: 1000Mi - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - command: - - /bin/bash - - -c - - cd /app && java -Dserver.port=48084 -jar main.jar - lifecycle: - preStop: - exec: - command: ["curl","-X","PUT","http://127.0.0.1:28080/offline","&&","sleep","30"] - readinessProbe: - httpGet: - path: /online - port: 28080 - initialDelaySeconds: 3 - periodSeconds: 3 - restartPolicy: Always \ No newline at end of file diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/pom.xml b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/pom.xml deleted file mode 100644 index aa63288c..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/pom.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - 4.0.0 - - - org.springframework.boot - spring-boot-starter-parent - 2.3.7.RELEASE - - - - - Hoxton.SR12 - 1.14.0-Hoxton.SR12-SNAPSHOT - 2.3.12.RELEASE - 1.7.30 - - - com.tencent.polaris - callee-service-b - jar - 1.7.0 - Quickstart Callee Service B - - - - - com.tencent.cloud - spring-cloud-tencent-dependencies - 1.14.0-Hoxton.SR12-SNAPSHOT - pom - import - - - com.alibaba.cloud - spring-cloud-alibaba-dependencies - 2.2.1.RELEASE - pom - import - - - - org.springframework.cloud - spring-cloud-dependencies - Hoxton.SR12 - pom - import - - - - - - - com.tencent.cloud - spring-cloud-starter-tencent-all - 1.14.0-Hoxton.SR12-SNAPSHOT - - - - org.springframework.boot - spring-boot-starter-webflux - - - - org.springframework.boot - spring-boot-starter-actuator - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - org.apache.maven.plugins - maven-source-plugin - 3.2.0 - - - attach-sources - - jar - - - - - - - diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/CustomMetadata.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/CustomMetadata.java deleted file mode 100644 index 8257f2cd..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/CustomMetadata.java +++ /dev/null @@ -1,46 +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.quickstart.callee; - -import java.util.HashMap; -import java.util.Map; - -import com.tencent.cloud.common.spi.InstanceMetadataProvider; - -import org.springframework.stereotype.Component; - -/** - * Custom metadata for instance. - * - * @author Haotian Zhang - */ -@Component -public class CustomMetadata implements InstanceMetadataProvider { - - @Override - public Map getMetadata() { - Map metadata = new HashMap<>(); - metadata.put("k1", "v2"); - return metadata; - } - - @Override - public String getZone() { - return "shenzhen-zone-2"; - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java deleted file mode 100644 index d4de94f3..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeController.java +++ /dev/null @@ -1,162 +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.quickstart.callee; - -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; - -import com.tencent.cloud.common.constant.MetadataConstant; -import com.tencent.cloud.quickstart.callee.config.DataSourceProperties; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import static com.tencent.cloud.common.constant.ContextConstant.UTF_8; - -/** - * Quickstart callee controller. - * - * @author Haotian Zhang - */ -@RestController -@RequestMapping("/quickstart/callee") -public class QuickstartCalleeController { - - private static final Logger LOG = LoggerFactory.getLogger(QuickstartCalleeController.class); - - @Value("${server.port:0}") - private int port; - - @Value("${spring.cloud.client.ip-address:127.0.0.1}") - private String ip; - - @Value("${appName:${spring.application.name}}") - private String appName; - - @Autowired - private DataSourceProperties dataSourceProperties; - private boolean ifBadGateway = true; - private boolean ifDelay = true; - - /** - * Get sum of two value. - * @param value1 value 1 - * @param value2 value 2 - * @return sum - */ - @GetMapping("/sum") - public String sum(@RequestParam int value1, @RequestParam int value2) { - LOG.info("Quickstart Callee Service [{}:{}] is called and sum is [{}].", ip, port, value1 + value2); - return String.format("Quickstart Callee Service [%s:%s] is called and sum is [%s].", ip, port, value1 + value2); - } - - /** - * Get information of callee. - * @return information of callee - */ - @GetMapping("/info") - public String info() { - LOG.info("Quickstart [{}] Service [{}:{}] is called. datasource = [{}].", appName, ip, port, dataSourceProperties); - return String.format("Quickstart [%s] Service [%s:%s] is called. datasource = [%s].", appName, ip, port, dataSourceProperties); - } - - /** - * Get metadata in HTTP header. - * - * @param metadataStr metadata string - * @return metadata in HTTP header - * @throws UnsupportedEncodingException encoding exception - */ - @RequestMapping("/echo") - public String echoHeader(@RequestHeader(MetadataConstant.HeaderName.CUSTOM_METADATA) String metadataStr) - throws UnsupportedEncodingException { - LOG.info(URLDecoder.decode(metadataStr, UTF_8)); - metadataStr = URLDecoder.decode(metadataStr, UTF_8); - return metadataStr; - } - - /** - * Check circuit break. - * - * @return circuit break info - */ - @GetMapping("/circuitBreak") - public ResponseEntity circuitBreak() throws InterruptedException { - if (ifBadGateway) { - LOG.info("Quickstart Callee Service [{}:{}] is called wrong.", ip, port); - return new ResponseEntity<>("failed for call quickstart callee service.", HttpStatus.BAD_GATEWAY); - } - if (ifDelay) { - Thread.sleep(200); - LOG.info("Quickstart Callee Service [{}:{}] is called slow.", ip, port); - return new ResponseEntity<>(String.format("Quickstart Callee Service [%s:%s] is called slow.", ip, port), HttpStatus.OK); - } - LOG.info("Quickstart Callee Service [{}:{}] is called right.", ip, port); - return new ResponseEntity<>(String.format("Quickstart Callee Service [%s:%s] is called right.", ip, port), HttpStatus.OK); - } - - @GetMapping("/setBadGateway") - public String setBadGateway(@RequestParam boolean param) { - this.ifBadGateway = param; - if (param) { - LOG.info("info is set to return HttpStatus.BAD_GATEWAY."); - return "info is set to return HttpStatus.BAD_GATEWAY."; - } - else { - LOG.info("info is set to return HttpStatus.OK."); - return "info is set to return HttpStatus.OK."; - } - } - - @GetMapping("/setDelay") - public String setDelay(@RequestParam boolean param) { - this.ifDelay = param; - if (param) { - LOG.info("info is set to delay 200ms."); - return "info is set to delay 200ms."; - } - else { - LOG.info("info is set to no delay."); - return "info is set to no delay."; - } - } - - @GetMapping("/faultDetect") - public ResponseEntity health() throws InterruptedException { - if (ifBadGateway) { - LOG.info("Quickstart Callee Service [{}:{}] is detected wrong.", ip, port); - return new ResponseEntity<>(String.format("Quickstart Callee Service [%s:%s] is detected wrong.", ip, port), HttpStatus.BAD_GATEWAY); - } - if (ifDelay) { - Thread.sleep(200); - LOG.info("Quickstart Callee Service [{}:{}] is detected slow.", ip, port); - return new ResponseEntity<>(String.format("Quickstart Callee Service [%s:%s] is detected slow.", ip, port), HttpStatus.OK); - } - LOG.info("Quickstart Callee Service [{}:{}] is detected right.", ip, port); - return new ResponseEntity<>(String.format("Quickstart Callee Service [%s:%s] is detected right.", ip, port), HttpStatus.OK); - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeServiceB.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeServiceB.java deleted file mode 100644 index c2740e40..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/QuickstartCalleeServiceB.java +++ /dev/null @@ -1,34 +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.quickstart.callee; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Quickstart callee application. - * - * @author Haotian Zhang - */ -@SpringBootApplication -public class QuickstartCalleeServiceB { - - public static void main(String[] args) { - SpringApplication.run(QuickstartCalleeServiceB.class, args); - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/config/CustomConfigChangeListener.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/config/CustomConfigChangeListener.java deleted file mode 100644 index bd2b1295..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/config/CustomConfigChangeListener.java +++ /dev/null @@ -1,51 +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.quickstart.callee.config; - -import java.util.Set; - -import com.tencent.cloud.polaris.config.annotation.PolarisConfigKVFileChangeListener; -import com.tencent.cloud.polaris.config.listener.ConfigChangeEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.stereotype.Component; - -/** - * Custom Config Listener Example . - * - * @author Haotian Zhang - */ -@Component -public final class CustomConfigChangeListener { - - private static final Logger LOG = LoggerFactory.getLogger(CustomConfigChangeListener.class); - - /** - * PolarisConfigKVFileChangeListener Example . - * @param event instance of {@link ConfigChangeEvent} - */ - @PolarisConfigKVFileChangeListener(interestedKeyPrefixes = "appName") - public void onChange(ConfigChangeEvent event) { - Set changedKeys = event.changedKeys(); - - for (String changedKey : changedKeys) { - LOG.info("{} = {}", changedKey, event.getChange(changedKey)); - } - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/config/DataSourceProperties.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/config/DataSourceProperties.java deleted file mode 100644 index 00ac6717..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/config/DataSourceProperties.java +++ /dev/null @@ -1,65 +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.quickstart.callee.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - * Example for ConfigurationProperties. - * @author lepdou 2022-09-08 - */ -@Component -@ConfigurationProperties("datasource") -public class DataSourceProperties { - - private String jdbcUrl; - private String username; - private String password; - - public String getJdbcUrl() { - return jdbcUrl; - } - - public void setJdbcUrl(String jdbcUrl) { - this.jdbcUrl = jdbcUrl; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - @Override - public String toString() { - return "jdbcUrl='" + jdbcUrl + '\'' + - ", username='" + username + '\'' + - ", password='" + password + '\''; - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/ratelimit/CustomLabelResolverReactive.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/ratelimit/CustomLabelResolverReactive.java deleted file mode 100644 index 4a270fc6..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/ratelimit/CustomLabelResolverReactive.java +++ /dev/null @@ -1,60 +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.quickstart.callee.ratelimit; - -import java.util.HashMap; -import java.util.Map; - -import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLabelReactiveResolver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; -import org.springframework.web.server.ServerWebExchange; - -/** - * resolver custom label from request. - * - * @author sean yu - */ -@Component -public class CustomLabelResolverReactive implements PolarisRateLimiterLabelReactiveResolver { - private static final Logger LOG = LoggerFactory.getLogger(CustomLabelResolverReactive.class); - - @Value("${label.key-value:}") - private String[] keyValues; - - @Override - public Map resolve(ServerWebExchange exchange) { - // rate limit by some request params. such as query params, headers .. - return getLabels(keyValues); - } - - private Map getLabels(String[] keyValues) { - Map labels = new HashMap<>(); - for (String kv : keyValues) { - String key = kv.substring(0, kv.indexOf(":")); - String value = kv.substring(kv.indexOf(":") + 1); - labels.put(key, value); - } - - LOG.info("Current labels:{}", labels); - return labels; - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/ratelimit/JsonPolarisRateLimiterLimitedFallback.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/ratelimit/JsonPolarisRateLimiterLimitedFallback.java deleted file mode 100644 index 9c871287..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/java/com/tencent/cloud/quickstart/callee/ratelimit/JsonPolarisRateLimiterLimitedFallback.java +++ /dev/null @@ -1,41 +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.quickstart.callee.ratelimit; - -import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLimitedFallback; - -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; - -/** - * JsonPolarisRateLimiterLimitedFallback. - * - * @author Lingxiao.Wu - */ -@Component -public class JsonPolarisRateLimiterLimitedFallback implements PolarisRateLimiterLimitedFallback { - @Override - public MediaType mediaType() { - return MediaType.APPLICATION_JSON; - } - - @Override - public String rejectTips() { - return "{\"success\":false,\"code\":429,\"msg\":\"RejectRequestTips提示消息\",\"timestamp\":1673415310479}"; - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/resources/bootstrap.yml b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/resources/bootstrap.yml deleted file mode 100644 index 381eb216..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/callee-service-b/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,47 +0,0 @@ -server: - port: 48084 -spring: - application: - name: QuickstartCalleeService - cloud: - polaris: - address: grpc://127.0.0.1:8091 - namespace: default - enabled: true - discovery: - enabled: true - register: true - contract: - exposure: true - report: - enabled: false - stat: - enabled: true - port: 28084 - # pushgateway: - # enabled: true - # address: 127.0.0.1:9091 - config: - address: grpc://127.0.0.1:8093 - auto-refresh: true - groups: - - name: ${spring.application.name} - files: [ "config/callee.properties" ] - ratelimit: - enabled: true - maxQueuingTime: 500 - tencent: - metadata: - content: - label1: value2 - region: huanan -management: - endpoints: - web: - exposure: - include: - - polaris-discovery - - polaris-ratelimit - - polaris-config -label: - key-value: user2:lisi diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/Dockerfile b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/Dockerfile deleted file mode 100644 index e4da5f69..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -FROM alpine:3.19.1 - -ARG file_name -ARG java_version - -COPY ./target/${file_name} /app/main.jar - -WORKDIR /app - -RUN sed -i 's!http://dl-cdn.alpinelinux.org/!https://mirrors.tencent.com/!g' /etc/apk/repositories - -RUN set -eux && \ - apk add openjdk${java_version} && \ - apk add bind-tools && \ - apk add busybox-extras && \ - apk add findutils && \ - apk add tcpdump && \ - apk add tzdata && \ - apk add curl && \ - apk add bash && \ - cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ - echo "Asia/Shanghai" > /etc/timezone && \ - date - -RUN chmod 777 /app/ - -RUN ls -la /app/ - -ENTRYPOINT ["java", "-jar", "/app/main.jar"] \ No newline at end of file diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/deployment.yaml b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/deployment.yaml deleted file mode 100644 index 4f0d28db..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/deployment.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: hoxton-caller - name: hoxton-caller - namespace: default -spec: - replicas: 1 - selector: - matchLabels: - app: hoxton-caller - template: - metadata: - labels: - app: hoxton-caller - annotations: - polarismesh.cn/javaagent: "true" - polarismesh.cn/javaagentVersion: "1.7.0-RC2" - polarismesh.cn/javaagentFrameworkName: "spring-cloud" - polarismesh.cn/javaagentFrameworkVersion: "hoxton" - spec: - containers: - - image: polarismesh/polaris-javaagent-demo-sc-quickstart-hoxton-caller:1.7.0-java8 - imagePullPolicy: Always - name: consumer - resources: - limits: - cpu: "500m" - memory: 1000Mi - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - command: - - /bin/bash - - -c - - cd /app && java -Dserver.port=48082 -jar main.jar - lifecycle: - preStop: - exec: - command: ["curl","-X","PUT","http://127.0.0.1:28080/offline","&&","sleep","30"] - readinessProbe: - httpGet: - path: /online - port: 28080 - initialDelaySeconds: 3 - periodSeconds: 3 - restartPolicy: Always \ No newline at end of file diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/pom.xml b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/pom.xml deleted file mode 100644 index ea379aaf..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/pom.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - 4.0.0 - - - org.springframework.boot - spring-boot-starter-parent - 2.3.7.RELEASE - - - - jar - 1.7.0 - caller-service - Quickstart Caller Service - - - Hoxton.SR12 - 1.14.0-Hoxton.SR12-SNAPSHOT - 2.3.12.RELEASE - 1.7.30 - - - - - - com.tencent.cloud - spring-cloud-tencent-dependencies - 1.14.0-Hoxton.SR12-SNAPSHOT - pom - import - - - com.alibaba.cloud - spring-cloud-alibaba-dependencies - 2.2.1.RELEASE - pom - import - - - - org.springframework.cloud - spring-cloud-dependencies - Hoxton.SR12 - pom - import - - - - - - - com.tencent.cloud - spring-cloud-starter-tencent-all - 1.14.0-Hoxton.SR12-SNAPSHOT - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-webflux - - - - org.springframework.cloud - spring-cloud-starter-openfeign - - - - org.springframework.boot - spring-boot-starter-actuator - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - org.apache.maven.plugins - maven-source-plugin - 3.2.0 - - - attach-sources - - jar - - - - - - - diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/CustomMetadataProvider.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/CustomMetadataProvider.java deleted file mode 100644 index 94829657..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/CustomMetadataProvider.java +++ /dev/null @@ -1,34 +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.quickstart.caller; - -import com.tencent.cloud.common.spi.InstanceMetadataProvider; - -import org.springframework.stereotype.Component; - -/** - *@author lepdou 2022-06-29 - */ -@Component -public class CustomMetadataProvider implements InstanceMetadataProvider { - - @Override - public String getRegion() { - return "huadong"; - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCalleeService.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCalleeService.java deleted file mode 100644 index f210fb54..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCalleeService.java +++ /dev/null @@ -1,41 +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.quickstart.caller; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -/** - * Quickstart callee feign client. - * - * @author Haotian Zhang - */ -@FeignClient(value = "QuickstartCalleeService", fallback = QuickstartCalleeServiceFallback.class) -public interface QuickstartCalleeService { - - /** - * Get sum of two value. - * - * @param value1 value 1 - * @param value2 value 2 - * @return sum - */ - @GetMapping("/quickstart/callee/sum") - String sum(@RequestParam("value1") int value1, @RequestParam("value2") int value2); -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCalleeServiceFallback.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCalleeServiceFallback.java deleted file mode 100644 index 8f680a8d..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCalleeServiceFallback.java +++ /dev/null @@ -1,34 +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.quickstart.caller; - -import org.springframework.stereotype.Component; - -/** - * Quickstart callee feign client fallback. - * - * @author Haotian Zhang - */ -@Component -public class QuickstartCalleeServiceFallback implements QuickstartCalleeService { - - @Override - public String sum(int value1, int value2) { - return "sum is 0."; - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCallerApplication.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCallerApplication.java deleted file mode 100644 index 26fcb7ee..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCallerApplication.java +++ /dev/null @@ -1,85 +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.quickstart.caller; - -import com.tencent.cloud.polaris.circuitbreaker.resttemplate.PolarisCircuitBreaker; -import com.tencent.cloud.quickstart.caller.circuitbreaker.CustomFallback; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.client.loadbalancer.LoadBalanced; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Bean; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.util.DefaultUriBuilderFactory; - -/** - * Quickstart caller application. - * - * @author Haotian Zhang - */ -@SpringBootApplication -@EnableFeignClients -public class QuickstartCallerApplication { - - public static void main(String[] args) { - SpringApplication.run(QuickstartCallerApplication.class, args); - } - - @Bean - @LoadBalanced - public RestTemplate restTemplate() { - return new RestTemplate(); - } - - @Bean - @LoadBalanced - public RestTemplate defaultRestTemplate() { - DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory("http://QuickstartCalleeService"); - RestTemplate restTemplate = new RestTemplate(); - restTemplate.setUriTemplateHandler(uriBuilderFactory); - return restTemplate; - } - - @Bean - @LoadBalanced - @PolarisCircuitBreaker - public RestTemplate restTemplateFallbackFromPolaris() { - DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory("http://QuickstartCalleeService"); - RestTemplate restTemplate = new RestTemplate(); - restTemplate.setUriTemplateHandler(uriBuilderFactory); - return restTemplate; - } - - @Bean - @LoadBalanced - @PolarisCircuitBreaker(fallbackClass = CustomFallback.class) - public RestTemplate restTemplateFallbackFromCode() { - DefaultUriBuilderFactory uriBuilderFactory = new DefaultUriBuilderFactory("http://QuickstartCalleeService"); - RestTemplate restTemplate = new RestTemplate(); - restTemplate.setUriTemplateHandler(uriBuilderFactory); - return restTemplate; - } - - @LoadBalanced - @Bean - WebClient.Builder webClientBuilder() { - return WebClient.builder().baseUrl("http://QuickstartCalleeService"); - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCallerController.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCallerController.java deleted file mode 100644 index ec939dd1..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/QuickstartCallerController.java +++ /dev/null @@ -1,182 +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.quickstart.caller; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicInteger; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import reactor.core.publisher.Mono; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -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; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.RestClientException; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.reactive.function.client.WebClient; - -/** - * Quickstart caller controller. - * - * @author Haotian Zhang - */ -@RestController -@RequestMapping("/quickstart/caller") -public class QuickstartCallerController { - - private static final Logger LOG = LoggerFactory.getLogger(QuickstartCallerController.class); - - @Autowired - private RestTemplate restTemplate; - - @Autowired - private QuickstartCalleeService quickstartCalleeService; - - @Autowired - private WebClient.Builder webClientBuilder; - - /** - * Get sum of two value. - * @param value1 value 1 - * @param value2 value 2 - * @return sum - */ - @GetMapping("/feign") - public String feign(@RequestParam int value1, @RequestParam int value2) { - return quickstartCalleeService.sum(value1, value2); - } - - /** - * Get information of callee. - * @return information of callee - */ - @GetMapping("/rest") - public String rest() { - return restTemplate.getForObject("http://QuickstartCalleeService/quickstart/callee/info", String.class); - } - - /** - * Get information of callee. - * @return information of callee - */ - @GetMapping("/webclient") - public Mono webclient() { - return webClientBuilder - .build() - .get() - .uri("/quickstart/callee/echo") - .retrieve() - .bodyToMono(String.class); - } - - /** - * Get information 30 times per 1 second. - * - * @return result of 30 calls. - * @throws InterruptedException exception - */ - @GetMapping("/ratelimit") - public String invokeInfo() throws InterruptedException { - StringBuffer builder = new StringBuffer(); - CountDownLatch count = new CountDownLatch(30); - AtomicInteger index = new AtomicInteger(0); - for (int i = 0; i < 30; i++) { - new Thread(() -> { - try { - ResponseEntity entity = restTemplate.getForEntity( - "http://QuickstartCalleeService/quickstart/callee/info", String.class); - builder.append(entity.getBody() + "\n"); - } - catch (RestClientException e) { - if (e instanceof HttpClientErrorException.TooManyRequests) { - builder.append("TooManyRequests " + index.incrementAndGet() + "\n"); - } - else { - throw e; - } - } - count.countDown(); - }).start(); - } - count.await(); - return builder.toString(); - } - - /** - * Get information with unirate. - * - * @return information - */ - @GetMapping("/unirate") - public String unirate() throws InterruptedException { - StringBuffer builder = new StringBuffer(); - CountDownLatch count = new CountDownLatch(30); - AtomicInteger index = new AtomicInteger(0); - long currentTimestamp = System.currentTimeMillis(); - for (int i = 0; i < 30; i++) { - new Thread(() -> { - try { - long startTimestamp = System.currentTimeMillis(); - ResponseEntity entity = restTemplate.getForEntity( - "http://QuickstartCalleeService/quickstart/callee/info", String.class); - long endTimestamp = System.currentTimeMillis(); - builder.append("Start timestamp:" + startTimestamp + ". End timestamp: " + endTimestamp + - ". diff interval:" + (endTimestamp - startTimestamp) + "\n"); - } - catch (RestClientException e) { - if (e instanceof HttpClientErrorException.TooManyRequests) { - builder.append("TooManyRequests " + index.incrementAndGet() + "\n"); - } - else { - throw e; - } - } - count.countDown(); - }).start(); - } - count.await(); - long lastTimestamp = System.currentTimeMillis(); - builder.append("Unirate request from " + currentTimestamp + " to " + lastTimestamp + " with interval " + (lastTimestamp - currentTimestamp) + "ms."); - - return builder.toString(); - } - - /** - * Get information of caller. - * @return information of caller - */ - @GetMapping("/info") - public String info() { - LOG.info("Quickstart Callee Service is called."); - return "Quickstart Callee Service is called."; - } - - /** - * health check. - * @return health check info - */ - @GetMapping("/healthCheck") - public String healthCheck() { - return "ok"; - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerController.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerController.java deleted file mode 100644 index 4d902aaa..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerController.java +++ /dev/null @@ -1,136 +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.quickstart.caller.circuitbreaker; - -import reactor.core.publisher.Mono; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; -import org.springframework.cloud.client.circuitbreaker.ReactiveCircuitBreakerFactory; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.reactive.function.client.WebClient; - -/** - * Controller for circuit breaker. - * - * @author Haotian Zhang - */ -@RestController -@RequestMapping("/quickstart/caller/circuitBreak") -public class CircuitBreakerController { - - @Autowired - private CircuitBreakerQuickstartCalleeService circuitBreakerQuickstartCalleeService; - - @Autowired - private CircuitBreakerQuickstartCalleeServiceWithFallback circuitBreakerQuickstartCalleeServiceWithFallback; - - @Autowired - @Qualifier("defaultRestTemplate") - private RestTemplate defaultRestTemplate; - - @Autowired - @Qualifier("restTemplateFallbackFromPolaris") - private RestTemplate restTemplateFallbackFromPolaris; - - @Autowired - @Qualifier("restTemplateFallbackFromCode") - private RestTemplate restTemplateFallbackFromCode; - - @Autowired - private CircuitBreakerFactory circuitBreakerFactory; - - @Autowired - private ReactiveCircuitBreakerFactory reactiveCircuitBreakerFactory; - - @Autowired - private WebClient.Builder webClientBuilder; - - /** - * Feign circuit breaker with fallback from Polaris. - * @return circuit breaker information of callee - */ - @GetMapping("/feign/fallbackFromPolaris") - public String circuitBreakFeignFallbackFromPolaris() { - return circuitBreakerQuickstartCalleeService.circuitBreak(); - } - - /** - * Feign circuit breaker with fallback from Polaris. - * @return circuit breaker information of callee - */ - @GetMapping("/feign/fallbackFromCode") - public String circuitBreakFeignFallbackFromCode() { - return circuitBreakerQuickstartCalleeServiceWithFallback.circuitBreak(); - } - - /** - * RestTemplate circuit breaker. - * @return circuit breaker information of callee - */ - @GetMapping("/rest") - public String circuitBreakRestTemplate() { - return circuitBreakerFactory - .create("QuickstartCalleeService#/quickstart/callee/circuitBreak") - .run(() -> defaultRestTemplate.getForObject("/quickstart/callee/circuitBreak", String.class), - throwable -> "trigger the refuse for service callee." - ); - } - - /** - * RestTemplate circuit breaker with fallback from Polaris. - * @return circuit breaker information of callee - */ - @GetMapping("/rest/fallbackFromPolaris") - public ResponseEntity circuitBreakRestTemplateFallbackFromPolaris() { - return restTemplateFallbackFromPolaris.getForEntity("/quickstart/callee/circuitBreak", String.class); - } - - /** - * RestTemplate circuit breaker with fallback from code. - * @return circuit breaker information of callee - */ - @GetMapping("/rest/fallbackFromCode") - public ResponseEntity circuitBreakRestTemplateFallbackFromCode() { - return restTemplateFallbackFromCode.getForEntity("/quickstart/callee/circuitBreak", String.class); - } - - /** - * Get information of callee. - * @return information of callee - */ - @GetMapping("/webclient") - public Mono webclient() { - return webClientBuilder - .build() - .get() - .uri("/quickstart/callee/circuitBreak") - .retrieve() - .bodyToMono(String.class) - .transform(it -> - reactiveCircuitBreakerFactory - .create("QuickstartCalleeService#/quickstart/callee/circuitBreak") - .run(it, throwable -> Mono.just("fallback: trigger the refuse for service callee")) - ); - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerQuickstartCalleeService.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerQuickstartCalleeService.java deleted file mode 100644 index 64821b9a..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerQuickstartCalleeService.java +++ /dev/null @@ -1,38 +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.quickstart.caller.circuitbreaker; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; - -/** - * Circuit breaker example callee provider. - * - * @author sean yu - */ -@FeignClient(name = "QuickstartCalleeService", contextId = "fallback-from-polaris") -public interface CircuitBreakerQuickstartCalleeService { - - /** - * Check circuit break. - * - * @return circuit break info - */ - @GetMapping("/quickstart/callee/circuitBreak") - String circuitBreak(); -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerQuickstartCalleeServiceFallback.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerQuickstartCalleeServiceFallback.java deleted file mode 100644 index 06a2df36..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerQuickstartCalleeServiceFallback.java +++ /dev/null @@ -1,34 +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.quickstart.caller.circuitbreaker; - -import org.springframework.stereotype.Component; - -/** - * Circuit breaker example callee fallback. - * - * @author sean yu - */ -@Component -public class CircuitBreakerQuickstartCalleeServiceFallback implements CircuitBreakerQuickstartCalleeServiceWithFallback { - - @Override - public String circuitBreak() { - return "fallback: trigger the refuse for service callee."; - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerQuickstartCalleeServiceWithFallback.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerQuickstartCalleeServiceWithFallback.java deleted file mode 100644 index f71a7650..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CircuitBreakerQuickstartCalleeServiceWithFallback.java +++ /dev/null @@ -1,38 +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.quickstart.caller.circuitbreaker; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; - -/** - * CircuitBreakerQuickstartCalleeServiceWithFallback. - * - * @author sean yu - */ -@FeignClient(name = "QuickstartCalleeService", contextId = "fallback-from-code", fallback = CircuitBreakerQuickstartCalleeServiceFallback.class) -public interface CircuitBreakerQuickstartCalleeServiceWithFallback { - - /** - * Check circuit break. - * - * @return circuit break info - */ - @GetMapping("/quickstart/callee/circuitBreak") - String circuitBreak(); -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CustomFallback.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CustomFallback.java deleted file mode 100644 index 887d690d..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/circuitbreaker/CustomFallback.java +++ /dev/null @@ -1,43 +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.quickstart.caller.circuitbreaker; - -import java.util.HashMap; - -import com.tencent.cloud.polaris.circuitbreaker.resttemplate.PolarisCircuitBreakerFallback; -import com.tencent.cloud.polaris.circuitbreaker.resttemplate.PolarisCircuitBreakerHttpResponse; - -import org.springframework.stereotype.Component; - -/** - * CustomFallback. - * - * @author sean yu - */ -@Component -public class CustomFallback implements PolarisCircuitBreakerFallback { - @Override - public PolarisCircuitBreakerHttpResponse fallback() { - return new PolarisCircuitBreakerHttpResponse( - 200, - new HashMap() {{ - put("Content-Type", "application/json"); - }}, - "{\"msg\": \"this is a fallback class\"}"); - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/router/CustomRouterLabelResolver.java b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/router/CustomRouterLabelResolver.java deleted file mode 100644 index 18f3d0ca..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/java/com/tencent/cloud/quickstart/caller/router/CustomRouterLabelResolver.java +++ /dev/null @@ -1,54 +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.quickstart.caller.router; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import com.google.gson.Gson; -import com.tencent.cloud.polaris.router.spi.FeignRouterLabelResolver; -import feign.RequestTemplate; - -import org.springframework.stereotype.Component; - -/** - * - * Customize the business tag information obtained from the request - * - *@author lepdou 2022-05-12 - */ -@Component -public class CustomRouterLabelResolver implements FeignRouterLabelResolver { - private final Gson gson = new Gson(); - - @Override - public Map resolve(RequestTemplate requestTemplate, Set expressionLabelKeys) { - Map labels = new HashMap<>(); - - labels.put("label1", "value1"); - - return labels; - } - - @Override - public int getOrder() { - return 0; - } -} diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/resources/bootstrap.yml b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/resources/bootstrap.yml deleted file mode 100644 index cc2b878a..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/caller-service/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,46 +0,0 @@ -server: - port: 48082 -spring: - application: - name: QuickstartCallerService - cloud: - polaris: - address: grpc://127.0.0.1:8091 - namespace: default - enabled: true - discovery: - enabled: true - register: true - heartbeat: - enabled: true - health-check-url: /quickstart/caller/healthCheck - contract: - exposure: true - report: - enabled: false - circuitbreaker: - enabled: true - stat: - enabled: true - port: 28082 - # pushgateway: - # enabled: true - # address: 127.0.0.1:9091 - tencent: - rpc-enhancement: - enabled: true - reporter: - enabled: true - ignore-internal-server-error: true - series: server_error - statuses: gateway_timeout, bad_gateway, service_unavailable -feign: - hystrix: - enabled: true -management: - endpoints: - web: - exposure: - include: - - polaris-discovery - - polaris-circuit-breaker diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/pom.xml b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/pom.xml deleted file mode 100644 index edb20a8b..00000000 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/circuitbreaker-examples/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - 4.0.0 - - com.tencent.polaris - spring-cloud-hoxton-examples - ${revision} - ../pom.xml - - - - 17 - 17 - UTF-8 - - - circuitbreaker-examples - pom - - caller-service - callee-service-a - callee-service-b - - - \ No newline at end of file diff --git a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/pom.xml b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/pom.xml index 17680dcd..ade6f974 100644 --- a/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/pom.xml +++ b/polaris-agent-examples/spring-cloud-plugins-examples/spring-cloud-hoxton-examples/pom.xml @@ -17,7 +17,6 @@ quickstart-examples gray-release-examples - circuitbreaker-examples \ No newline at end of file