add PluginOrderConstant

pull/992/head
seanyu 2 years ago
parent 359c250196
commit 17a1882b25

@ -32,8 +32,14 @@ import org.slf4j.LoggerFactory;
import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.core.Ordered;
import static com.tencent.cloud.rpc.enhancement.plugin.PluginOrderConstant.ClientPluginOrder.CIRCUIT_BREAKER_REPORTER_PLUGIN_ORDER;
/**
* ExceptionCircuitBreakerReporter.
*
* @author sean yu
*/
public class ExceptionCircuitBreakerReporter implements EnhancedPlugin {
private static final Logger LOG = LoggerFactory.getLogger(ExceptionCircuitBreakerReporter.class);
@ -92,6 +98,6 @@ public class ExceptionCircuitBreakerReporter implements EnhancedPlugin {
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 2;
return CIRCUIT_BREAKER_REPORTER_PLUGIN_ORDER;
}
}

@ -34,9 +34,14 @@ import org.slf4j.LoggerFactory;
import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.core.Ordered;
import static com.tencent.cloud.rpc.enhancement.plugin.PluginOrderConstant.ClientPluginOrder.CIRCUIT_BREAKER_REPORTER_PLUGIN_ORDER;
/**
* SuccessCircuitBreakerReporter.
*
* @author sean yu
*/
public class SuccessCircuitBreakerReporter implements EnhancedPlugin {
private static final Logger LOG = LoggerFactory.getLogger(SuccessPolarisReporter.class);
@ -94,6 +99,6 @@ public class SuccessCircuitBreakerReporter implements EnhancedPlugin {
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 2;
return CIRCUIT_BREAKER_REPORTER_PLUGIN_ORDER;
}
}

