This repository was archived by the owner on Dec 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
This repository was archived by the owner on Dec 13, 2023. It is now read-only.
SWITCH task should COMPLETE after decision cases are done #3271
Copy link
Copy link
Open
Labels
Description
What bothers me
SWITCH task is marked as COMPLETEd immediately after processing expression. With this behaviour it is dangerous to use it in DO_WHILE task, where every iteration is marked as completed (and next one is started) when every task from loopTasks are completed. Similar problem shows for FORK_JOIN where JOIN task has SWITCH in joinOn section but does not wait for it's decision cases.
Example
As an example you may run following workflow
{
"name": "ADHoc-loop-test",
"version": 1,
"input": {
"list": [
{
"number": 1
},
{
"number": 2
},
{
"number": 3
}
]
},
"workflowDef": {
"name": "ADHoc-loop-test",
"description": "Program for testing loop behaviour",
"version": 1,
"schemaVersion": 2,
"ownerEmail": "xyz@company.eu",
"tasks": [
{
"name": "LoopTask",
"taskReferenceName": "LoopTask",
"type": "DO_WHILE",
"inputParameters": {
"list": "${workflow.input.list}"
},
"loopCondition": "$.LoopTask['iteration'] < $.list.length",
"loopOver": [
{
"name": "GetNumberAtIndex",
"taskReferenceName": "GetNumberAtIndex",
"type": "INLINE",
"inputParameters": {
"evaluatorType": "javascript",
"list": "${workflow.input.list}",
"iterator": "${LoopTask.output.iteration}",
"expression": "function getElement() { return $.list.get($.iterator - 1); } getElement();"
}
},
{
"name": "SwitchTask",
"taskReferenceName": "SwitchTask",
"type": "SWITCH",
"evaluatorType": "javascript",
"inputParameters": {
"param": "${GetNumberAtIndex.output.result.number}"
},
"expression": "$.param > 0",
"decisionCases": {
"true": [
{
"name": "WaitTask",
"taskReferenceName": "WaitTask",
"type": "WAIT",
"inputParameters": {
"duration": "10 secs"
}
},
{
"name": "ComputeNumber",
"taskReferenceName": "ComputeNumber",
"type": "INLINE",
"inputParameters": {
"evaluatorType": "javascript",
"number": "${GetNumberAtIndex.output.result.number}",
"expression": "function compute() { return $.number+10; } compute();"
}
}
]
}
}
]
}
]
}
}From above execution I expect to process every number sequentially but the third one is processed three times instead.
Expected behavior
It would be great if SWITCH task completed after all of its decisionCases and defaultCase are finished.
Reactions are currently unavailable