mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-15 12:32:09 +08:00
把一些异步参数从公共Condition移入WhenCondition
This commit is contained in:
@@ -106,7 +106,7 @@ public class LiteFlowChainBuilder {
|
||||
} else if (condition.getConditionType().equals(ConditionTypeEnum.TYPE_WHEN)) {
|
||||
if (this.conditionList.size() >= 1 &&
|
||||
CollectionUtil.getLast(this.conditionList) instanceof WhenCondition &&
|
||||
CollectionUtil.getLast(this.conditionList).getGroup().equals(condition.getGroup())) {
|
||||
((WhenCondition)CollectionUtil.getLast(this.conditionList)).getGroup().equals(((WhenCondition)condition).getGroup())) {
|
||||
CollectionUtil.getLast(this.conditionList).getExecutableList().addAll(condition.getExecutableList());
|
||||
} else {
|
||||
this.conditionList.add(condition);
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.common.LocalDefaultFlowConstant;
|
||||
import com.yomahub.liteflow.enums.ConditionTypeEnum;
|
||||
import com.yomahub.liteflow.flow.element.condition.Condition;
|
||||
import com.yomahub.liteflow.flow.element.condition.WhenCondition;
|
||||
|
||||
/**
|
||||
* WhenCondition基于代码形式的组装器
|
||||
@@ -18,7 +19,8 @@ public class LiteFlowWhenConditionBuilder extends LiteFlowConditionBuilder{
|
||||
}
|
||||
|
||||
public LiteFlowWhenConditionBuilder setErrorResume(boolean errorResume){
|
||||
this.condition.setErrorResume(errorResume);
|
||||
WhenCondition whenCondition = (WhenCondition) this.condition;
|
||||
whenCondition.setErrorResume(errorResume);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -30,16 +32,18 @@ public class LiteFlowWhenConditionBuilder extends LiteFlowConditionBuilder{
|
||||
}
|
||||
|
||||
public LiteFlowWhenConditionBuilder setGroup(String group){
|
||||
WhenCondition whenCondition = (WhenCondition) this.condition;
|
||||
if (StrUtil.isBlank(group)){
|
||||
this.condition.setGroup(LocalDefaultFlowConstant.DEFAULT);
|
||||
whenCondition.setGroup(LocalDefaultFlowConstant.DEFAULT);
|
||||
}else{
|
||||
this.condition.setGroup(group);
|
||||
whenCondition.setGroup(group);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LiteFlowWhenConditionBuilder setAny(boolean any){
|
||||
this.condition.setAny(any);
|
||||
WhenCondition whenCondition = (WhenCondition) this.condition;
|
||||
whenCondition.setAny(any);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -52,10 +56,11 @@ public class LiteFlowWhenConditionBuilder extends LiteFlowConditionBuilder{
|
||||
|
||||
|
||||
public LiteFlowWhenConditionBuilder setThreadExecutorClass(String executorServiceName){
|
||||
WhenCondition whenCondition = (WhenCondition) this.condition;
|
||||
if (StrUtil.isBlank(executorServiceName)) {
|
||||
return this;
|
||||
}
|
||||
this.condition.setThreadExecutorClass(executorServiceName);
|
||||
whenCondition.setThreadExecutorClass(executorServiceName);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.ql.util.express.Operator;
|
||||
import com.yomahub.liteflow.exception.ELParseException;
|
||||
import com.yomahub.liteflow.flow.element.Executable;
|
||||
import com.yomahub.liteflow.flow.element.condition.Condition;
|
||||
import com.yomahub.liteflow.flow.element.condition.WhenCondition;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -29,9 +30,9 @@ public class IgnoreErrorOperator extends Operator {
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
Condition condition;
|
||||
if (objects[0] instanceof Condition){
|
||||
condition = (Condition) objects[0];
|
||||
WhenCondition condition;
|
||||
if (objects[0] instanceof WhenCondition){
|
||||
condition = (WhenCondition) objects[0];
|
||||
}else{
|
||||
LOG.error("The caller must be executable item!");
|
||||
throw new Exception();
|
||||
|
||||
@@ -26,17 +26,7 @@ public abstract class Condition implements Executable{
|
||||
//可执行元素的集合
|
||||
private List<Executable> executableList = new ArrayList<>();
|
||||
|
||||
//只在when类型下有效,以区分当when调用链调用失败时是否继续往下执行 默认false不继续执行
|
||||
private boolean errorResume = false;
|
||||
|
||||
//只在when类型下有效,用于不同node进行同组合并,相同的组会进行合并,不同的组不会进行合并
|
||||
private String group = LocalDefaultFlowConstant.DEFAULT;
|
||||
|
||||
//只在when类型下有效,为true的话说明在多个并行节点下,任意一个成功,整个when就成功
|
||||
private boolean any = false;
|
||||
|
||||
// when单独的线程池名称
|
||||
private String threadExecutorClass;
|
||||
|
||||
//当前所在的ChainName
|
||||
//如果对于子流程来说,那这个就是子流程所在的Chain
|
||||
@@ -64,40 +54,8 @@ public abstract class Condition implements Executable{
|
||||
this.executableList.add(executable);
|
||||
}
|
||||
|
||||
public boolean isErrorResume() {
|
||||
return errorResume;
|
||||
}
|
||||
|
||||
public void setErrorResume(boolean errorResume) {
|
||||
this.errorResume = errorResume;
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setGroup(String group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public abstract ConditionTypeEnum getConditionType();
|
||||
|
||||
public boolean isAny() {
|
||||
return any;
|
||||
}
|
||||
|
||||
public void setAny(boolean any) {
|
||||
this.any = any;
|
||||
}
|
||||
|
||||
public String getThreadExecutorClass() {
|
||||
return threadExecutorClass;
|
||||
}
|
||||
|
||||
public void setThreadExecutorClass(String threadExecutorClass) {
|
||||
this.threadExecutorClass = threadExecutorClass;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.yomahub.liteflow.flow.element.condition;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.common.LocalDefaultFlowConstant;
|
||||
import com.yomahub.liteflow.enums.ConditionTypeEnum;
|
||||
import com.yomahub.liteflow.exception.WhenExecuteException;
|
||||
import com.yomahub.liteflow.flow.parallel.CompletableFutureTimeout;
|
||||
@@ -35,6 +36,18 @@ public class WhenCondition extends Condition {
|
||||
|
||||
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
//只在when类型下有效,以区分当when调用链调用失败时是否继续往下执行 默认false不继续执行
|
||||
private boolean errorResume = false;
|
||||
|
||||
//只在when类型下有效,用于不同node进行同组合并,相同的组会进行合并,不同的组不会进行合并
|
||||
private String group = LocalDefaultFlowConstant.DEFAULT;
|
||||
|
||||
//只在when类型下有效,为true的话说明在多个并行节点下,任意一个成功,整个when就成功
|
||||
private boolean any = false;
|
||||
|
||||
// when单独的线程池名称
|
||||
private String threadExecutorClass;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Integer slotIndex) throws Exception {
|
||||
@@ -154,4 +167,36 @@ public class WhenCondition extends Condition {
|
||||
LOG.warn("requestId [{}] executing when condition timeout , but ignore with errorResume.", slot.getRequestId());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isErrorResume() {
|
||||
return errorResume;
|
||||
}
|
||||
|
||||
public void setErrorResume(boolean errorResume) {
|
||||
this.errorResume = errorResume;
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setGroup(String group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public boolean isAny() {
|
||||
return any;
|
||||
}
|
||||
|
||||
public void setAny(boolean any) {
|
||||
this.any = any;
|
||||
}
|
||||
|
||||
public String getThreadExecutorClass() {
|
||||
return threadExecutorClass;
|
||||
}
|
||||
|
||||
public void setThreadExecutorClass(String threadExecutorClass) {
|
||||
this.threadExecutorClass = threadExecutorClass;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user