@ -28,6 +28,9 @@ import com.tencent.polaris.factory.config.ConfigurationImpl;
*/
public class PolarisTsfFlowConfigModifier implements PolarisConfigModifier {
/**
* Polaris Tsf Flow Name.
*/
public static final String TSF_FLOW_NAME = "tsf";
@Override

@ -0,0 +1,67 @@
/*
* 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.rpc.enhancement.plugin;
import org.springframework.core.Ordered;
/**
* PluginOrderConstant.
*
* @author sean yu
*/
public class PluginOrderConstant {
public static class ClientPluginOrder {
/**
* order for
* {@link com.tencent.cloud.polaris.circuitbreaker.reporter.SuccessCircuitBreakerReporter}
* and
* {@link com.tencent.cloud.polaris.circuitbreaker.reporter.ExceptionCircuitBreakerReporter}.
*/
public static final int CONSUMER_REPORTER_PLUGIN_ORDER = Ordered.HIGHEST_PRECEDENCE + 1;
/**
* order for
* {@link com.tencent.cloud.rpc.enhancement.plugin.reporter.SuccessPolarisReporter}
* and
* {@link com.tencent.cloud.rpc.enhancement.plugin.reporter.ExceptionPolarisReporter}.
*/
public static final int CIRCUIT_BREAKER_REPORTER_PLUGIN_ORDER = Ordered.HIGHEST_PRECEDENCE + 2;
/**
* order for
* {@link com.tencent.cloud.rpc.enhancement.plugin.assembly.client.AssemblyClientPreHook}
* and
* {@link com.tencent.cloud.rpc.enhancement.plugin.assembly.client.AssemblyClientPostHook}
* and
* {@link com.tencent.cloud.rpc.enhancement.plugin.assembly.client.AssemblyClientExceptionHook}.
*/
public static final int ASSEMBLY_PLUGIN_ORDER = Ordered.HIGHEST_PRECEDENCE + 3;
}
public static class ServerPluginOrder {
/**
* order for
* {@link com.tencent.cloud.rpc.enhancement.plugin.assembly.server.AssemblyServerPreHook}
* and
* {@link com.tencent.cloud.rpc.enhancement.plugin.assembly.server.AssemblyServerPostHook}
* and
* {@link com.tencent.cloud.rpc.enhancement.plugin.assembly.server.AssemblyServerExceptionHook}.
*/
public static final int ASSEMBLY_PLUGIN_ORDER = Ordered.HIGHEST_PRECEDENCE + 1;
}
}

@ -31,7 +31,7 @@ import com.tencent.polaris.assembly.api.AssemblyAPI;
import com.tencent.polaris.assembly.api.pojo.AfterRequest;
import com.tencent.polaris.assembly.api.pojo.Capability;
import org.springframework.core.Ordered;
import static com.tencent.cloud.rpc.enhancement.plugin.PluginOrderConstant.ClientPluginOrder.ASSEMBLY_PLUGIN_ORDER;
/**
* AssemblyClientExceptionHook.
@ -77,6 +77,6 @@ public class AssemblyClientExceptionHook implements EnhancedPlugin {
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 3;
return ASSEMBLY_PLUGIN_ORDER;
}
}

@ -31,7 +31,7 @@ import com.tencent.polaris.assembly.api.AssemblyAPI;
import com.tencent.polaris.assembly.api.pojo.AfterRequest;
import com.tencent.polaris.assembly.api.pojo.Capability;
import org.springframework.core.Ordered;
import static com.tencent.cloud.rpc.enhancement.plugin.PluginOrderConstant.ClientPluginOrder.ASSEMBLY_PLUGIN_ORDER;
/**
* AssemblyClientPostHook.
@ -77,7 +77,7 @@ public class AssemblyClientPostHook implements EnhancedPlugin {
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 3;
return ASSEMBLY_PLUGIN_ORDER;
}
}

@ -28,7 +28,7 @@ import com.tencent.polaris.assembly.api.AssemblyAPI;
import com.tencent.polaris.assembly.api.pojo.BeforeRequest;
import com.tencent.polaris.assembly.api.pojo.Capability;
import org.springframework.core.Ordered;
import static com.tencent.cloud.rpc.enhancement.plugin.PluginOrderConstant.ClientPluginOrder.ASSEMBLY_PLUGIN_ORDER;
/**
* AssemblyClientPreHook.
@ -67,7 +67,7 @@ public class AssemblyClientPreHook implements EnhancedPlugin {
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 3;
return ASSEMBLY_PLUGIN_ORDER;
}
}

@ -30,7 +30,8 @@ import com.tencent.polaris.assembly.api.AssemblyAPI;
import com.tencent.polaris.assembly.api.pojo.AfterRequest;
import com.tencent.polaris.assembly.api.pojo.Capability;
import org.springframework.core.Ordered;
import static com.tencent.cloud.rpc.enhancement.plugin.PluginOrderConstant.ServerPluginOrder.ASSEMBLY_PLUGIN_ORDER;
/**
* AssemblyServerExceptionHook.
@ -69,7 +70,7 @@ public class AssemblyServerExceptionHook implements EnhancedPlugin {
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 3;
return ASSEMBLY_PLUGIN_ORDER;
}
}

@ -30,7 +30,7 @@ import com.tencent.polaris.assembly.api.AssemblyAPI;
import com.tencent.polaris.assembly.api.pojo.AfterRequest;
import com.tencent.polaris.assembly.api.pojo.Capability;
import org.springframework.core.Ordered;
import static com.tencent.cloud.rpc.enhancement.plugin.PluginOrderConstant.ServerPluginOrder.ASSEMBLY_PLUGIN_ORDER;
/**
* AssemblyServerPostHook.
@ -69,7 +69,7 @@ public class AssemblyServerPostHook implements EnhancedPlugin {
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 3;
return ASSEMBLY_PLUGIN_ORDER;
}
}

@ -28,7 +28,7 @@ import com.tencent.polaris.assembly.api.AssemblyAPI;
import com.tencent.polaris.assembly.api.pojo.BeforeRequest;
import com.tencent.polaris.assembly.api.pojo.Capability;
import org.springframework.core.Ordered;
import static com.tencent.cloud.rpc.enhancement.plugin.PluginOrderConstant.ServerPluginOrder.ASSEMBLY_PLUGIN_ORDER;
/**
* AssemblyServerPreHook.
@ -64,7 +64,7 @@ public class AssemblyServerPreHook implements EnhancedPlugin {
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 3;
return ASSEMBLY_PLUGIN_ORDER;
}
}

@ -33,7 +33,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.core.Ordered;
import static com.tencent.cloud.rpc.enhancement.plugin.PluginOrderConstant.ClientPluginOrder.CONSUMER_REPORTER_PLUGIN_ORDER;
/**
* Polaris reporter when feign call fails.
@ -102,7 +103,7 @@ public class ExceptionPolarisReporter implements EnhancedPlugin {
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 1;
return CONSUMER_REPORTER_PLUGIN_ORDER;
}
}

@ -33,7 +33,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.core.Ordered;
import static com.tencent.cloud.rpc.enhancement.plugin.PluginOrderConstant.ClientPluginOrder.CONSUMER_REPORTER_PLUGIN_ORDER;
/**
* Polaris reporter when feign call is successful.
@ -103,6 +104,6 @@ public class SuccessPolarisReporter implements EnhancedPlugin {
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE + 1;
return CONSUMER_REPORTER_PLUGIN_ORDER;
}
}

Loading…
Cancel
Save