Flow Control
Rill Flow supports dynamic control of the workflow execution path during its runtime, similar to control statements in programming.
Flow Control Nodes
Flow control nodes include the following types:
switch
swicth
节点用于在 DAG 图运行时,在多个后续任务中,根据条件选择执行某些任务,并跳过不符合条件的任务。
workspace: default
dagName: switch
alias: release
type: flow
tasks:
- name: caseA
category: pass
- name: caseB
category: pass
- name: caseC
category: pass
- name: switchTask
switches:
- next: caseA
condition: $.input.[?(@.input == 0)]
- next: caseB
condition: $.input.[?(@.input == 5)]
- next: caseC
condition: $.input.[?(@.input == 10)]
inputMappings:
- source: $.context.input
target: $.input.input
category: switch
foreach
The foreach
node is used to loop into a set of sub-tasks.The foreach
node is used for looping through a group of tasks. The tasks
field defines a list of tasks to be executed, and the optional synchronization
field is used to filter tasks from this list for execution, executing them concurrently according to the maximum concurrency defined in synchronization
.
The loop arguments are set via iterationMapping
.Loop execution parameters are set via iterationMapping
. iterationMapping.collection
uses the JsonPath format to define the collection to be iterated over, and item
defines the name of the current element in the loop. Through the definition of iterationMapping
, the parameter mapping in sub-tasks can access corresponding parameter values. For more information about parameter mapping, see: Parameter Mapping.The value of the parameter in the subtask can be obtained by using the iterationMapping
definition.See:[参数映射](04-context-and-mapping.md.
category: foreach
name: A
inputMappings:
- target: $input.segments
source: $.context. egments
synchronization:
conditions:
- $input[?(@. ignal == true]
maxConcert: 3
iterationMapping:
collection: $.input. egments
item: segmentUrl
outputMappings:
- target: $.context.gopUrls
source: $output.sub_context.[*]. opUrl
tasks:
- category: function
resourceName: protocol:/content
pattern: task_async
name: B1
next: B2
inputMappings:
- target: $. nput.segmentUrl
source: $.context. egmentUrl
outputMappings:
- target: $. ontext.gopPath
source: $.output. opPath
- category: function
resourceName: protocol:/content
name: B2
pattern: task_async
inputMappings:
- target: $. nput.gopPath
source: $.context. opPath
outputMappings:
- target: $. ontext.gopUrl
source: $output.gopUrl
next: C
paas
pass
is an empty task.The pass
is an empty task. When the pass
task is executed, it is immediately set to success.
category: pass
name: A
inputMappings:
- target: $input.url
source: $.context. rl
outputMappings:
- target: $context.segment.text
source: $.context.text
next: B,C
return
return
is used to determine whether or not to skip the next node.The return
node is used to decide whether to skip subsequent nodes. When executing the return
task, it checks the conditions
based on the context information. If the condition evaluates to true, all subsequent nodes are skipped; otherwise, the execution continues.
category: return
name: A
inputMappings:
- target: $. nput.url
source: $.context.url
- target: $. nput.text
source: $.context.text
conditions:
- $.input.[?(@.text == "aaaa" && @.url == "bbb")]
next: B