This topic describes the basics of Flow Definition Language and provides usage examples.
Basics
Flow Definition Language (FDL) defines business logic. When a flow is executed, the Serverless Workflow service executes the steps in sequence based on the flow definition. In FDL, a flow contains steps. Steps can be simple atomic steps, such as task, succeed, fail, wait, and pass. Steps can also be complex control steps, such as choice, parallel, and foreach. You can combine these steps to build complex business logic. For example, a branch of a parallel step can be a sequence of steps. If a step encounters an error during execution, FDL provides retry and catch capabilities to handle the error.
FDL steps are similar to functions in a programming language. Combining steps is similar to function invocation. Data is passed between steps using inputs and outputs. Each step uses local variables to store data. If a step contains another step, the outer step is the parent step and the inner step is the child step.
- Use a
passstep as a placeholder to plan the basic structure of the flow. - Use a
taskstep to call a function in Function Compute. - Use a
waitstep to pause the execution of the flow for a specified period. - Use a
choicestep to define different execution paths. - Use a
succeedorfailstep to stop the flow early. - Use a
parallelstep to execute multiple branches in parallel. - Use a
foreachstep to process array data in parallel.
A flow has the following properties:
- version (Required): The version of the flow. Only v1 is supported.
- type (Required): The type of the definition. Set this to flow.
- steps (Required): The sequence of steps in the flow. After a step is successfully executed, the next step in the sequence is executed. To end the flow early, use the
endproperty of a step, or use a succeed or fail step. - inputMappings (Optional): The input mapping. The
$inputvariable referenced in the input mapping is theInputparameter of theStartExecutionAPI request. - outputMappings (Optional): The output mapping. The
$localvariable referenced in the output mapping is a JSON object that stores the execution result of each step in the sequence.Note If you do not specify an output mapping,$localis used as the final output of the flow. - timeoutSeconds (Optional): The timeout period for the flow, in seconds. If the execution duration of the flow exceeds the specified timeout period, the execution times out.
Examples
- The following example flow contains a task step. This step calls a function in Function Compute.
version: v1 type: flow steps: - type: task name: hello resourceArn: acs:fc:{region}:{accountID}:services/fnf_test/functions/hello - The following example flow contains a sequence of two steps,
step1andstep4. The first step,step1, is a parent step that contains two child steps,step2andstep3.version: v1 type: flow steps: - type: parallel name: step1 branches: - steps: - type: pass name: step2 - steps: - type: pass name: step3 - type: pass name: step4
More information
For more information about the features of Flow Definition Language, see the following topics: