Add RegistryCenterService.getServiceNameSpace
This commit is contained in:
@@ -40,6 +40,7 @@ import we.proxy.FizzWebClient;
|
|||||||
import we.proxy.Route;
|
import we.proxy.Route;
|
||||||
import we.proxy.dubbo.ApacheDubboGenericService;
|
import we.proxy.dubbo.ApacheDubboGenericService;
|
||||||
import we.proxy.dubbo.DubboInterfaceDeclaration;
|
import we.proxy.dubbo.DubboInterfaceDeclaration;
|
||||||
|
import we.service_registry.RegistryCenterService;
|
||||||
import we.util.*;
|
import we.util.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -115,10 +116,7 @@ public class RouteFilter extends FizzWebFilter {
|
|||||||
|
|
||||||
} else if (route.type == ApiConfig.Type.SERVICE_DISCOVERY) {
|
} else if (route.type == ApiConfig.Type.SERVICE_DISCOVERY) {
|
||||||
String pathQuery = getBackendPathQuery(req, route);
|
String pathQuery = getBackendPathQuery(req, route);
|
||||||
String svc = route.backendService;
|
String svc = RegistryCenterService.getServiceNameSpace(route.registryCenter, route.backendService);
|
||||||
if (route.registryCenter != null) {
|
|
||||||
svc = route.registryCenter + Consts.S.COMMA + route.backendService;
|
|
||||||
}
|
|
||||||
return fizzWebClient.send2service(traceId, route.method, svc, pathQuery, hdrs, req.getBody(), route.timeout, route.retryCount, route.retryInterval)
|
return fizzWebClient.send2service(traceId, route.method, svc, pathQuery, hdrs, req.getBody(), route.timeout, route.retryCount, route.retryInterval)
|
||||||
.flatMap(genServerResponse(exchange));
|
.flatMap(genServerResponse(exchange));
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ import we.fizz.input.ScriptHelper;
|
|||||||
import we.flume.clients.log4j2appender.LogService;
|
import we.flume.clients.log4j2appender.LogService;
|
||||||
import we.proxy.FizzWebClient;
|
import we.proxy.FizzWebClient;
|
||||||
import we.proxy.http.HttpInstanceService;
|
import we.proxy.http.HttpInstanceService;
|
||||||
|
import we.service_registry.RegistryCenterService;
|
||||||
import we.util.Consts;
|
import we.util.Consts;
|
||||||
import we.util.JacksonUtils;
|
import we.util.JacksonUtils;
|
||||||
import we.util.MapUtil;
|
import we.util.MapUtil;
|
||||||
@@ -211,7 +212,7 @@ public class RequestInput extends RPCInput implements IInput{
|
|||||||
} else if (SERVICE_TYPE_DISCOVERY.equals(config.getServiceType())) {
|
} else if (SERVICE_TYPE_DISCOVERY.equals(config.getServiceType())) {
|
||||||
if (StringUtils.isNotBlank(config.getRegistryName())) {
|
if (StringUtils.isNotBlank(config.getRegistryName())) {
|
||||||
// support choosing registry center
|
// support choosing registry center
|
||||||
host = config.getRegistryName() + Consts.S.COMMA + host;
|
host = RegistryCenterService.getServiceNameSpace(config.getRegistryName(), host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import we.plugin.auth.ApiConfig;
|
|||||||
import we.plugin.auth.ApiConfigService;
|
import we.plugin.auth.ApiConfigService;
|
||||||
import we.plugin.auth.CallbackConfig;
|
import we.plugin.auth.CallbackConfig;
|
||||||
import we.plugin.auth.Receiver;
|
import we.plugin.auth.Receiver;
|
||||||
|
import we.service_registry.RegistryCenterService;
|
||||||
import we.util.*;
|
import we.util.*;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
@@ -243,11 +244,7 @@ public class CallbackService {
|
|||||||
for (ServiceTypePath stp : req.assignServices) {
|
for (ServiceTypePath stp : req.assignServices) {
|
||||||
if (stp.type == ApiConfig.Type.SERVICE_DISCOVERY) {
|
if (stp.type == ApiConfig.Type.SERVICE_DISCOVERY) {
|
||||||
String svc = null;
|
String svc = null;
|
||||||
if (stp.registryCenter == null) {
|
svc = RegistryCenterService.getServiceNameSpace(stp.registryCenter, stp.service);
|
||||||
svc = stp.service;
|
|
||||||
} else {
|
|
||||||
svc = stp.registryCenter + Consts.S.COMMA + stp.service;
|
|
||||||
}
|
|
||||||
send = fizzWebClient.send2service(req.id, req.method, svc, stp.path, req.headers, req.body)
|
send = fizzWebClient.send2service(req.id, req.method, svc, stp.path, req.headers, req.body)
|
||||||
.onErrorResume( crError(req, stp.service, stp.path) );
|
.onErrorResume( crError(req, stp.service, stp.path) );
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -24,8 +24,10 @@ import org.springframework.stereotype.Service;
|
|||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
import we.config.AggregateRedisConfig;
|
import we.config.AggregateRedisConfig;
|
||||||
|
import we.util.Consts;
|
||||||
import we.util.JacksonUtils;
|
import we.util.JacksonUtils;
|
||||||
import we.util.Result;
|
import we.util.Result;
|
||||||
|
import we.util.ThreadContext;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -144,4 +146,12 @@ public class RegistryCenterService {
|
|||||||
public String getInstance(String registryCenter, String service) {
|
public String getInstance(String registryCenter, String service) {
|
||||||
return registryCenterMap.get(registryCenter).getInstance(service);
|
return registryCenterMap.get(registryCenter).getInstance(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getServiceNameSpace(String registryCenter, String service) {
|
||||||
|
if (registryCenter == null) {
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
StringBuilder b = ThreadContext.getStringBuilder(ThreadContext.sb0);
|
||||||
|
return b.append(registryCenter).append(Consts.S.COMMA).append(service).toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user