Do
The Do task is specified in every single workflow as it represents the basic definition of the workflow. In Temporal, a workflow is a sequence of steps that must follow deterministic constraints:
The same steps are executed, in the same order, with the same input and output data
The Do task is used by many other tasks, such as in a child workflow. These will be discussed in detail in those tasks.
Properties
| Name | Type | Required | Description |
|---|---|---|---|
| do | map[string, task] | no | The tasks to perform sequentially. |
Examples
Single Workflow
If you're not sure how to start building your workflow, start with a single workflow definition.
When defined at the root level, if a single is specified then a single Temporal
workflow is registered, with the workflow name set by the document.name property.
In this example, the workflow name is single-workflow:
document:
dsl: 1.0.0
namespace: zigflow
name: single-workflow
version: 0.0.1
do:
- setData:
set:
key: ${ uuid }
- wait:
wait:
seconds: 5
- getUser:
call: http
export:
as: user
with:
method: get
headers:
uuid: ${ .data.key }
endpoint: https://jsonplaceholder.typicode.com/users/2
This workflow is very basic, but explain the steps in details:
- setData: this sets some data, which is randomly generated UUID key. This
is available on
${ .data.key }. See Set for a detailed explanation of why generated data should be used sparingly. - wait: pause the workflow, using a Durable Timer
- getUser: call an HTTP endpoint, using the previously generated UUID as a header.
Multiple Workflows
Workflow names must be unique.
When defined at the root level, you can use the Do task to create multiple
workflows by specifying multiple Do tasks at the top level. If you do this, the
workflow names will be set by the task name and the document.name property
will be ignored.
document:
dsl: 1.0.0
namespace: zigflow
name: multiple-workflows # This property is ignored
version: 0.0.1
do:
- workflow1:
do:
- wait:
wait:
seconds: 5
- getUser:
call: http
with:
method: get
endpoint: https://jsonplaceholder.typicode.com/users/1
- workflow2:
do:
- wait:
wait:
seconds: 10
- getUser:
call: http
with:
method: get
endpoint: https://jsonplaceholder.typicode.com/users/2
These workflow are basic, with a sleep and an HTTP call. These two workflows are
independent and are named workflow1 and workflow2.