Commit e57a7669 by Nepxion

Revert "增加Mock接口"

This reverts commit a3935596.
parent a3935596
......@@ -9,7 +9,6 @@ package com.nepxion.discovery.plugin.admincenter.configuration;
* @version 1.0
*/
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
......@@ -42,11 +41,5 @@ public class AdminAutoConfiguration {
public RestTemplate routerRestTemplate() {
return new RestTemplate();
}
@LoadBalanced
@Bean
public RestTemplate routerLoadBalancedRestTemplate() {
return new RestTemplate();
}
}
}
\ No newline at end of file
......@@ -47,9 +47,6 @@ public class RouterEndpoint {
private RestTemplate routerRestTemplate;
@Autowired
private RestTemplate routerLoadBalancedRestTemplate;
@Autowired
private DiscoveryClient discoveryClient;
@Autowired
......@@ -91,12 +88,6 @@ public class RouterEndpoint {
return routeTree(routeServiceIds);
}
@RequestMapping(path = "/router/mock/{routeServiceId}", method = RequestMethod.POST)
@ApiOperation(value = "Mock调用", notes = "", response = String.class, httpMethod = "POST")
public String mock(@PathVariable(value = "routeServiceId") @ApiParam(value = "目标服务名", required = true) String routeServiceId, @RequestBody @ApiParam(value = "Mock入参", required = true) String mockValue) {
return routeMock(routeServiceId, mockValue);
}
public List<String> getServices() {
return discoveryClient.getServices();
}
......@@ -250,14 +241,4 @@ public class RouterEndpoint {
return routerEntityList;
}
private String routeMock(String routeServiceId, String mockValue) {
String result = pluginAdapter.mock(registration, mockValue);
if (!StringUtils.equals(routeServiceId, PluginConstant.MOCK_ROUTE_SERVICE_ID)) {
result = routerLoadBalancedRestTemplate.postForEntity("http://" + routeServiceId + "/router/mock/" + PluginConstant.MOCK_ROUTE_SERVICE_ID, result, String.class).getBody();
}
return result;
}
}
\ No newline at end of file
......@@ -11,7 +11,6 @@ package com.nepxion.discovery.plugin.framework.adapter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.serviceregistry.Registration;
import com.nepxion.discovery.plugin.framework.cache.PluginCache;
import com.nepxion.discovery.plugin.framework.cache.RuleCache;
......@@ -93,14 +92,4 @@ public abstract class AbstractPluginAdapter implements PluginAdapter {
public void clearDynamicRule() {
ruleCache.clear(PluginConstant.DYNAMIC_RULE);
}
@Override
public String mock(Registration registration, String mockValue) {
String serviceId = getServiceId();
String version = getVersion();
String host = getHost(registration);
int port = getPort(registration);
return mockValue + " -> [" + serviceId + "][" + host + ":" + port + "][V" + version + "]";
}
}
\ No newline at end of file
......@@ -48,6 +48,4 @@ public interface PluginAdapter {
void setDynamicRule(RuleEntity ruleEntity);
void clearDynamicRule();
String mock(Registration registration, String mockValue);
}
\ No newline at end of file
......@@ -25,8 +25,7 @@ public class PluginConstant {
public static final String RULE = "rule";
public static final String DYNAMIC_RULE = "dynamicRule";
public static final String REACH_MAX_LIMITED_COUNT = "reach max limited count";
public static final String MOCK_ROUTE_SERVICE_ID = "mockRouteServiceId";
public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
public static final String ENCODING_UTF_8 = "UTF-8";
public static final String SEPARATE = ";";
......
......@@ -10,10 +10,10 @@ package com.nepxion.discovery.plugin.example.feign;
*/
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.serviceregistry.Registration;
import org.springframework.core.env.ConfigurableEnvironment;
import com.nepxion.discovery.plugin.framework.adapter.PluginAdapter;
import com.nepxion.discovery.plugin.framework.constant.PluginConstant;
public class AbstractFeignImpl {
@Autowired
......@@ -22,10 +22,10 @@ public class AbstractFeignImpl {
@Autowired
private PluginAdapter pluginAdapter;
@Autowired
private Registration registration;
public String doInvoke(String value) {
return pluginAdapter.mock(registration, value);
String serviceId = environment.getProperty(PluginConstant.SPRING_APPLICATION_NAME);
String version = pluginAdapter.getVersion();
return value + " -> " + serviceId + "[" + version + "]";
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment