Merge branch 'develop' into master
This commit is contained in:
@@ -225,6 +225,12 @@
|
||||
</dependency>
|
||||
<!-- grpc -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>${reflections.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.curator</groupId>
|
||||
<artifactId>curator-client</artifactId>
|
||||
@@ -279,5 +285,13 @@
|
||||
<id>repo</id>
|
||||
<url>file://${project.basedir}/../repo</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype-snapshots</id>
|
||||
<name>SonaType Snapshots</name>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
@@ -31,15 +31,10 @@ import org.apache.commons.io.FileUtils;
|
||||
import org.noear.snack.ONode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.ReactiveStringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import we.fizz.input.extension.grpc.GrpcInput;
|
||||
import we.fizz.input.extension.dubbo.DubboInput;
|
||||
import we.fizz.input.extension.mysql.MySQLInput;
|
||||
import we.fizz.input.extension.request.RequestInput;
|
||||
import we.flume.clients.log4j2appender.LogService;
|
||||
import we.util.Constants;
|
||||
import we.util.ReactorUtils;
|
||||
@@ -55,11 +50,7 @@ import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
@@ -147,10 +138,6 @@ public class ConfigLoader {
|
||||
public Pipeline createPipeline(String configStr) throws IOException {
|
||||
ONode cfgNode = ONode.loadStr(configStr);
|
||||
|
||||
InputFactory.registerInput(RequestInput.TYPE, RequestInput.class);
|
||||
InputFactory.registerInput(MySQLInput.TYPE, MySQLInput.class);
|
||||
InputFactory.registerInput(GrpcInput.TYPE, GrpcInput.class);
|
||||
InputFactory.registerInput(DubboInput.TYPE, DubboInput.class);
|
||||
Pipeline pipeline = new Pipeline();
|
||||
pipeline.setApplicationContext(appContext);
|
||||
|
||||
@@ -213,8 +200,10 @@ public class ConfigLoader {
|
||||
@PostConstruct
|
||||
public synchronized void init() throws Exception {
|
||||
this.refreshLocalCache();
|
||||
InputFactory.loadInputClasses();
|
||||
}
|
||||
|
||||
|
||||
public synchronized void refreshLocalCache() throws Exception {
|
||||
if (formalPathPrefix == null) {
|
||||
formalPathPrefix = appContext.getEnvironment().getProperty("gateway.prefix", "/proxy");
|
||||
@@ -372,6 +361,8 @@ public class ConfigLoader {
|
||||
}
|
||||
}
|
||||
String key = method.toUpperCase() + ":" + path;
|
||||
// config file entry ,if you want modify the aggregate config json but not use the interface of fizz,
|
||||
// you can just read the config ,transform to json format and modify it
|
||||
if (aggregateResources.containsKey(key) && aggregateResources.get(key) != null) {
|
||||
String configStr = aggregateResources.get(key);
|
||||
Input input = null;
|
||||
|
||||
@@ -44,6 +44,7 @@ import we.fizz.component.IComponent;
|
||||
import we.fizz.component.StepContextPosition;
|
||||
import we.fizz.component.circle.Circle;
|
||||
import we.fizz.component.condition.Condition;
|
||||
import we.fizz.exception.FizzRuntimeException;
|
||||
import we.fizz.input.Input;
|
||||
import we.fizz.input.InputConfig;
|
||||
import we.fizz.input.InputContext;
|
||||
|
||||
@@ -278,7 +278,7 @@ public class Circle implements IComponent {
|
||||
ONode ctxNode = circleItemResult.ctxNode;
|
||||
PathMapping.setByPath(ctxNode, stepCtxPos.getPath() + ".item", cItem.getItem(), true);
|
||||
PathMapping.setByPath(ctxNode, stepCtxPos.getPath() + ".index", cItem.getIndex(), true);
|
||||
|
||||
|
||||
if (!this.canExec(cItem.getIndex(), ctxNode, stepContext, stepCtxPos)) {
|
||||
CircleItem nextItem2 = this.next(ctxNode);
|
||||
if (nextItem2 == null) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import we.fizz.StepContext;
|
||||
import we.fizz.StepResponse;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IInput {
|
||||
|
||||
@@ -17,8 +17,11 @@
|
||||
package we.fizz.input;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import org.reflections.Reflections;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import reactor.core.publisher.Mono;
|
||||
import we.fizz.Step;
|
||||
@@ -95,4 +98,14 @@ public class Input {
|
||||
return InputConfig.class;
|
||||
}
|
||||
|
||||
public static void initialize(Class<?>clazz) throws IllegalAccessException {
|
||||
Field field = null;
|
||||
try {
|
||||
field = clazz.getDeclaredField("TYPE");
|
||||
InputFactory.registerInput((InputType) field.get(null), clazz);
|
||||
} catch (NoSuchFieldException e) {
|
||||
// doing nothing is right
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package we.fizz.input;
|
||||
|
||||
import we.fizz.component.ComponentHelper;
|
||||
import org.reflections.Reflections;
|
||||
import we.fizz.exception.FizzRuntimeException;
|
||||
import we.fizz.input.extension.request.RequestInput;
|
||||
|
||||
@@ -27,6 +28,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -68,8 +70,9 @@ public class InputFactory {
|
||||
inputConfig.setComponents(ComponentHelper.buildComponents((List<Map<String, Object>>) config.get("components")));
|
||||
inputConfig.parse();
|
||||
return inputConfig;
|
||||
} else {
|
||||
throw new FizzRuntimeException("can't find input config type:" + type);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Input createInput(String type) {
|
||||
@@ -87,8 +90,17 @@ public class InputFactory {
|
||||
LOGGER.error("failed to create input config, error: {}", e.getMessage(), e);
|
||||
throw new FizzRuntimeException("failed to create input config, message: " + e.getMessage(), e);
|
||||
}
|
||||
} else {
|
||||
throw new FizzRuntimeException("can't find input type:" + type);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void loadInputClasses() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
Reflections reflections = new Reflections("we.fizz.input");
|
||||
Set<Class<? extends Input>> subTypes = reflections.getSubTypesOf(Input.class);
|
||||
for (Class<?>inputType : subTypes){
|
||||
Method initializeMethod = inputType.getMethod("initialize", Class.class);
|
||||
initializeMethod.invoke(null, inputType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 the original author or authors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package we.fizz.input.extension.mysql;
|
||||
|
||||
import we.fizz.input.IInput;
|
||||
import we.fizz.input.Input;
|
||||
import we.fizz.input.InputType;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author linwaiwai
|
||||
*
|
||||
*/
|
||||
|
||||
public class MySQLInput extends Input implements IInput {
|
||||
static public InputType TYPE = new InputType("MYSQL");
|
||||
public static Class inputConfigClass (){
|
||||
return MySQLInputConfig.class;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 the original author or authors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package we.fizz.input.extension.mysql;
|
||||
|
||||
import we.fizz.input.InputConfig;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author linwaiwai
|
||||
*
|
||||
*/
|
||||
public class MySQLInputConfig extends InputConfig {
|
||||
|
||||
public MySQLInputConfig(Map configBody) {
|
||||
super(configBody);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user