feature #I9DQDU 允许对不存在的组件增加全局参数
This commit is contained in:
parent
e3cfe56308
commit
59f67bc546
|
@ -10,6 +10,7 @@ import com.ql.util.express.InstructionSet;
|
|||
import com.ql.util.express.exception.QLException;
|
||||
import com.yomahub.liteflow.builder.el.operator.*;
|
||||
import com.yomahub.liteflow.common.ChainConstant;
|
||||
import com.yomahub.liteflow.enums.ParseModeEnum;
|
||||
import com.yomahub.liteflow.exception.*;
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.element.Chain;
|
||||
|
@ -184,7 +185,7 @@ public class LiteFlowChainELBuilder {
|
|||
this.chain.setEl(elStr);
|
||||
LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
|
||||
// 如果设置了不检查Node是否存在,那么这里是不解析的
|
||||
if (BooleanUtil.isFalse(liteflowConfig.getCheckNodeExists())){
|
||||
if (liteflowConfig.getParseMode().equals(ParseModeEnum.PARSE_ONE_ON_FIRST_EXEC)){
|
||||
this.chain.setCompiled(false);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import cn.hutool.core.map.MapUtil;
|
|||
import cn.hutool.core.util.*;
|
||||
import com.yomahub.liteflow.enums.ChainExecuteModeEnum;
|
||||
import com.yomahub.liteflow.enums.InnerChainTypeEnum;
|
||||
import com.yomahub.liteflow.enums.ParseModeEnum;
|
||||
import com.yomahub.liteflow.exception.*;
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
|
@ -72,7 +73,7 @@ public class FlowExecutor {
|
|||
LiteflowConfigGetter.setLiteflowConfig(liteflowConfig);
|
||||
// 设置FlowExecutor的Holder,虽然大部分地方都可以通过Spring上下文获取到,但放入Holder,还是为了某些地方能方便的取到
|
||||
FlowExecutorHolder.setHolder(this);
|
||||
if (BooleanUtil.isTrue(liteflowConfig.isParseOnStart())) {
|
||||
if (!liteflowConfig.getParseMode().equals(ParseModeEnum.PARSE_ALL_ON_FIRST_EXEC)) {
|
||||
this.init(true);
|
||||
}
|
||||
// 初始化DataBus
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.yomahub.liteflow.enums;
|
||||
|
||||
/**
|
||||
* 解析模式
|
||||
* PARSE_ALL_ON_START 启动时解析所有的规则
|
||||
* PARSE_ALL_ON_FIRST_EXEC 第一次执行链路时解析所有的规则
|
||||
* PARSE_ONE_ON_FIRST_EXEC 第一次执行相关链路时解析当前的规则
|
||||
*
|
||||
* @author Bryan.Zhang
|
||||
* @since 2.12.0
|
||||
*/
|
||||
public enum ParseModeEnum {
|
||||
|
||||
PARSE_ALL_ON_START,
|
||||
PARSE_ALL_ON_FIRST_EXEC,
|
||||
PARSE_ONE_ON_FIRST_EXEC
|
||||
}
|
|
@ -10,6 +10,7 @@ package com.yomahub.liteflow.property;
|
|||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.enums.ParseModeEnum;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -71,9 +72,8 @@ public class LiteflowConfig {
|
|||
// 异步线程池最大队列数量
|
||||
private Integer whenQueueLimit;
|
||||
|
||||
// 是否在启动时解析规则文件
|
||||
// 这个参数主要给编码式注册元数据的场景用的,结合FlowBus.addNode一起用
|
||||
private Boolean parseOnStart;
|
||||
// 解析模式,一共有三种,具体看其定义
|
||||
private ParseModeEnum parseMode;
|
||||
|
||||
// 这个属性为true,则支持多种不同的类型的配置
|
||||
// 但是要注意,不能将主流程和子流程分配在不同类型配置文件中
|
||||
|
@ -118,9 +118,6 @@ public class LiteflowConfig {
|
|||
//是否快速加载规则,如果快速加载规则意味着不用copyOnWrite机制了
|
||||
private Boolean fastLoad;
|
||||
|
||||
//检查node是否存在
|
||||
private Boolean checkNodeExists;
|
||||
|
||||
public Boolean getEnableMonitorFile() {
|
||||
return enableMonitorFile;
|
||||
}
|
||||
|
@ -254,19 +251,6 @@ public class LiteflowConfig {
|
|||
this.whenQueueLimit = whenQueueLimit;
|
||||
}
|
||||
|
||||
public Boolean isParseOnStart() {
|
||||
if (ObjectUtil.isNull(parseOnStart)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
else {
|
||||
return parseOnStart;
|
||||
}
|
||||
}
|
||||
|
||||
public void setParseOnStart(Boolean parseOnStart) {
|
||||
this.parseOnStart = parseOnStart;
|
||||
}
|
||||
|
||||
public Boolean isSupportMultipleType() {
|
||||
if (ObjectUtil.isNull(supportMultipleType)) {
|
||||
return Boolean.FALSE;
|
||||
|
@ -494,15 +478,15 @@ public class LiteflowConfig {
|
|||
this.fastLoad = fastLoad;
|
||||
}
|
||||
|
||||
public Boolean getCheckNodeExists() {
|
||||
if (ObjectUtil.isNull(checkNodeExists)){
|
||||
return Boolean.TRUE;
|
||||
public ParseModeEnum getParseMode() {
|
||||
if (ObjectUtil.isNull(parseMode)) {
|
||||
return ParseModeEnum.PARSE_ALL_ON_START;
|
||||
}else{
|
||||
return checkNodeExists;
|
||||
return parseMode;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCheckNodeExists(Boolean checkNodeExists) {
|
||||
this.checkNodeExists = checkNodeExists;
|
||||
public void setParseMode(ParseModeEnum parseMode) {
|
||||
this.parseMode = parseMode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class LiteflowAutoConfiguration {
|
|||
liteflowConfig.setPeriod(liteflowMonitorProperty.getPeriod());
|
||||
liteflowConfig.setWhenMaxWorkers(property.getWhenMaxWorkers());
|
||||
liteflowConfig.setWhenQueueLimit(property.getWhenQueueLimit());
|
||||
liteflowConfig.setParseOnStart(property.isParseOnStart());
|
||||
liteflowConfig.setParseMode(property.getParseMode());
|
||||
liteflowConfig.setEnable(property.isEnable());
|
||||
liteflowConfig.setSupportMultipleType(property.isSupportMultipleType());
|
||||
liteflowConfig.setRetryCount(property.getRetryCount());
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.yomahub.liteflow.solon.config;
|
||||
|
||||
import com.yomahub.liteflow.enums.ParseModeEnum;
|
||||
import org.noear.solon.annotation.Configuration;
|
||||
import org.noear.solon.annotation.Inject;
|
||||
|
||||
|
@ -44,9 +45,8 @@ public class LiteflowProperty {
|
|||
// 异步线程池最大队列数量
|
||||
private int whenQueueLimit;
|
||||
|
||||
// 是否在启动时解析规则文件
|
||||
// 这个参数主要给编码式注册元数据的场景用的,结合FlowBus.addNode一起用
|
||||
private boolean parseOnStart;
|
||||
// 解析模式,一共有三种,具体看其定义
|
||||
private ParseModeEnum parseMode;
|
||||
|
||||
// 这个属性为true,则支持多种不同的类型的配置
|
||||
// 但是要注意,不能将主流程和子流程分配在不同类型配置文件中
|
||||
|
@ -132,14 +132,6 @@ public class LiteflowProperty {
|
|||
this.whenQueueLimit = whenQueueLimit;
|
||||
}
|
||||
|
||||
public boolean isParseOnStart() {
|
||||
return parseOnStart;
|
||||
}
|
||||
|
||||
public void setParseOnStart(boolean parseOnStart) {
|
||||
this.parseOnStart = parseOnStart;
|
||||
}
|
||||
|
||||
public boolean isSupportMultipleType() {
|
||||
return supportMultipleType;
|
||||
}
|
||||
|
@ -251,4 +243,12 @@ public class LiteflowProperty {
|
|||
public void setFallbackCmpEnable(Boolean fallbackCmpEnable) {
|
||||
this.fallbackCmpEnable = fallbackCmpEnable;
|
||||
}
|
||||
|
||||
public ParseModeEnum getParseMode() {
|
||||
return parseMode;
|
||||
}
|
||||
|
||||
public void setParseMode(ParseModeEnum parseMode) {
|
||||
this.parseMode = parseMode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.yomahub.liteflow.springboot;
|
||||
|
||||
import com.yomahub.liteflow.enums.ParseModeEnum;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -54,9 +55,8 @@ public class LiteflowProperty {
|
|||
// 异步线程池是否隔离
|
||||
private boolean whenThreadPoolIsolate;
|
||||
|
||||
// 是否在启动时解析规则文件
|
||||
// 这个参数主要给编码式注册元数据的场景用的,结合FlowBus.addNode一起用
|
||||
private boolean parseOnStart;
|
||||
// 解析模式,一共有三种,具体看其定义
|
||||
private ParseModeEnum parseMode;
|
||||
|
||||
// 这个属性为true,则支持多种不同的类型的配置
|
||||
// 但是要注意,不能将主流程和子流程分配在不同类型配置文件中
|
||||
|
@ -155,12 +155,12 @@ public class LiteflowProperty {
|
|||
this.whenQueueLimit = whenQueueLimit;
|
||||
}
|
||||
|
||||
public boolean isParseOnStart() {
|
||||
return parseOnStart;
|
||||
public ParseModeEnum getParseMode() {
|
||||
return parseMode;
|
||||
}
|
||||
|
||||
public void setParseOnStart(boolean parseOnStart) {
|
||||
this.parseOnStart = parseOnStart;
|
||||
public void setParseMode(ParseModeEnum parseMode) {
|
||||
this.parseMode = parseMode;
|
||||
}
|
||||
|
||||
public boolean isSupportMultipleType() {
|
||||
|
|
|
@ -51,9 +51,17 @@ public class LiteflowMainAutoConfiguration {
|
|||
}
|
||||
|
||||
// FlowExecutor的初始化工作,和实例化分开来
|
||||
// 这里写2个几乎一样的是因为无论是在PARSE_ALL_ON_START或者PARSE_ONE_ON_FIRST_EXEC模式下,都需要初始化工作
|
||||
// 换句话说,这两个只可能被执行一个
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "liteflow", name = "parse-on-start", havingValue = "true")
|
||||
public LiteflowExecutorInit liteflowExecutorInit(FlowExecutor flowExecutor) {
|
||||
@ConditionalOnProperty(prefix = "liteflow", name = "parse-mode", havingValue = "PARSE_ALL_ON_START")
|
||||
public LiteflowExecutorInit liteflowExecutorInit1(FlowExecutor flowExecutor) {
|
||||
return new LiteflowExecutorInit(flowExecutor);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "liteflow", name = "parse-mode", havingValue = "PARSE_ONE_ON_FIRST_EXEC")
|
||||
public LiteflowExecutorInit liteflowExecutorInit2(FlowExecutor flowExecutor) {
|
||||
return new LiteflowExecutorInit(flowExecutor);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public class LiteflowPropertyAutoConfiguration {
|
|||
liteflowConfig.setWhenMaxWorkers(property.getWhenMaxWorkers());
|
||||
liteflowConfig.setWhenQueueLimit(property.getWhenQueueLimit());
|
||||
liteflowConfig.setWhenThreadPoolIsolate(property.isWhenThreadPoolIsolate());
|
||||
liteflowConfig.setParseOnStart(property.isParseOnStart());
|
||||
liteflowConfig.setParseMode(property.getParseMode());
|
||||
liteflowConfig.setEnable(property.isEnable());
|
||||
liteflowConfig.setSupportMultipleType(property.isSupportMultipleType());
|
||||
liteflowConfig.setRetryCount(property.getRetryCount());
|
||||
|
@ -49,7 +49,6 @@ public class LiteflowPropertyAutoConfiguration {
|
|||
liteflowConfig.setParallelLoopExecutorClass(property.getParallelLoopExecutorClass());
|
||||
liteflowConfig.setFallbackCmpEnable(property.isFallbackCmpEnable());
|
||||
liteflowConfig.setFastLoad(property.isFastLoad());
|
||||
liteflowConfig.setCheckNodeExists(property.isCheckNodeExists());
|
||||
liteflowConfig.setEnableLog(liteflowMonitorProperty.isEnableLog());
|
||||
liteflowConfig.setQueueLimit(liteflowMonitorProperty.getQueueLimit());
|
||||
liteflowConfig.setDelay(liteflowMonitorProperty.getDelay());
|
||||
|
|
|
@ -111,9 +111,9 @@
|
|||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"name": "liteflow.parse-on-start",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Set whether the rule file needs to be parsed at startup.",
|
||||
"name": "liteflow.parse-mode",
|
||||
"type": "com.yomahub.liteflow.enums.ParseModeEnum",
|
||||
"description": "Set parse mode at startup.",
|
||||
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
|
||||
"defaultValue": true
|
||||
},
|
||||
|
@ -159,13 +159,6 @@
|
|||
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"name": "liteflow.check-node-exists",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Whether to check the existence of a node or not.",
|
||||
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "liteflow.monitor.enable-log",
|
||||
"type": "java.lang.Boolean",
|
||||
|
|
|
@ -10,7 +10,7 @@ liteflow.when-max-wait-time-unit=MILLISECONDS
|
|||
liteflow.when-max-workers=16
|
||||
liteflow.when-queue-limit=512
|
||||
liteflow.when-thread-pool-isolate=false
|
||||
liteflow.parse-on-start=true
|
||||
liteflow.parse-mode=PARSE_ALL_ON_START
|
||||
liteflow.retry-count=0
|
||||
liteflow.support-multiple-type=false
|
||||
liteflow.node-executor-class=com.yomahub.liteflow.flow.executor.DefaultNodeExecutor
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
liteflow.rule-source-ext-data={"chainNamespace":"chainConfig","scriptNamespace":"scriptConfig"}
|
||||
liteflow.parse-on-start=false
|
||||
liteflow.parse-mode=PARSE_ALL_ON_FIRST_EXEC
|
|
@ -3,4 +3,4 @@ liteflow.rule-source-ext-data={\
|
|||
"chainPath": "/liteflow/chain",\
|
||||
"scriptPath": "/liteflow/script"\
|
||||
}
|
||||
liteflow.parse-on-start=false
|
||||
liteflow.parse-mode=PARSE_ALL_ON_FIRST_EXEC
|
|
@ -3,4 +3,4 @@ liteflow.rule-source-ext-data={\
|
|||
"chainPath": "/liteflow/chain",\
|
||||
"scriptPath": "/liteflow/script"\
|
||||
}
|
||||
liteflow.parse-on-start=false
|
||||
liteflow.parse-mode=PARSE_ALL_ON_FIRST_EXEC
|
|
@ -1,2 +1,2 @@
|
|||
liteflow.rule-source-ext-data={"serverAddr":"192.168.10.147:8848","dataId":"LiteFlow","group":"LITE_FLOW_GROUP","namespace":"","username":"","password":""}
|
||||
liteflow.parse-on-start=false
|
||||
liteflow.parse-mode=PARSE_ALL_ON_FIRST_EXEC
|
|
@ -2,6 +2,7 @@ package com.yomahub.liteflow.test.config;
|
|||
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.core.FlowExecutorHolder;
|
||||
import com.yomahub.liteflow.enums.ParseModeEnum;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||
|
@ -43,7 +44,7 @@ public class LiteflowConfigTest1 extends BaseTest {
|
|||
Assertions.assertFalse(config.getEnableLog());
|
||||
Assertions.assertEquals(16, config.getWhenMaxWorkers().longValue());
|
||||
Assertions.assertEquals(512, config.getWhenQueueLimit().longValue());
|
||||
Assertions.assertEquals(true, config.isParseOnStart());
|
||||
Assertions.assertEquals(ParseModeEnum.PARSE_ALL_ON_START, config.getParseMode());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.yomahub.liteflow.test.flowmeta;
|
|||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.core.FlowExecutorHolder;
|
||||
import com.yomahub.liteflow.enums.NodeTypeEnum;
|
||||
import com.yomahub.liteflow.enums.ParseModeEnum;
|
||||
import com.yomahub.liteflow.flow.FlowBus;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
|
@ -20,7 +21,7 @@ public class FlowMetaTest extends BaseTest {
|
|||
public static void init() {
|
||||
LiteflowConfig config = new LiteflowConfig();
|
||||
config.setRuleSource("flowmeta/flow.el.xml");
|
||||
config.setParseOnStart(false);
|
||||
config.setParseMode(ParseModeEnum.PARSE_ALL_ON_FIRST_EXEC);
|
||||
flowExecutor = FlowExecutorHolder.loadInstance(config);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,4 +8,4 @@ liteflow.rule-source-ext-data={\
|
|||
"scriptDataBase":1,\
|
||||
"scriptKey":"pollScriptKey"\
|
||||
}
|
||||
liteflow.parse-on-start=false
|
||||
liteflow.parse-mode=PARSE_ALL_ON_FIRST_EXEC
|
|
@ -7,4 +7,4 @@ liteflow.rule-source-ext-data={\
|
|||
"scriptDataBase":1,\
|
||||
"scriptKey":"testScriptKey"\
|
||||
}
|
||||
liteflow.parse-on-start=false
|
||||
liteflow.parse-mode=PARSE_ALL_ON_FIRST_EXEC
|
|
@ -1,2 +1,2 @@
|
|||
liteflow.rule-source=uncheckNode/flow.el.xml
|
||||
liteflow.check-node-exists=false
|
||||
liteflow.parse-mode=PARSE_ONE_ON_FIRST_EXEC
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
<bean id="liteflowConfig" class="com.yomahub.liteflow.property.LiteflowConfig">
|
||||
<property name="ruleSource" value="flowmeta/flow.el.xml"/>
|
||||
<property name="parseOnStart" value="false"/>
|
||||
<property name="parseMode" value="PARSE_ALL_ON_FIRST_EXEC"/>
|
||||
</bean>
|
||||
|
||||
<bean id="flowExecutor" class="com.yomahub.liteflow.core.FlowExecutor">
|
||||
|
|
Loading…
Reference in New Issue