Browse Source

next_filter重命名为dispatcher 明确定义

master
yechuan 1 year ago
parent
commit
0fb7bca14b
3 changed files with 11 additions and 10 deletions
  1. +3
    -3
      common/src/main/java/work/xuye/common/db/entity/Task.java
  2. +2
    -1
      common/src/main/java/work/xuye/common/db/entity/vo/Dispatcher.java
  3. +6
    -6
      source/src/main/java/work/xuye/source/handler/SourceHandler.java

+ 3
- 3
common/src/main/java/work/xuye/common/db/entity/Task.java View File

@@ -9,7 +9,7 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import work.xuye.common.db.entity.vo.NextTaskFilter;
import work.xuye.common.db.entity.vo.Dispatcher;
import work.xuye.common.db.entity.vo.ParseParams;
import work.xuye.common.db.entity.vo.SinkParams;
import work.xuye.common.db.entity.vo.TransformParams;
@@ -59,8 +59,8 @@ public class Task implements Serializable {
@TableField(value = "sink_params", typeHandler = JacksonTypeHandler.class)
private SinkParams sinkParams;

@TableField(value = "next_filter", typeHandler = JacksonTypeHandler.class)
private NextTaskFilter nextFilter;
@TableField(value = "dispatcher", typeHandler = JacksonTypeHandler.class)
private Dispatcher dispatcher;

@TableField(value = "create_time", fill = FieldFill.INSERT)
@JsonDeserialize(using = LocalDateTimeDeserializer.class)


common/src/main/java/work/xuye/common/db/entity/vo/NextTaskFilter.java → common/src/main/java/work/xuye/common/db/entity/vo/Dispatcher.java View File

@@ -8,13 +8,14 @@ import java.util.List;
import java.util.Map;

/**
* 分流设置
* @author yechuan
* @since 2023/8/8 19:09
**/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class NextTaskFilter {
public class Dispatcher {
/**
* 参与计算的jsonPath
*/

+ 6
- 6
source/src/main/java/work/xuye/source/handler/SourceHandler.java View File

@@ -15,7 +15,7 @@ import org.springframework.util.DigestUtils;
import org.springframework.util.ObjectUtils;
import work.xuye.common.constant.*;
import work.xuye.common.db.entity.Task;
import work.xuye.common.db.entity.vo.NextTaskFilter;
import work.xuye.common.db.entity.vo.Dispatcher;
import work.xuye.common.db.entity.vo.TaskMiniVO;
import work.xuye.common.db.service.TaskManager;
import work.xuye.common.dto.HttpRequestParams;
@@ -120,7 +120,7 @@ public class SourceHandler {
return null;
}

if (Objects.nonNull(task.getNextFilter())) {
if (Objects.nonNull(task.getDispatcher())) {

Map<String, Message> nextNodeMessage = buildNextNodeMessage(result, task, message);

@@ -163,7 +163,7 @@ public class SourceHandler {
}

private Map<String, Message> buildNextNodeMessage(List<HttpRes> result, Task task, Message<TaskMiniVO> message) {
NextTaskFilter filter = task.getNextFilter();
Dispatcher filter = task.getDispatcher();

Map<String, Message> resultMap = new HashMap<>();
result.stream()
@@ -174,7 +174,7 @@ public class SourceHandler {
.headers(item.getHeaders())
.requestParams(item.getRequestParams());
httpRes.setResourceStatus(item.getResourceStatus());
httpRes.setTemporary(JsonPathUtil.read(item.getBody(), task.getNextFilter().getFilterArgs()));
httpRes.setTemporary(JsonPathUtil.read(item.getBody(), task.getDispatcher().getFilterArgs()));
return httpRes;
})
.flatMap(item -> {
@@ -210,7 +210,7 @@ public class SourceHandler {
}

// 节点命中
List<NextTaskFilter.NextNodeConfig> nextNodes = filter.getNextNodes();
List<Dispatcher.NextNodeConfig> nextNodes = filter.getNextNodes();
if (ObjectUtils.isEmpty(nextNodes)) {
return;
}
@@ -218,7 +218,7 @@ public class SourceHandler {
context.setVariable("filterArgs", map);
context.setVariable("httpRes", httpRes);

for (NextTaskFilter.NextNodeConfig nextNode : nextNodes) {
for (Dispatcher.NextNodeConfig nextNode : nextNodes) {

if (!Boolean.TRUE.equals(getPlaceholderSpel(nextNode.getCondition(), filter.getPlaceholderExpressions(), context, Boolean.class))) {
continue;


Loading…
Cancel
Save