Skip to content

Commit

Permalink
feat: add failure node support (#878)
Browse files Browse the repository at this point in the history
add failure node support

Signed-off-by: xwk1246 <wenkai@union.ai>
Co-authored-by: Jason Porter <84735036+jsonporter@users.noreply.github.com>
  • Loading branch information
xwk1246 and jsonporter authored May 31, 2024
1 parent c74e22e commit b001019
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ const parseWorkflow = ({
}

const templateNodeList = context.template.nodes;

/* Build Nodes from template */
for (let i = 0; i < templateNodeList.length; i++) {
const compiledNode: CompiledNode = templateNodeList[i];
Expand All @@ -475,6 +474,28 @@ const parseWorkflow = ({
};
}

/* Build failure node and add downstream connection for edges building */
const failureNode = { ...context.template.failureNode, failureNode: true };
if (failureNode && failureNode.id) {
parseNode({
node: failureNode as CompiledNode,
root,
nodeMetadataMap,
staticExecutionIdsMap,
compiledWorkflowClosure,
});
nodeMap[failureNode.id] = {
dNode: root.nodes[root.nodes.length - 1],
compiledNode: failureNode as CompiledNode,
};
if (!context.connections.downstream[startNodeId].ids.includes(failureNode.id)) {
context.connections.downstream[startNodeId].ids.push(failureNode.id);
context.connections.downstream[failureNode.id] = {
ids: [endNodeId],
};
}
}

/* Build Edges */
buildWorkflowEdges({
root,
Expand Down

0 comments on commit b001019

Please sign in to comment.