Skip to content

Commit

Permalink
feat(core): change error to branchType on Topology Graph
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Jan 13, 2025
1 parent 089e4d4 commit b58107e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.micronaut.core.annotation.Introspected;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
Expand All @@ -19,7 +18,7 @@ public abstract class AbstractGraph {
@JsonInclude
protected String type;
@Setter
protected boolean error;
protected BranchType branchType;

public AbstractGraph() {
this.type = this.getClass().getName();
Expand All @@ -39,8 +38,8 @@ public void updateUidWithChildren(String uid) {
this.uid = uid;
}

public void updateErrorWithChildren(boolean error) {
this.error = error;
public void updateWithChildren(BranchType branchType) {
this.branchType = branchType;
}

public AbstractGraph forExecution() {
Expand All @@ -53,4 +52,9 @@ public boolean equals(Object o) {
if (!(o instanceof AbstractGraph)) return false;
return o.hashCode() == this.hashCode();
}

public enum BranchType {
ERROR,
FINALLY
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ public void updateUidWithChildren(String uid) {
}

@Override
public void updateErrorWithChildren(boolean error) {
this.error = error;
public void updateWithChildren(BranchType branchType) {
this.branchType = branchType;

this.taskNode.error = error;
this.root.error = error;
this.end.error = error;
this.taskNode.branchType = branchType;
this.root.branchType = branchType;
this.end.branchType = branchType;
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/io/kestra/core/services/GraphService.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ public void replace() {
});
parentCluster.getGraph().removeNode(taskToReplace);

if (taskToReplace.isError()) {
clusterForReplacement.updateErrorWithChildren(true);
if (taskToReplace.getBranchType() != null) {
clusterForReplacement.updateWithChildren(taskToReplace.getBranchType());
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/java/io/kestra/core/utils/GraphUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,11 @@ private static void fillGraph(
// add the node
graph.addNode(currentGraph);

if (relationType == RelationType.ERROR || relationType == RelationType.FINALLY) {
currentGraph.updateWithChildren(AbstractGraph.BranchType.valueOf(relationType.name()));
}

if (relationType == RelationType.ERROR) {
currentGraph.updateErrorWithChildren(true);
if (isFirst) {
previous = graph.getRoot();
}
Expand Down

0 comments on commit b58107e

Please sign in to comment.