+ * @return method name
+ */
+ String fallbackMethod() default "";
+
+ /**
+ * Defines exceptions which should be ignored.
+ *
+ * @return exceptions to ignore
+ */
+ Class extends Throwable>[] ignoreExceptions() default {};
+
+ /**
+ * Defines exceptions which should be retried.
+ * Default is all exceptions.
+ *
+ * @return exceptions to wrap
+ */
+ Class extends Throwable>[] raisedExceptions() default {};
+
+ /**
+ * Defines the fault tolerance strategy, the default is fast fail strategy.
+ * @see FaultToleranceStrategy
+ */
+ FaultToleranceStrategy strategy() default FaultToleranceStrategy.FAIL_FAST;
+
+ /**
+ * Number of retries, only used under {@link FaultToleranceStrategy}.FAIL_OVER strategy. Default is 0.
+ */
+ int maxAttempts() default 0;
+
+ /**
+ * The parallelism of forking is only used under the {@link FaultToleranceStrategy}.FORKING strategy.
+ */
+ int parallelism() default 1;
+}
diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/com/tencent/cloud/plugin/faulttolerance/common/FallbackMethod.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/com/tencent/cloud/plugin/faulttolerance/common/FallbackMethod.java
new file mode 100644
index 000000000..84671502b
--- /dev/null
+++ b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/com/tencent/cloud/plugin/faulttolerance/common/FallbackMethod.java
@@ -0,0 +1,43 @@
+/*
+ * Tencent is pleased to support the open source community by making spring-cloud-tencent available.
+ *
+ * Copyright (C) 2021 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.plugin.faulttolerance.common;
+
+import java.lang.reflect.Method;
+
+/**
+ * Fallback method for fault-tolerance.
+ *
+ * @author zhixinzxliu
+ */
+public class FallbackMethod {
+
+ /**
+ * Absent fallback method.
+ */
+ public static final FallbackMethod ABSENT = new FallbackMethod(null);
+
+ private final Method method;
+
+ public FallbackMethod(Method method) {
+ this.method = method;
+ }
+
+ public Method getMethod() {
+ return method;
+ }
+}
diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/com/tencent/cloud/plugin/faulttolerance/config/FaultToleranceAutoConfiguration.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/com/tencent/cloud/plugin/faulttolerance/config/FaultToleranceAutoConfiguration.java
new file mode 100644
index 000000000..41246bcee
--- /dev/null
+++ b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/com/tencent/cloud/plugin/faulttolerance/config/FaultToleranceAutoConfiguration.java
@@ -0,0 +1,42 @@
+/*
+ * Tencent is pleased to support the open source community by making spring-cloud-tencent available.
+ *
+ * Copyright (C) 2021 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.plugin.faulttolerance.config;
+
+import com.tencent.cloud.plugin.faulttolerance.instrument.FaultToleranceAspect;
+
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Role;
+
+/**
+ * FaultTolerance Auto-Configuration.
+ *
+ * @author Haotian Zhang
+ */
+@Configuration(proxyBeanMethods = false)
+@Role(RootBeanDefinition.ROLE_INFRASTRUCTURE)
+public class FaultToleranceAutoConfiguration {
+
+ @Bean
+ @ConditionalOnMissingBean
+ public FaultToleranceAspect faultToleranceAspect() {
+ return new FaultToleranceAspect();
+ }
+}
diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/com/tencent/cloud/plugin/faulttolerance/instrument/FaultToleranceAspect.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/com/tencent/cloud/plugin/faulttolerance/instrument/FaultToleranceAspect.java
new file mode 100644
index 000000000..91803eba3
--- /dev/null
+++ b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/com/tencent/cloud/plugin/faulttolerance/instrument/FaultToleranceAspect.java
@@ -0,0 +1,248 @@
+/*
+ * Tencent is pleased to support the open source community by making spring-cloud-tencent available.
+ *
+ * Copyright (C) 2021 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.plugin.faulttolerance.instrument;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import com.tencent.cloud.plugin.faulttolerance.annotation.FaultTolerance;
+import com.tencent.cloud.plugin.faulttolerance.common.FallbackMethod;
+import com.tencent.cloud.plugin.faulttolerance.model.FaultToleranceStrategy;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.springframework.cloud.tsf.faulttolerance.annotation.TsfFaultTolerance;
+import org.springframework.cloud.tsf.faulttolerance.model.TsfFaultToleranceStragety;
+
+/**
+ * Fault tolerance.
+ *
+ * @author zhixinzxliu, Haotian Zhang
+ */
+@Aspect
+public class FaultToleranceAspect {
+
+ private static final Logger logger = LoggerFactory.getLogger(FaultToleranceAspect.class);
+
+ private final Map fallbackMethodMap = new ConcurrentHashMap<>();
+ private final ExecutorService executorService = Executors.newCachedThreadPool();
+
+ @Pointcut("@annotation(org.springframework.cloud.tsf.faulttolerance.annotation.TsfFaultTolerance)"
+ + " || @annotation(com.tencent.cloud.plugin.faulttolerance.annotation.FaultTolerance)")
+ public void faultToleranceAnnotationPointcut() {
+ }
+
+ @Around("faultToleranceAnnotationPointcut()")
+ public Object methodsAnnotatedWithFaultTolerance(final ProceedingJoinPoint joinPoint) throws Throwable {
+ MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+ FaultTolerance faultTolerance = signature.getMethod().getAnnotation(FaultTolerance.class);
+ TsfFaultTolerance tsfFaultTolerance = signature.getMethod().getAnnotation(TsfFaultTolerance.class);
+
+ Object result;
+ try {
+ // Invoke job in parallel. Whoever returns the result first will use it.
+ // The latter result will be ignored directly.
+ // If all exceptions occur, an exception will be thrown.
+ if (faultTolerance != null
+ && faultTolerance.strategy() == FaultToleranceStrategy.FORKING
+ && faultTolerance.parallelism() > 1) {
+ List> jobs = generateJobs(faultTolerance.parallelism(), joinPoint);
+ result = executorService.invokeAny(jobs);
+ }
+ else if (tsfFaultTolerance != null &&
+ tsfFaultTolerance.strategy() == TsfFaultToleranceStragety.FORKING &&
+ tsfFaultTolerance.parallelism() > 1) {
+ List> jobs = generateJobs(tsfFaultTolerance.parallelism(), joinPoint);
+ result = executorService.invokeAny(jobs);
+ }
+ else {
+ result = joinPoint.proceed();
+ }
+ }
+ catch (Throwable throwable) {
+ return execFaultToleranceLogic(joinPoint, faultTolerance, tsfFaultTolerance, throwable);
+ }
+
+ return result;
+ }
+
+ private Object execFaultToleranceLogic(ProceedingJoinPoint joinPoint, FaultTolerance faultTolerance, TsfFaultTolerance tsfFaultTolerance, Throwable throwable) throws Throwable {
+ if (!needExecuteFaultTolerance(faultTolerance, tsfFaultTolerance, throwable)) {
+ throw throwable;
+ }
+
+ // 重试逻辑
+ if ((faultTolerance != null && faultTolerance.strategy() == FaultToleranceStrategy.FAIL_OVER)
+ || (tsfFaultTolerance != null && tsfFaultTolerance.strategy() == TsfFaultToleranceStragety.FAIL_OVER)) {
+ int maxAttempts = faultTolerance != null ? faultTolerance.maxAttempts() : tsfFaultTolerance.maxAttempts();
+ while (maxAttempts > 0) {
+ try {
+ return joinPoint.proceed();
+ }
+ catch (Throwable throwable1) {
+ if (!needExecuteFaultTolerance(faultTolerance, tsfFaultTolerance, throwable1)) {
+ throw throwable1;
+ }
+
+ logger.error("The {} time retry error, will continue retry {} times.", maxAttempts, maxAttempts - 1, throwable1);
+ }
+ finally {
+ maxAttempts--;
+ }
+ }
+ }
+
+ MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+ Method method = signature.getMethod();
+ if (method == null) {
+ throw throwable;
+ }
+
+ FallbackMethod fallbackMethod = fallbackMethodMap.get(method);
+ if (fallbackMethod == null) {
+ fallbackMethod = resolveFallbackMethod(joinPoint);
+ fallbackMethodMap.putIfAbsent(method, fallbackMethod);
+ }
+ if (fallbackMethod.getMethod() != null) {
+ return fallbackMethod.getMethod().invoke(joinPoint.getTarget(), joinPoint.getArgs());
+ }
+
+ throw throwable;
+ }
+
+ private List> generateJobs(int parallelism, final ProceedingJoinPoint joinPoint) {
+ List> jobs = new ArrayList<>();
+
+ for (int i = 0; i < parallelism; i++) {
+ jobs.add(() -> {
+ try {
+ return joinPoint.proceed();
+ }
+ catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ });
+ }
+
+ return jobs;
+ }
+
+ /**
+ * 1. If the user sets ignoreExceptions and the current exception is a subclass of one of them,
+ * the fault-tolerant logic will not be executed.
+ * 2. If the user does not set ignoreExceptions or the current exception is not a subclass of ignoreExceptions
+ * and meets the following conditions, fault-tolerant logic will be executed:
+ * 2.1. If the user does not set raisedExceptions, fault tolerance logic will be executed.
+ * 2.2. The user has set raisedExceptions, and the current exception is a subclass of one of the raisedExceptions set by the user.
+ */
+ private boolean needExecuteFaultTolerance(FaultTolerance faultTolerance, TsfFaultTolerance tsfFaultTolerance, Throwable throwable) {
+ if (faultTolerance == null && tsfFaultTolerance == null) {
+ return false;
+ }
+ Class extends Throwable>[] ignoreExceptions = faultTolerance != null ? faultTolerance.ignoreExceptions() : null;
+ if (ignoreExceptions == null || ignoreExceptions.length == 0) {
+ ignoreExceptions = tsfFaultTolerance != null ? tsfFaultTolerance.ignoreExceptions() : null;
+ }
+ Class extends Throwable>[] raisedExceptions = faultTolerance != null ? faultTolerance.raisedExceptions() : null;
+ if (raisedExceptions == null || raisedExceptions.length == 0) {
+ raisedExceptions = tsfFaultTolerance != null ? tsfFaultTolerance.raisedExceptions() : null;
+ }
+
+ try {
+
+ if (ignoreExceptions != null) {
+ for (Class extends Throwable> ignoreException : ignoreExceptions) {
+ if (ignoreException.isAssignableFrom(throwable.getClass())) {
+ logger.debug("The exception {} is ignored.", throwable.getClass().getName());
+ return false;
+ }
+ }
+ }
+
+ if (raisedExceptions == null || raisedExceptions.length == 0) {
+ return true;
+ }
+ else {
+ for (Class extends Throwable> raisedException : raisedExceptions) {
+ if (raisedException.isAssignableFrom(throwable.getClass())) {
+ return true;
+ }
+ }
+ }
+ }
+ catch (Throwable throwable1) {
+ logger.warn("Check exception {} failed.", throwable.getClass().getName(), throwable1);
+ return false;
+ }
+
+ return false;
+ }
+
+ protected FallbackMethod resolveFallbackMethod(ProceedingJoinPoint joinPoint) {
+ MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+ FaultTolerance faultTolerance = signature.getMethod().getAnnotation(FaultTolerance.class);
+ TsfFaultTolerance tsfFaultTolerance = signature.getMethod().getAnnotation(TsfFaultTolerance.class);
+
+ String fallbackMethodName = faultTolerance != null ? faultTolerance.fallbackMethod() : tsfFaultTolerance.fallbackMethod();
+ Class> targetClass = joinPoint.getTarget().getClass();
+ Class>[] parameterTypes = signature.getMethod().getParameterTypes();
+
+ Method method = getDeclaredMethodFor(targetClass, fallbackMethodName, false, parameterTypes);
+
+ if (method == null) {
+ return FallbackMethod.ABSENT;
+ }
+ else {
+ if (signature.getMethod().getReturnType().isAssignableFrom(method.getReturnType())) {
+ return new FallbackMethod(method);
+ }
+ else {
+ return FallbackMethod.ABSENT;
+ }
+ }
+ }
+
+ private Method getDeclaredMethodFor(Class> clazz, String name, boolean inRecursive, Class>... parameterTypes) {
+ try {
+ return clazz.getDeclaredMethod(name, parameterTypes);
+ }
+ catch (NoSuchMethodException e) {
+ if (!inRecursive) {
+ logger.warn("Fallback method not found! Classname = {}, methodName = {}, parameterTypes = {}",
+ clazz.getName(), name, Arrays.toString(parameterTypes));
+ }
+ Class> superClass = clazz.getSuperclass();
+ if (superClass != null) {
+ return getDeclaredMethodFor(superClass, name, true, parameterTypes);
+ }
+ }
+ return null;
+ }
+}
diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/com/tencent/cloud/plugin/faulttolerance/model/FaultToleranceStrategy.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/com/tencent/cloud/plugin/faulttolerance/model/FaultToleranceStrategy.java
new file mode 100644
index 000000000..b2563b507
--- /dev/null
+++ b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/com/tencent/cloud/plugin/faulttolerance/model/FaultToleranceStrategy.java
@@ -0,0 +1,37 @@
+/*
+ * Tencent is pleased to support the open source community by making spring-cloud-tencent available.
+ *
+ * Copyright (C) 2021 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.plugin.faulttolerance.model;
+
+public enum FaultToleranceStrategy {
+ /**
+ * Fails directly. For downstream services without idempotence, fail fast is recommended.
+ */
+ FAIL_FAST,
+
+ /**
+ * If the request is wrong, it will be retried.
+ */
+ FAIL_OVER,
+
+ /**
+ * Sending multiple requests at the same time requires the user to configure the degree of parallelism.
+ * For example, if two requests are sent at the same time, whichever one returns first will return the result.
+ * If the first request is an exception, it will wait for another request, and if all are exceptions, an exception will be returned.
+ */
+ FORKING
+}
diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/org/springframework/cloud/tsf/faulttolerance/annotation/EnableTsfFaultTolerance.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/org/springframework/cloud/tsf/faulttolerance/annotation/EnableTsfFaultTolerance.java
new file mode 100644
index 000000000..8156f6dac
--- /dev/null
+++ b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/org/springframework/cloud/tsf/faulttolerance/annotation/EnableTsfFaultTolerance.java
@@ -0,0 +1,38 @@
+/*
+ * Tencent is pleased to support the open source community by making spring-cloud-tencent available.
+ *
+ * Copyright (C) 2021 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 org.springframework.cloud.tsf.faulttolerance.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Empty annotation. Compatible with old versions TSF SDK.
+ *
+ * @author Haotian Zhang
+ */
+@Deprecated(since = "2.0.0.0")
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+public @interface EnableTsfFaultTolerance {
+}
diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/org/springframework/cloud/tsf/faulttolerance/annotation/TsfFaultTolerance.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/org/springframework/cloud/tsf/faulttolerance/annotation/TsfFaultTolerance.java
new file mode 100644
index 000000000..53b96464d
--- /dev/null
+++ b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/org/springframework/cloud/tsf/faulttolerance/annotation/TsfFaultTolerance.java
@@ -0,0 +1,90 @@
+/*
+ * Tencent is pleased to support the open source community by making spring-cloud-tencent available.
+ *
+ * Copyright (C) 2021 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 org.springframework.cloud.tsf.faulttolerance.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.springframework.cloud.tsf.faulttolerance.model.TsfFaultToleranceStragety;
+
+/**
+ * @author zhixinzxiliu
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+@Deprecated(since = "2.0.0.0")
+public @interface TsfFaultTolerance {
+ /**
+ * Specifies a method to process fallback logic.
+ * A fallback method should be defined in the same class where is TsfFaultTolerance.
+ * Also a fallback method should have same signature to a method.
+ * for example:
+ *
+ * @TsfFaultTolerance(fallbackMethod = "getByIdFallback")
+ * public String getById(String id) {...}
+ *
+ * public String getByIdFallback(String id) {...}
+ *
+ *
+ * @return method name
+ */
+ String fallbackMethod() default "";
+
+ /**
+ * Specifies command properties.
+ *
+ * @return command properties
+ */
+ TsfFaultToleranceProperty[] properties() default {};
+
+ /**
+ * Defines exceptions which should be ignored.
+ *
+ * @return exceptions to ignore
+ */
+ Class extends Throwable>[] ignoreExceptions() default {};
+
+ /**
+ * Defines exceptions which should be retry.
+ * Default is all exceptions.
+ *
+ * @return exceptions to wrap
+ */
+ Class extends Throwable>[] raisedExceptions() default {};
+
+ /**
+ * 设置容错策略,默认为快速失败策略.
+ */
+ TsfFaultToleranceStragety strategy() default TsfFaultToleranceStragety.FAIL_FAST;
+
+ /**
+ * 重试次数,只在Failover策略下用到.
+ */
+ int maxAttempts() default 0;
+
+ /**
+ * forking 的并行度,只在Forking策略下用到.
+ */
+ int parallelism() default 1;
+}
diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/org/springframework/cloud/tsf/faulttolerance/annotation/TsfFaultToleranceProperty.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/org/springframework/cloud/tsf/faulttolerance/annotation/TsfFaultToleranceProperty.java
new file mode 100644
index 000000000..a5c051f1b
--- /dev/null
+++ b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/org/springframework/cloud/tsf/faulttolerance/annotation/TsfFaultToleranceProperty.java
@@ -0,0 +1,52 @@
+/*
+ * Tencent is pleased to support the open source community by making spring-cloud-tencent available.
+ *
+ * Copyright (C) 2021 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 org.springframework.cloud.tsf.faulttolerance.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation allows specify TsfFaultTolerance properties in the following format:
+ * property name = property value.
+ *
+ * @author zhixinzxliu
+ */
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Deprecated(since = "2.0.0.0")
+public @interface TsfFaultToleranceProperty {
+
+ /**
+ * Property name.
+ *
+ * @return name
+ */
+ String name();
+
+ /**
+ * Property value.
+ *
+ * @return value
+ */
+ String value();
+
+}
diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/org/springframework/cloud/tsf/faulttolerance/model/TsfFaultToleranceStragety.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/org/springframework/cloud/tsf/faulttolerance/model/TsfFaultToleranceStragety.java
new file mode 100644
index 000000000..86953fae8
--- /dev/null
+++ b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/java/org/springframework/cloud/tsf/faulttolerance/model/TsfFaultToleranceStragety.java
@@ -0,0 +1,38 @@
+/*
+ * Tencent is pleased to support the open source community by making spring-cloud-tencent available.
+ *
+ * Copyright (C) 2021 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 org.springframework.cloud.tsf.faulttolerance.model;
+
+@Deprecated(since = "2.0.0.0")
+public enum TsfFaultToleranceStragety {
+ /**
+ * Fails directly. For downstream services without idempotence, fail fast is recommended.
+ */
+ FAIL_FAST,
+
+ /**
+ * If the request is wrong, it will be retried.
+ */
+ FAIL_OVER,
+
+ /**
+ * Sending multiple requests at the same time requires the user to configure the degree of parallelism.
+ * For example, if two requests are sent at the same time, whichever one returns first will return the result.
+ * If the first request is an exception, it will wait for another request, and if all are exceptions, an exception will be returned.
+ */
+ FORKING
+}
diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 000000000..095822ab9
--- /dev/null
+++ b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+com.tencent.cloud.plugin.faulttolerance.config.FaultToleranceAutoConfiguration
diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/test/java/com/tencent/cloud/plugin/faulttolerance/integration/FaultToleranceService.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/test/java/com/tencent/cloud/plugin/faulttolerance/integration/FaultToleranceService.java
new file mode 100644
index 000000000..7bba88ac8
--- /dev/null
+++ b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/test/java/com/tencent/cloud/plugin/faulttolerance/integration/FaultToleranceService.java
@@ -0,0 +1,73 @@
+/*
+ * Tencent is pleased to support the open source community by making spring-cloud-tencent available.
+ *
+ * Copyright (C) 2021 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.plugin.faulttolerance.integration;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import com.tencent.cloud.plugin.faulttolerance.annotation.FaultTolerance;
+import com.tencent.cloud.plugin.faulttolerance.model.FaultToleranceStrategy;
+
+/**
+ * Fault tolerance test service.
+ *
+ * @author Haotian Zhang
+ */
+public class FaultToleranceService {
+
+ private final AtomicInteger failFastCount = new AtomicInteger(0);
+ private final AtomicInteger failOverCount = new AtomicInteger(0);
+ private final AtomicInteger forkingCount = new AtomicInteger(0);
+
+ @FaultTolerance(strategy = FaultToleranceStrategy.FAIL_FAST, fallbackMethod = "fallback")
+ public String failFast() {
+ failFastCount.getAndIncrement();
+ throw new RuntimeException("NO");
+ }
+
+ public String fallback() {
+ return "fallback";
+ }
+
+ @FaultTolerance(strategy = FaultToleranceStrategy.FAIL_OVER, maxAttempts = 3)
+ public String failOver() {
+ if (failOverCount.incrementAndGet() % 4 == 0) {
+ return "OK";
+ }
+ throw new RuntimeException("NO");
+ }
+
+ @FaultTolerance(strategy = FaultToleranceStrategy.FORKING, parallelism = 4)
+ public String forking() {
+ if (forkingCount.incrementAndGet() % 4 == 0) {
+ return "OK";
+ }
+ throw new RuntimeException("NO");
+ }
+
+ public int getFailFastCount() {
+ return failFastCount.get();
+ }
+
+ public int getFailOverCount() {
+ return failOverCount.get();
+ }
+
+ public int getForkingCount() {
+ return forkingCount.get();
+ }
+}
diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/test/java/com/tencent/cloud/plugin/faulttolerance/integration/FaultToleranceTest.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/test/java/com/tencent/cloud/plugin/faulttolerance/integration/FaultToleranceTest.java
new file mode 100644
index 000000000..dd931d13d
--- /dev/null
+++ b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-fault-tolerance/src/test/java/com/tencent/cloud/plugin/faulttolerance/integration/FaultToleranceTest.java
@@ -0,0 +1,74 @@
+/*
+ * Tencent is pleased to support the open source community by making spring-cloud-tencent available.
+ *
+ * Copyright (C) 2021 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.plugin.faulttolerance.integration;
+
+import com.tencent.cloud.plugin.faulttolerance.config.FaultToleranceAutoConfiguration;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Integration test for Fault Tolerance.
+ *
+ * @author Haotian Zhang
+ */
+@ExtendWith(SpringExtension.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = FaultToleranceTest.TestApplication.class)
+public class FaultToleranceTest {
+
+ @Autowired
+ private FaultToleranceService testService;
+
+ @Test
+ public void testFailFast() {
+ assertThat(testService.failFast()).isEqualTo("fallback");
+ assertThat(testService.getFailFastCount()).isEqualTo(1);
+ }
+
+ @Test
+ public void testFailOver() {
+ assertThat(testService.failOver()).isEqualTo("OK");
+ assertThat(testService.getFailOverCount()).isEqualTo(4);
+ }
+
+ @Test
+ public void testForking() {
+ assertThat(testService.forking()).isEqualTo("OK");
+ assertThat(testService.getForkingCount()).isEqualTo(4);
+ }
+
+ @Configuration
+ @EnableAutoConfiguration
+ @ImportAutoConfiguration(FaultToleranceAutoConfiguration.class)
+ public static class TestApplication {
+
+ @Bean
+ public FaultToleranceService faultToleranceService() {
+ return new FaultToleranceService();
+ }
+ }
+}
diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-trace-plugin/src/main/java/com/tencent/tsf/monitor/annotation/EnableTsfMonitor.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-trace-plugin/src/main/java/com/tencent/tsf/monitor/annotation/EnableTsfMonitor.java
new file mode 100644
index 000000000..387cfac21
--- /dev/null
+++ b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-trace-plugin/src/main/java/com/tencent/tsf/monitor/annotation/EnableTsfMonitor.java
@@ -0,0 +1,39 @@
+/*
+ * Tencent is pleased to support the open source community by making spring-cloud-tencent available.
+ *
+ * Copyright (C) 2021 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.tsf.monitor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Empty annotation. Compatible with old versions TSF SDK.
+ *
+ * @author Haotian Zhang
+ */
+@Deprecated(since = "2.0.0.0")
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+public @interface EnableTsfMonitor {
+
+}
diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-trace-plugin/src/main/java/com/tencent/tsf/sleuth/annotation/EnableTsfSleuth.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-trace-plugin/src/main/java/com/tencent/tsf/sleuth/annotation/EnableTsfSleuth.java
new file mode 100644
index 000000000..289134d59
--- /dev/null
+++ b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-trace-plugin/src/main/java/com/tencent/tsf/sleuth/annotation/EnableTsfSleuth.java
@@ -0,0 +1,39 @@
+/*
+ * Tencent is pleased to support the open source community by making spring-cloud-tencent available.
+ *
+ * Copyright (C) 2021 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.tsf.sleuth.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Empty annotation. Compatible with old versions TSF SDK.
+ *
+ * @author Haotian Zhang
+ */
+@Deprecated(since = "2.0.0.0")
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Inherited
+public @interface EnableTsfSleuth {
+
+}
diff --git a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/config/extend/tsf/TsfContextConfigModifier.java b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/config/extend/tsf/TsfContextConfigModifier.java
index 13f060de8..5c589c4e6 100644
--- a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/config/extend/tsf/TsfContextConfigModifier.java
+++ b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/config/extend/tsf/TsfContextConfigModifier.java
@@ -21,6 +21,7 @@
import com.tencent.cloud.polaris.context.PolarisConfigModifier;
import com.tencent.cloud.polaris.context.config.extend.consul.ConsulProperties;
import com.tencent.polaris.api.config.plugin.DefaultPlugins;
+import com.tencent.polaris.api.utils.StringUtils;
import com.tencent.polaris.factory.config.ConfigurationImpl;
import com.tencent.polaris.plugins.event.tsf.TsfEventReporterConfig;
@@ -45,6 +46,13 @@ public void modify(ConfigurationImpl configuration) {
configuration.getGlobal().getEventReporter().getReporters().add(DefaultPlugins.TSF_EVENT_REPORTER_TYPE);
TsfEventReporterConfig tsfEventReporterConfig = new TsfEventReporterConfig();
+ if (StringUtils.isNotBlank(tsfCoreProperties.getEventMasterIp())) {
+ tsfEventReporterConfig.setEnable(true);
+ }
+ else {
+ tsfEventReporterConfig.setEnable(false);
+ return;
+ }
tsfEventReporterConfig.setEventMasterIp(tsfCoreProperties.getEventMasterIp());
tsfEventReporterConfig.setEventMasterPort(tsfCoreProperties.getEventMasterPort());
tsfEventReporterConfig.setAppId(tsfCoreProperties.getAppId());
diff --git a/spring-cloud-tencent-polaris-context/src/main/java/org/springframework/tsf/annotation/EnableTsf.java b/spring-cloud-tencent-polaris-context/src/main/java/org/springframework/tsf/annotation/EnableTsf.java
index 890ff9b72..a4fd51cc2 100644
--- a/spring-cloud-tencent-polaris-context/src/main/java/org/springframework/tsf/annotation/EnableTsf.java
+++ b/spring-cloud-tencent-polaris-context/src/main/java/org/springframework/tsf/annotation/EnableTsf.java
@@ -24,22 +24,15 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-
/**
- * Compatible with old versions TSF SDK.
+ * Empty annotation. Compatible with old versions TSF SDK.
*
* @author Haotian Zhang
*/
-
+@Deprecated(since = "2.0.0.0")
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
-@EnableAutoConfiguration
-@EnableDiscoveryClient // 服务注册发现
-@EnableConfigurationProperties // 分布式配置
public @interface EnableTsf {
}
diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/config/RpcEnhancementAutoConfiguration.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/config/RpcEnhancementAutoConfiguration.java
index fef771c94..1a211fae6 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/config/RpcEnhancementAutoConfiguration.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/config/RpcEnhancementAutoConfiguration.java
@@ -23,24 +23,24 @@
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import com.tencent.cloud.polaris.context.PolarisSDKContextManager;
import com.tencent.cloud.polaris.context.config.PolarisContextAutoConfiguration;
-import com.tencent.cloud.rpc.enhancement.feign.EnhancedFeignBeanPostProcessor;
-import com.tencent.cloud.rpc.enhancement.feign.PolarisLoadBalancerFeignRequestTransformer;
-import com.tencent.cloud.rpc.enhancement.filter.EnhancedReactiveFilter;
-import com.tencent.cloud.rpc.enhancement.filter.EnhancedServletFilter;
+import com.tencent.cloud.rpc.enhancement.instrument.feign.EnhancedFeignBeanPostProcessor;
+import com.tencent.cloud.rpc.enhancement.instrument.feign.PolarisLoadBalancerFeignRequestTransformer;
+import com.tencent.cloud.rpc.enhancement.instrument.filter.EnhancedReactiveFilter;
+import com.tencent.cloud.rpc.enhancement.instrument.filter.EnhancedServletFilter;
+import com.tencent.cloud.rpc.enhancement.instrument.resttemplate.EnhancedRestTemplateInterceptor;
+import com.tencent.cloud.rpc.enhancement.instrument.resttemplate.PolarisLoadBalancerRequestTransformer;
+import com.tencent.cloud.rpc.enhancement.instrument.scg.EnhancedGatewayGlobalFilter;
+import com.tencent.cloud.rpc.enhancement.instrument.webclient.EnhancedWebClientExchangeFilterFunction;
+import com.tencent.cloud.rpc.enhancement.instrument.webclient.PolarisLoadBalancerClientRequestTransformer;
import com.tencent.cloud.rpc.enhancement.plugin.DefaultEnhancedPluginRunner;
import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPlugin;
import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginRunner;
import com.tencent.cloud.rpc.enhancement.plugin.reporter.ExceptionPolarisReporter;
import com.tencent.cloud.rpc.enhancement.plugin.reporter.SuccessPolarisReporter;
-import com.tencent.cloud.rpc.enhancement.resttemplate.EnhancedRestTemplateInterceptor;
-import com.tencent.cloud.rpc.enhancement.resttemplate.PolarisLoadBalancerRequestTransformer;
-import com.tencent.cloud.rpc.enhancement.scg.EnhancedGatewayGlobalFilter;
import com.tencent.cloud.rpc.enhancement.transformer.InstanceTransformer;
import com.tencent.cloud.rpc.enhancement.transformer.PolarisInstanceTransformer;
import com.tencent.cloud.rpc.enhancement.transformer.PolarisRegistrationTransformer;
import com.tencent.cloud.rpc.enhancement.transformer.RegistrationTransformer;
-import com.tencent.cloud.rpc.enhancement.webclient.EnhancedWebClientExchangeFilterFunction;
-import com.tencent.cloud.rpc.enhancement.webclient.PolarisLoadBalancerClientRequestTransformer;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/EnhancedFeignBeanPostProcessor.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/feign/EnhancedFeignBeanPostProcessor.java
similarity index 98%
rename from spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/EnhancedFeignBeanPostProcessor.java
rename to spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/feign/EnhancedFeignBeanPostProcessor.java
index 132f5f26e..f4aed2a3c 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/EnhancedFeignBeanPostProcessor.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/feign/EnhancedFeignBeanPostProcessor.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.feign;
+package com.tencent.cloud.rpc.enhancement.instrument.feign;
import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginRunner;
import feign.Client;
diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/EnhancedFeignClient.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/feign/EnhancedFeignClient.java
similarity index 98%
rename from spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/EnhancedFeignClient.java
rename to spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/feign/EnhancedFeignClient.java
index 8650c36f8..e4c2d1a5b 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/EnhancedFeignClient.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/feign/EnhancedFeignClient.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.feign;
+package com.tencent.cloud.rpc.enhancement.instrument.feign;
import java.io.IOException;
import java.net.URI;
diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/PolarisLoadBalancerFeignRequestTransformer.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/feign/PolarisLoadBalancerFeignRequestTransformer.java
similarity index 88%
rename from spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/PolarisLoadBalancerFeignRequestTransformer.java
rename to spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/feign/PolarisLoadBalancerFeignRequestTransformer.java
index 8ab2cc5dd..eeb17ef1e 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/feign/PolarisLoadBalancerFeignRequestTransformer.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/feign/PolarisLoadBalancerFeignRequestTransformer.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.feign;
+package com.tencent.cloud.rpc.enhancement.instrument.feign;
import com.tencent.cloud.common.metadata.MetadataContextHolder;
import feign.Request;
@@ -23,7 +23,7 @@
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.openfeign.loadbalancer.LoadBalancerFeignRequestTransformer;
-import static com.tencent.cloud.rpc.enhancement.resttemplate.PolarisLoadBalancerRequestTransformer.LOAD_BALANCER_SERVICE_INSTANCE;
+import static com.tencent.cloud.rpc.enhancement.instrument.resttemplate.PolarisLoadBalancerRequestTransformer.LOAD_BALANCER_SERVICE_INSTANCE;
/**
* PolarisLoadBalancerFeignRequestTransformer.
diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/filter/EnhancedReactiveFilter.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/filter/EnhancedReactiveFilter.java
similarity index 98%
rename from spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/filter/EnhancedReactiveFilter.java
rename to spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/filter/EnhancedReactiveFilter.java
index d2c935cb5..a830ea79e 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/filter/EnhancedReactiveFilter.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/filter/EnhancedReactiveFilter.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.filter;
+package com.tencent.cloud.rpc.enhancement.instrument.filter;
import com.tencent.cloud.common.constant.OrderConstant;
import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginContext;
diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/filter/EnhancedServletFilter.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/filter/EnhancedServletFilter.java
similarity index 98%
rename from spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/filter/EnhancedServletFilter.java
rename to spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/filter/EnhancedServletFilter.java
index 970993903..1c1142da9 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/filter/EnhancedServletFilter.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/filter/EnhancedServletFilter.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.filter;
+package com.tencent.cloud.rpc.enhancement.instrument.filter;
import java.io.IOException;
import java.net.URI;
diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/resttemplate/EnhancedRestTemplateInterceptor.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/resttemplate/EnhancedRestTemplateInterceptor.java
similarity index 94%
rename from spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/resttemplate/EnhancedRestTemplateInterceptor.java
rename to spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/resttemplate/EnhancedRestTemplateInterceptor.java
index fdadc59de..5f739118c 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/resttemplate/EnhancedRestTemplateInterceptor.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/resttemplate/EnhancedRestTemplateInterceptor.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.resttemplate;
+package com.tencent.cloud.rpc.enhancement.instrument.resttemplate;
import java.io.IOException;
@@ -32,7 +32,7 @@
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
-import static com.tencent.cloud.rpc.enhancement.resttemplate.PolarisLoadBalancerRequestTransformer.LOAD_BALANCER_SERVICE_INSTANCE;
+import static com.tencent.cloud.rpc.enhancement.instrument.resttemplate.PolarisLoadBalancerRequestTransformer.LOAD_BALANCER_SERVICE_INSTANCE;
/**
* EnhancedRestTemplateInterceptor.
diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/resttemplate/PolarisLoadBalancerRequestTransformer.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/resttemplate/PolarisLoadBalancerRequestTransformer.java
similarity index 96%
rename from spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/resttemplate/PolarisLoadBalancerRequestTransformer.java
rename to spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/resttemplate/PolarisLoadBalancerRequestTransformer.java
index dd7a5de34..f72ea4c74 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/resttemplate/PolarisLoadBalancerRequestTransformer.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/resttemplate/PolarisLoadBalancerRequestTransformer.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.resttemplate;
+package com.tencent.cloud.rpc.enhancement.instrument.resttemplate;
import com.tencent.cloud.common.metadata.MetadataContextHolder;
diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/scg/EnhancedGatewayGlobalFilter.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/scg/EnhancedGatewayGlobalFilter.java
similarity index 98%
rename from spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/scg/EnhancedGatewayGlobalFilter.java
rename to spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/scg/EnhancedGatewayGlobalFilter.java
index e6f2bed2e..1cd2748b5 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/scg/EnhancedGatewayGlobalFilter.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/scg/EnhancedGatewayGlobalFilter.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.scg;
+package com.tencent.cloud.rpc.enhancement.instrument.scg;
import java.net.URI;
diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/webclient/EnhancedWebClientExchangeFilterFunction.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/webclient/EnhancedWebClientExchangeFilterFunction.java
similarity index 94%
rename from spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/webclient/EnhancedWebClientExchangeFilterFunction.java
rename to spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/webclient/EnhancedWebClientExchangeFilterFunction.java
index c2e599485..e8d8f1231 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/webclient/EnhancedWebClientExchangeFilterFunction.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/webclient/EnhancedWebClientExchangeFilterFunction.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.webclient;
+package com.tencent.cloud.rpc.enhancement.instrument.webclient;
import com.tencent.cloud.common.metadata.MetadataContextHolder;
import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginContext;
@@ -31,7 +31,7 @@
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
import org.springframework.web.reactive.function.client.ExchangeFunction;
-import static com.tencent.cloud.rpc.enhancement.resttemplate.PolarisLoadBalancerRequestTransformer.LOAD_BALANCER_SERVICE_INSTANCE;
+import static com.tencent.cloud.rpc.enhancement.instrument.resttemplate.PolarisLoadBalancerRequestTransformer.LOAD_BALANCER_SERVICE_INSTANCE;
/**
* EnhancedWebClientExchangeFilterFunction.
diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/webclient/PolarisLoadBalancerClientRequestTransformer.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/webclient/PolarisLoadBalancerClientRequestTransformer.java
similarity index 88%
rename from spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/webclient/PolarisLoadBalancerClientRequestTransformer.java
rename to spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/webclient/PolarisLoadBalancerClientRequestTransformer.java
index 8737d4beb..cf7bb9df0 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/webclient/PolarisLoadBalancerClientRequestTransformer.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/instrument/webclient/PolarisLoadBalancerClientRequestTransformer.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.webclient;
+package com.tencent.cloud.rpc.enhancement.instrument.webclient;
import com.tencent.cloud.common.metadata.MetadataContextHolder;
@@ -23,7 +23,7 @@
import org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerClientRequestTransformer;
import org.springframework.web.reactive.function.client.ClientRequest;
-import static com.tencent.cloud.rpc.enhancement.resttemplate.PolarisLoadBalancerRequestTransformer.LOAD_BALANCER_SERVICE_INSTANCE;
+import static com.tencent.cloud.rpc.enhancement.instrument.resttemplate.PolarisLoadBalancerRequestTransformer.LOAD_BALANCER_SERVICE_INSTANCE;
/**
* PolarisLoadBalancerClientRequestTransformer.
diff --git a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/config/RpcEnhancementAutoConfigurationTest.java b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/config/RpcEnhancementAutoConfigurationTest.java
index b84fa6343..dd3911967 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/config/RpcEnhancementAutoConfigurationTest.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/config/RpcEnhancementAutoConfigurationTest.java
@@ -18,11 +18,11 @@
package com.tencent.cloud.rpc.enhancement.config;
import com.tencent.cloud.polaris.context.config.PolarisContextAutoConfiguration;
-import com.tencent.cloud.rpc.enhancement.feign.EnhancedFeignBeanPostProcessor;
+import com.tencent.cloud.rpc.enhancement.instrument.feign.EnhancedFeignBeanPostProcessor;
+import com.tencent.cloud.rpc.enhancement.instrument.resttemplate.EnhancedRestTemplateInterceptor;
import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginRunner;
import com.tencent.cloud.rpc.enhancement.plugin.reporter.ExceptionPolarisReporter;
import com.tencent.cloud.rpc.enhancement.plugin.reporter.SuccessPolarisReporter;
-import com.tencent.cloud.rpc.enhancement.resttemplate.EnhancedRestTemplateInterceptor;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
diff --git a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/feign/EnhancedFeignBeanPostProcessorTest.java b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/feign/EnhancedFeignBeanPostProcessorTest.java
similarity index 98%
rename from spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/feign/EnhancedFeignBeanPostProcessorTest.java
rename to spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/feign/EnhancedFeignBeanPostProcessorTest.java
index 17868daa7..6dbca5fec 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/feign/EnhancedFeignBeanPostProcessorTest.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/feign/EnhancedFeignBeanPostProcessorTest.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.feign;
+package com.tencent.cloud.rpc.enhancement.instrument.feign;
import feign.Client;
import org.junit.jupiter.api.BeforeEach;
diff --git a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/feign/EnhancedFeignClientTest.java b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/feign/EnhancedFeignClientTest.java
similarity index 99%
rename from spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/feign/EnhancedFeignClientTest.java
rename to spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/feign/EnhancedFeignClientTest.java
index debbd1d94..8cf85b46a 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/feign/EnhancedFeignClientTest.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/feign/EnhancedFeignClientTest.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.feign;
+package com.tencent.cloud.rpc.enhancement.instrument.feign;
import java.io.IOException;
import java.util.ArrayList;
diff --git a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/feign/PolarisLoadBalancerFeignRequestTransformerTest.java b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/feign/PolarisLoadBalancerFeignRequestTransformerTest.java
similarity index 91%
rename from spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/feign/PolarisLoadBalancerFeignRequestTransformerTest.java
rename to spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/feign/PolarisLoadBalancerFeignRequestTransformerTest.java
index 4f259d289..8e78c95b5 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/feign/PolarisLoadBalancerFeignRequestTransformerTest.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/feign/PolarisLoadBalancerFeignRequestTransformerTest.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.feign;
+package com.tencent.cloud.rpc.enhancement.instrument.feign;
import com.tencent.cloud.common.metadata.MetadataContext;
import com.tencent.cloud.common.metadata.MetadataContextHolder;
@@ -36,7 +36,7 @@
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.context.ApplicationContext;
-import static com.tencent.cloud.rpc.enhancement.resttemplate.PolarisLoadBalancerRequestTransformer.LOAD_BALANCER_SERVICE_INSTANCE;
+import static com.tencent.cloud.rpc.enhancement.instrument.resttemplate.PolarisLoadBalancerRequestTransformer.LOAD_BALANCER_SERVICE_INSTANCE;
import static com.tencent.polaris.test.common.Consts.NAMESPACE_TEST;
import static com.tencent.polaris.test.common.Consts.SERVICE_PROVIDER;
import static org.assertj.core.api.Assertions.assertThat;
@@ -72,7 +72,8 @@ static void beforeAll() {
StaticMetadataManager staticMetadataManager = mock(StaticMetadataManager.class);
doReturn(metadataLocalProperties).when(applicationContext).getBean(MetadataLocalProperties.class);
doReturn(staticMetadataManager).when(applicationContext).getBean(StaticMetadataManager.class);
- mockedApplicationContextAwareUtils.when(ApplicationContextAwareUtils::getApplicationContext).thenReturn(applicationContext);
+ mockedApplicationContextAwareUtils.when(ApplicationContextAwareUtils::getApplicationContext)
+ .thenReturn(applicationContext);
}
@AfterAll
@@ -89,6 +90,7 @@ void setUp() {
@Test
public void test() throws Throwable {
transformer.transformRequest(clientRequest, serviceInstance);
- assertThat(MetadataContextHolder.get().getLoadbalancerMetadata().get(LOAD_BALANCER_SERVICE_INSTANCE)).isEqualTo(serviceInstance);
+ assertThat(MetadataContextHolder.get().getLoadbalancerMetadata()
+ .get(LOAD_BALANCER_SERVICE_INSTANCE)).isEqualTo(serviceInstance);
}
}
diff --git a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/resttemplate/EnhancedRestTemplateInterceptorTest.java b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/resttemplate/EnhancedRestTemplateInterceptorTest.java
similarity index 97%
rename from spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/resttemplate/EnhancedRestTemplateInterceptorTest.java
rename to spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/resttemplate/EnhancedRestTemplateInterceptorTest.java
index 659d1cd15..7da97785b 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/resttemplate/EnhancedRestTemplateInterceptorTest.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/resttemplate/EnhancedRestTemplateInterceptorTest.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.resttemplate;
+package com.tencent.cloud.rpc.enhancement.instrument.resttemplate;
import java.io.IOException;
import java.net.SocketTimeoutException;
@@ -62,12 +62,12 @@ public class EnhancedRestTemplateInterceptorTest {
private static MockedStatic mockedApplicationContextAwareUtils;
@Mock
+ Registration registration;
+ @Mock
private RpcEnhancementReporterProperties reporterProperties;
@Mock
private SDKContext sdkContext;
@Mock
- Registration registration;
- @Mock
private ClientHttpRequestExecution mockClientHttpRequestExecution;
@Mock
private ClientHttpResponse mockClientHttpResponse;
@@ -86,7 +86,8 @@ static void beforeAll() {
StaticMetadataManager staticMetadataManager = mock(StaticMetadataManager.class);
doReturn(metadataLocalProperties).when(applicationContext).getBean(MetadataLocalProperties.class);
doReturn(staticMetadataManager).when(applicationContext).getBean(StaticMetadataManager.class);
- mockedApplicationContextAwareUtils.when(ApplicationContextAwareUtils::getApplicationContext).thenReturn(applicationContext);
+ mockedApplicationContextAwareUtils.when(ApplicationContextAwareUtils::getApplicationContext)
+ .thenReturn(applicationContext);
}
@AfterAll
diff --git a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/resttemplate/PolarisLoadBalancerRequestTransformerTest.java b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/resttemplate/PolarisLoadBalancerRequestTransformerTest.java
similarity index 90%
rename from spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/resttemplate/PolarisLoadBalancerRequestTransformerTest.java
rename to spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/resttemplate/PolarisLoadBalancerRequestTransformerTest.java
index 71bbd822f..3da230d61 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/resttemplate/PolarisLoadBalancerRequestTransformerTest.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/resttemplate/PolarisLoadBalancerRequestTransformerTest.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.resttemplate;
+package com.tencent.cloud.rpc.enhancement.instrument.resttemplate;
import com.tencent.cloud.common.metadata.MetadataContext;
import com.tencent.cloud.common.metadata.MetadataContextHolder;
@@ -36,7 +36,7 @@
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpRequest;
-import static com.tencent.cloud.rpc.enhancement.resttemplate.PolarisLoadBalancerRequestTransformer.LOAD_BALANCER_SERVICE_INSTANCE;
+import static com.tencent.cloud.rpc.enhancement.instrument.resttemplate.PolarisLoadBalancerRequestTransformer.LOAD_BALANCER_SERVICE_INSTANCE;
import static com.tencent.polaris.test.common.Consts.NAMESPACE_TEST;
import static com.tencent.polaris.test.common.Consts.SERVICE_PROVIDER;
import static org.assertj.core.api.Assertions.assertThat;
@@ -66,7 +66,8 @@ static void beforeAll() {
StaticMetadataManager staticMetadataManager = mock(StaticMetadataManager.class);
doReturn(metadataLocalProperties).when(applicationContext).getBean(MetadataLocalProperties.class);
doReturn(staticMetadataManager).when(applicationContext).getBean(StaticMetadataManager.class);
- mockedApplicationContextAwareUtils.when(ApplicationContextAwareUtils::getApplicationContext).thenReturn(applicationContext);
+ mockedApplicationContextAwareUtils.when(ApplicationContextAwareUtils::getApplicationContext)
+ .thenReturn(applicationContext);
}
@AfterAll
@@ -83,7 +84,8 @@ void setUp() {
@Test
public void test() throws Throwable {
transformer.transformRequest(clientRequest, serviceInstance);
- assertThat(MetadataContextHolder.get().getLoadbalancerMetadata().get(LOAD_BALANCER_SERVICE_INSTANCE)).isEqualTo(serviceInstance);
+ assertThat(MetadataContextHolder.get().getLoadbalancerMetadata()
+ .get(LOAD_BALANCER_SERVICE_INSTANCE)).isEqualTo(serviceInstance);
}
}
diff --git a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/scg/EnhancedGatewayGlobalFilterTest.java b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/scg/EnhancedGatewayGlobalFilterTest.java
similarity index 98%
rename from spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/scg/EnhancedGatewayGlobalFilterTest.java
rename to spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/scg/EnhancedGatewayGlobalFilterTest.java
index 0c6583a55..21174b5a6 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/scg/EnhancedGatewayGlobalFilterTest.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/scg/EnhancedGatewayGlobalFilterTest.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.scg;
+package com.tencent.cloud.rpc.enhancement.instrument.scg;
import java.net.URI;
import java.net.URISyntaxException;
diff --git a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/webclient/EnhancedWebClientExchangeFilterFunctionTest.java b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/webclient/EnhancedWebClientExchangeFilterFunctionTest.java
similarity index 96%
rename from spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/webclient/EnhancedWebClientExchangeFilterFunctionTest.java
rename to spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/webclient/EnhancedWebClientExchangeFilterFunctionTest.java
index a29d65cbd..67502167d 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/webclient/EnhancedWebClientExchangeFilterFunctionTest.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/webclient/EnhancedWebClientExchangeFilterFunctionTest.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.webclient;
+package com.tencent.cloud.rpc.enhancement.instrument.webclient;
import java.net.URI;
import java.net.URISyntaxException;
@@ -84,7 +84,8 @@ static void beforeAll() {
StaticMetadataManager staticMetadataManager = mock(StaticMetadataManager.class);
doReturn(metadataLocalProperties).when(applicationContext).getBean(MetadataLocalProperties.class);
doReturn(staticMetadataManager).when(applicationContext).getBean(StaticMetadataManager.class);
- mockedApplicationContextAwareUtils.when(ApplicationContextAwareUtils::getApplicationContext).thenReturn(applicationContext);
+ mockedApplicationContextAwareUtils.when(ApplicationContextAwareUtils::getApplicationContext)
+ .thenReturn(applicationContext);
}
@AfterAll
@@ -97,6 +98,7 @@ void setUp() {
MetadataContext.LOCAL_NAMESPACE = NAMESPACE_TEST;
MetadataContext.LOCAL_SERVICE = SERVICE_PROVIDER;
}
+
@Test
public void testRun() throws URISyntaxException {
@@ -117,8 +119,8 @@ public void testRun() throws URISyntaxException {
doReturn(Mono.error(new RuntimeException())).when(exchangeFunction).exchange(any());
- assertThatThrownBy(() -> reporter.filter(clientRequest, exchangeFunction).block()).isInstanceOf(RuntimeException.class);
-
+ assertThatThrownBy(() -> reporter.filter(clientRequest, exchangeFunction)
+ .block()).isInstanceOf(RuntimeException.class);
}
diff --git a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/webclient/PolarisLoadBalancerClientRequestTransformerTest.java b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/webclient/PolarisLoadBalancerClientRequestTransformerTest.java
similarity index 91%
rename from spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/webclient/PolarisLoadBalancerClientRequestTransformerTest.java
rename to spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/webclient/PolarisLoadBalancerClientRequestTransformerTest.java
index eec316bcc..0519402f1 100644
--- a/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/webclient/PolarisLoadBalancerClientRequestTransformerTest.java
+++ b/spring-cloud-tencent-rpc-enhancement/src/test/java/com/tencent/cloud/rpc/enhancement/instrument/webclient/PolarisLoadBalancerClientRequestTransformerTest.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.rpc.enhancement.webclient;
+package com.tencent.cloud.rpc.enhancement.instrument.webclient;
import com.tencent.cloud.common.metadata.MetadataContext;
import com.tencent.cloud.common.metadata.MetadataContextHolder;
@@ -36,7 +36,7 @@
import org.springframework.context.ApplicationContext;
import org.springframework.web.reactive.function.client.ClientRequest;
-import static com.tencent.cloud.rpc.enhancement.resttemplate.PolarisLoadBalancerRequestTransformer.LOAD_BALANCER_SERVICE_INSTANCE;
+import static com.tencent.cloud.rpc.enhancement.instrument.resttemplate.PolarisLoadBalancerRequestTransformer.LOAD_BALANCER_SERVICE_INSTANCE;
import static com.tencent.polaris.test.common.Consts.NAMESPACE_TEST;
import static com.tencent.polaris.test.common.Consts.SERVICE_PROVIDER;
import static org.assertj.core.api.Assertions.assertThat;
@@ -67,7 +67,8 @@ static void beforeAll() {
StaticMetadataManager staticMetadataManager = mock(StaticMetadataManager.class);
doReturn(metadataLocalProperties).when(applicationContext).getBean(MetadataLocalProperties.class);
doReturn(staticMetadataManager).when(applicationContext).getBean(StaticMetadataManager.class);
- mockedApplicationContextAwareUtils.when(ApplicationContextAwareUtils::getApplicationContext).thenReturn(applicationContext);
+ mockedApplicationContextAwareUtils.when(ApplicationContextAwareUtils::getApplicationContext)
+ .thenReturn(applicationContext);
}
@AfterAll
@@ -84,6 +85,7 @@ void setUp() {
@Test
public void test() throws Throwable {
transformer.transformRequest(clientRequest, serviceInstance);
- assertThat(MetadataContextHolder.get().getLoadbalancerMetadata().get(LOAD_BALANCER_SERVICE_INSTANCE)).isEqualTo(serviceInstance);
+ assertThat(MetadataContextHolder.get().getLoadbalancerMetadata()
+ .get(LOAD_BALANCER_SERVICE_INSTANCE)).isEqualTo(serviceInstance);
}
}