This topic describes the basics of Flow Definition Language (FDL) and related examples.
Basics
FDL is used to describe and define business logic. When a flow is executed, the Serverless workflow service executes steps in sequence based on the flow definition. In FDL, a flow usually contains several steps. These steps can be simple atomic steps, such as task, succeed, fail, wait, and pass steps, or complex control steps, such as choice, parallel, and foreach steps. These steps can be combined to build complex business logic. For example, a branch of a parallel step may be a series of serial steps. Errors may occur in the execution of steps, but FDL provides the retry and catch capabilities.
Steps in FDL are similar to functions in programming languages, and a combination of steps is similar to function calls. Data is passed between steps through input and output. Local variables are used to store data of steps. If a step contains another step, the outer step is called a parent step, and the included step is called a child step.
- Build the basic structure of the placeholder planning flow with
passsteps. - Call functions of the Function Compute service with
tasksteps. - Suspend the flow for a period of time with
waitsteps. - Define different execution paths with
choicesteps. - Terminate a flow in advance with
succeedorfailsteps. - Execute multiple branches in parallel with
parallelsteps. - Process array data in parallel with
foreachsteps.
A flow contains the following attributes:
- version: Required. The flow version. Only v1 is supported.
- type: Required. The flow type.
- steps: Required. Multiple serial steps in a flow. When a step is executed successfully, the next step starts. To stop a flow in advance, you can use the
endattribute or execute a succeed or fail step. - inputMappings: Optional. The input mappings. The
$inputreferenced in the input mappings is theInputparameter in aStartExecutionAPI request. - outputMappings: Optional. The output mappings. The
$localreferenced in the output mappings is a JSON object that records the execution result of each serial step.Note If no output mappings are specified,$localis used as the final flow output. - timeoutSeconds: Optional. The timeout period of a flow. If the flow execution duration exceeds the specified timeout period, the flow times out.
Examples
- The following sample flow consists of a task step that calls a function of Function Compute:
version: v1 type: flow steps: - type: task name: hello resourceArn: acs:fc:{region}:{accountID}:services/fnf_test/functions/hello - The following sample flow consists of two steps (
step1andstep4), in whichstep1contains 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
References
For more information about FDL features, see the following topics: