Aggregate discovery support choosing registry center
This commit is contained in:
@@ -57,6 +57,7 @@ import we.fizz.input.ScriptHelper;
|
||||
import we.flume.clients.log4j2appender.LogService;
|
||||
import we.proxy.FizzWebClient;
|
||||
import we.proxy.http.HttpInstanceService;
|
||||
import we.util.Consts;
|
||||
import we.util.JacksonUtils;
|
||||
import we.util.MapUtil;
|
||||
import we.util.TypeUtils;
|
||||
@@ -90,6 +91,7 @@ public class RequestInput extends RPCInput implements IInput{
|
||||
|
||||
private static final String CONTENT_TYPE = "content-type";
|
||||
|
||||
private static final Integer SERVICE_TYPE_DISCOVERY = 1;
|
||||
private static final Integer SERVICE_TYPE_HTTP = 2;
|
||||
|
||||
private String respContentType;
|
||||
@@ -198,6 +200,7 @@ public class RequestInput extends RPCInput implements IInput{
|
||||
|
||||
if (config.isNewVersion()) {
|
||||
String host = config.getServiceName();
|
||||
|
||||
if (SERVICE_TYPE_HTTP.equals(config.getServiceType().intValue())) {
|
||||
HttpInstanceService httpInstanceService = this.getCurrentApplicationContext()
|
||||
.getBean(HttpInstanceService.class);
|
||||
@@ -205,6 +208,11 @@ public class RequestInput extends RPCInput implements IInput{
|
||||
if (instance != null) {
|
||||
host = instance;
|
||||
}
|
||||
} else if (SERVICE_TYPE_DISCOVERY.equals(config.getServiceType())) {
|
||||
if (StringUtils.isNotBlank(config.getRegistryName())) {
|
||||
// support choosing registry center
|
||||
host = config.getRegistryName() + Consts.S.COMMA + host;
|
||||
}
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(config.getProtocol()).append("://").append(host)
|
||||
|
||||
@@ -52,6 +52,8 @@ public class RequestInputConfig extends InputConfig {
|
||||
*/
|
||||
private long retryInterval;
|
||||
|
||||
private String registryName;
|
||||
|
||||
public RequestInputConfig(Map configBody) {
|
||||
super(configBody);
|
||||
|
||||
@@ -61,6 +63,7 @@ public class RequestInputConfig extends InputConfig {
|
||||
serviceType = Integer.valueOf(configBody.get("serviceType").toString());
|
||||
protocol = ((String) configBody.get("protocol")).toLowerCase();
|
||||
serviceName = (String) configBody.get("serviceName");
|
||||
registryName = (String)configBody.get("registryName");
|
||||
path = (String) configBody.get("path");
|
||||
} else {
|
||||
String url = (String) configBody.get("url");
|
||||
@@ -211,4 +214,12 @@ public class RequestInputConfig extends InputConfig {
|
||||
public void setRetryInterval(long retryInterval) {
|
||||
this.retryInterval = retryInterval;
|
||||
}
|
||||
|
||||
public String getRegistryName() {
|
||||
return registryName;
|
||||
}
|
||||
|
||||
public void setRegistryName(String registryName) {
|
||||
this.registryName = registryName;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user