Merge branch 'develop' into master

This commit is contained in:
hongqiaowei
2021-08-03 13:13:11 +08:00
committed by GitHub
15 changed files with 134 additions and 97 deletions

67
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@@ -0,0 +1,67 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '15 13 * * 4'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'java', 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

1
.gitignore vendored
View File

@@ -6,3 +6,4 @@
.factorypath
.idea
/fizz-gateway-community.iml
*.iml

View File

@@ -108,6 +108,7 @@ Starting from v1.3.0, the frontend and backend of the management backend are mer
| v2.2.1 | v2.2.1 |
| v2.2.2 | v2.2.2 |
Please download the corresponding management backend version according to the version of the community version
## Deployment instructions

View File

@@ -108,6 +108,7 @@ API地址http://demo.fizzgate.com/proxy/[服务名]/[API_Path]
| v2.2.1 | v2.2.1 |
| v2.2.2 | v2.2.2 |
请根据社区版的版本下载对应的管理后台版本
## 部署说明

View File

@@ -20,10 +20,10 @@
<spring-session-bom.version>Dragonfruit-SR3</spring-session-bom.version>
<reactor-bom.version>Dysprosium-SR21</reactor-bom.version>
<lettuce.version>5.3.7.RELEASE</lettuce.version>
<netty.version>4.1.65.Final</netty.version>
<netty.version>4.1.66.Final</netty.version>
<httpcore.version>4.4.14</httpcore.version>
<log4j2.version>2.14.1</log4j2.version>
<slf4j.version>1.7.31</slf4j.version>
<slf4j.version>1.7.32</slf4j.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<lombok.version>1.18.20</lombok.version>
<apache.dubbo.version>2.7.5</apache.dubbo.version>
@@ -46,6 +46,12 @@
<artifactId>fizz-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<!-- import fizz-input-mysql -->
<!-- <dependency>
<groupId>com.fizzgate</groupId>
<artifactId>fizz-input-mysql</artifactId>
<version>${project.version}</version>
</dependency> -->
</dependencies>
<profiles>

View File

@@ -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>

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -10,15 +10,17 @@
<reactor-bom.version>Dysprosium-SR21</reactor-bom.version>
<lettuce.version>5.3.7.RELEASE</lettuce.version>
<nacos.cloud.version>2.2.5.RELEASE</nacos.cloud.version>
<netty.version>4.1.65.Final</netty.version>
<netty.version>4.1.66.Final</netty.version>
<httpcore.version>4.4.14</httpcore.version>
<log4j2.version>2.14.1</log4j2.version>
<slf4j.version>1.7.31</slf4j.version>
<slf4j.version>1.7.32</slf4j.version>
<apache.dubbo.version>2.7.5</apache.dubbo.version>
<grpc.version>1.16.1</grpc.version>
<mockito.version>3.4.6</mockito.version>
<curator.version>4.0.1</curator.version>
<zookeeper.version>3.5.9</zookeeper.version>
<r2dbc-mysql.version>0.8.2</r2dbc-mysql.version>
<reflections.version>0.9.12</reflections.version>
</properties>
<parent>
@@ -39,6 +41,7 @@
<module>fizz-plugin</module>
<!--<module>fizz-bootstrap</module>-->
<module>fizz-spring-boot-starter</module>
<!--<module>fizz-input-mysql</module>-->
</modules>
<repositories>
@@ -185,7 +188,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.8.0</version>
<version>2.11.0</version>
</dependency>
<dependency>