|
|
|
@ -1,9 +1,8 @@
|
|
|
|
|
package com.github.dynamic.threadpool.starter.remote;
|
|
|
|
|
|
|
|
|
|
import com.github.dynamic.threadpool.starter.toolkit.HttpClientUtil;
|
|
|
|
|
import com.github.dynamic.threadpool.common.config.ApplicationContextHolder;
|
|
|
|
|
import com.github.dynamic.threadpool.starter.config.DynamicThreadPoolProperties;
|
|
|
|
|
import com.github.dynamic.threadpool.common.web.base.Result;
|
|
|
|
|
import com.github.dynamic.threadpool.starter.config.DynamicThreadPoolProperties;
|
|
|
|
|
import com.github.dynamic.threadpool.starter.toolkit.HttpClientUtil;
|
|
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@ -19,10 +18,11 @@ public class ServerHttpAgent implements HttpAgent {
|
|
|
|
|
|
|
|
|
|
private final ServerListManager serverListManager;
|
|
|
|
|
|
|
|
|
|
private HttpClientUtil httpClientUtil = ApplicationContextHolder.getBean(HttpClientUtil.class);
|
|
|
|
|
private final HttpClientUtil httpClientUtil;
|
|
|
|
|
|
|
|
|
|
public ServerHttpAgent(DynamicThreadPoolProperties properties) {
|
|
|
|
|
public ServerHttpAgent(DynamicThreadPoolProperties properties, HttpClientUtil httpClientUtil) {
|
|
|
|
|
this.dynamicThreadPoolProperties = properties;
|
|
|
|
|
this.httpClientUtil = httpClientUtil;
|
|
|
|
|
this.serverListManager = new ServerListManager(dynamicThreadPoolProperties);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -32,31 +32,37 @@ public class ServerHttpAgent implements HttpAgent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Result httpGet(String path, Map<String, String> headers, Map<String, String> paramValues, long readTimeoutMs) {
|
|
|
|
|
return httpClientUtil.restApiGetByThreadPool(buildUrl(path), headers, paramValues, readTimeoutMs, Result.class);
|
|
|
|
|
public String getTenantId() {
|
|
|
|
|
return dynamicThreadPoolProperties.getNamespace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Result httpPost(String path, Map<String, String> headers, Map<String, String> paramValues, long readTimeoutMs) {
|
|
|
|
|
return httpClientUtil.restApiPostByThreadPool(buildUrl(path), headers, paramValues, readTimeoutMs, Result.class);
|
|
|
|
|
public String getEncode() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Result httpDelete(String path, Map<String, String> headers, Map<String, String> paramValues, long readTimeoutMs) {
|
|
|
|
|
return null;
|
|
|
|
|
public Result httpPostByDiscovery(String url, Object body) {
|
|
|
|
|
return httpClientUtil.restApiPost(url, body, Result.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getTenantId() {
|
|
|
|
|
return dynamicThreadPoolProperties.getNamespace();
|
|
|
|
|
public Result httpGetByConfig(String path, Map<String, String> headers, Map<String, String> paramValues, long readTimeoutMs) {
|
|
|
|
|
return httpClientUtil.restApiGetByThreadPool(buildUrl(path), headers, paramValues, readTimeoutMs, Result.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getEncode() {
|
|
|
|
|
public Result httpPostByConfig(String path, Map<String, String> headers, Map<String, String> paramValues, long readTimeoutMs) {
|
|
|
|
|
return httpClientUtil.restApiPostByThreadPool(buildUrl(path), headers, paramValues, readTimeoutMs, Result.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Result httpDeleteByConfig(String path, Map<String, String> headers, Map<String, String> paramValues, long readTimeoutMs) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String buildUrl(String path) {
|
|
|
|
|
return serverListManager.getCurrentServerAddr() + path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|