Merge remote-tracking branch 'we__/develop' into develop

This commit is contained in:
hongqiaowei
2022-03-22 16:54:36 +08:00
3 changed files with 21 additions and 9 deletions

View File

@@ -44,6 +44,7 @@ import javax.annotation.Resource;
import static we.config.AggregateRedisConfig.AGGREGATE_REACTIVE_REDIS_TEMPLATE; import static we.config.AggregateRedisConfig.AGGREGATE_REACTIVE_REDIS_TEMPLATE;
import static we.util.Consts.S.FORWARD_SLASH; import static we.util.Consts.S.FORWARD_SLASH;
import static we.util.Consts.S.FORWARD_SLASH_STR;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -206,7 +207,12 @@ public class ConfigLoader {
public synchronized void refreshLocalCache() throws Exception { public synchronized void refreshLocalCache() throws Exception {
if (formalPathPrefix == null) { if (formalPathPrefix == null) {
formalPathPrefix = appContext.getEnvironment().getProperty("gateway.prefix", "/proxy"); String formalPathPrefixTmp = appContext.getEnvironment().getProperty("gateway.prefix", "/proxy");
if (formalPathPrefixTmp.endsWith(FORWARD_SLASH_STR)) {
// remove the end slash
formalPathPrefixTmp = formalPathPrefixTmp.substring(0, formalPathPrefixTmp.length() - 1);
}
formalPathPrefix = formalPathPrefixTmp;
formalPathServiceNameStartIndex = formalPathPrefix.length() + 1; formalPathServiceNameStartIndex = formalPathPrefix.length() + 1;
} }
@@ -396,16 +402,16 @@ public class ConfigLoader {
private String extractServiceName(String path) { private String extractServiceName(String path) {
if (path != null) { if (path != null) {
if (path.startsWith(formalPathPrefix)) { if (path.startsWith(TEST_PATH_PREFIX)) {
int endIndex = path.indexOf(FORWARD_SLASH, formalPathServiceNameStartIndex);
if (endIndex > formalPathServiceNameStartIndex) {
return path.substring(formalPathServiceNameStartIndex, endIndex);
}
} else if (path.startsWith(TEST_PATH_PREFIX)) {
int endIndex = path.indexOf(FORWARD_SLASH, TEST_PATH_SERVICE_NAME_START_INDEX); int endIndex = path.indexOf(FORWARD_SLASH, TEST_PATH_SERVICE_NAME_START_INDEX);
if (endIndex > TEST_PATH_SERVICE_NAME_START_INDEX) { if (endIndex > TEST_PATH_SERVICE_NAME_START_INDEX) {
return path.substring(TEST_PATH_SERVICE_NAME_START_INDEX, endIndex); return path.substring(TEST_PATH_SERVICE_NAME_START_INDEX, endIndex);
} }
} else if (path.startsWith(formalPathPrefix)) {
int endIndex = path.indexOf(FORWARD_SLASH, formalPathServiceNameStartIndex);
if (endIndex > formalPathServiceNameStartIndex) {
return path.substring(formalPathServiceNameStartIndex, endIndex);
}
} }
} }
return null; return null;

View File

@@ -216,6 +216,9 @@ public class Pipeline {
List<Mono> monos = step.run(); List<Mono> monos = step.run();
Mono<Map>[] monoArray = monos.stream().toArray(Mono[]::new); Mono<Map>[] monoArray = monos.stream().toArray(Mono[]::new);
Mono<StepResponse>result = Flux.merge(monoArray).reduce(new HashMap(), (item1, item2) -> { Mono<StepResponse>result = Flux.merge(monoArray).reduce(new HashMap(), (item1, item2) -> {
if (item2.isEmpty()) {
return item1;
}
Input input = (Input)item2.get("request"); Input input = (Input)item2.get("request");
item1.put(input.getName() , item2.get("data")); item1.put(input.getName() , item2.get("data"));
return item1; return item1;

View File

@@ -132,7 +132,10 @@ public class Step {
if (input.needRun(ctx)) { if (input.needRun(ctx)) {
return input.run(); return input.run();
} }
return Mono.just(new HashMap()); Map<String, Object> inputResult = new HashMap<String, Object>();
inputResult.put("data", new HashMap<String, Object>());
inputResult.put("request", input);
return Mono.just(inputResult);
}).flatMap(r -> { }).flatMap(r -> {
if (r instanceof ComponentResult) { if (r instanceof ComponentResult) {
Map<String, Object> inputResult = new HashMap<String, Object>(); Map<String, Object> inputResult = new HashMap<String, Object>();