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
pass
steps. - Call functions of the Function Compute service with
task
steps. - Suspend the flow for a period of time with
wait
steps. - Define different execution paths with
choice
steps. - Terminate a flow in advance with
succeed
orfail
steps. - Execute multiple branches in parallel with
parallel
steps. - Process array data in parallel with
foreach
steps.
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
end
attribute or execute a succeed or fail step. - inputMappings: Optional. The input mappings. The
$input
referenced in the input mappings is theInput
parameter in aStartExecution
API request. - outputMappings: Optional. The output mappings. The
$local
referenced in the output mappings is a JSON object that records the execution result of each serial step.Note If no output mappings are specified,$local
is 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 (
step1
andstep4
), in whichstep1
contains two child steps (step2
andstep3
).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: