Signed-off-by: Alice Gibbons <alice@diagrid.io> |
||
|---|---|---|
| .. | ||
| task_chaining | ||
| README.md | ||
| chaining.http | ||
| dapr.yaml | ||
| makefile | ||
README.md
Task Chaining Pattern
This tutorial demonstrates how to chain multiple tasks together as a sequence in a workflow, where the output of one task is used as the input for the next one. For more information about the task chaining pattern see the Dapr docs.
Inspect the code
Open the chaining_workflow.py file in the tutorials/workflow/python/task-chaining/task_chaining folder. This file contains the definition for the workflow.
graph LR
SW((Start
Workflow))
A1[activity1]
A2[activity2]
A3[activity3]
EW((End
Workflow))
SW --> A1
A1 --> A2
A2 --> A3
A3 --> EW
Run the tutorial
-
Use a terminal to navigate to the
tutorials/workflow/python/task-chaining/task_chainingfolder. -
Install the dependencies using pip:
pip3 install -r requirements.txt -
Navigate back one level to the
task-chainingfolder and use the Dapr CLI to run the Dapr Multi-App run file```bashdapr run -f .
<!-- END_STEP --> -
Use the POST request in the
chaining.httpfile to start the workflow, or use this cURL command:curl -i --request POST http://localhost:5255/startThe input for the workflow is a string with the value
This. The expected app logs are as follows:== APP - chaining == activity1: Received input: This. == APP - chaining == activity2: Received input: This is. == APP - chaining == activity3: Received input: This is task. -
Use the GET request in the
chaining.httpfile to get the status of the workflow, or use this cURL command:curl --request GET --url http://localhost:3555/v1.0/workflows/dapr/<INSTANCEID>Where
<INSTANCEID>is the workflow instance ID you received in theinstance_idproperty in the previous step.The expected serialized output of the workflow is:
"\"This is task chaining\"" -
Stop the Dapr Multi-App run process by pressing
Ctrl+C.