1.7 KiB
Fan-out/Fan-in
This tutorial demonstrates how to author a workflow where multiple independent tasks can be scheduled and executed simultaneously. The workflow can either wait until all tasks are completed, or when the fastest task is completed. For more information about the fan-out/fan-in pattern see the Dapr docs.
Inspect the code
Open the FanOutFanInWorkflow.cs
file in the tutorials/workflow/csharp/fan-out-fan-in/FanOutFanIn
folder. This file contains the definition for the workflow.
graph LR
SW((Start
Workflow))
subgraph for each word in the input
GWL[GetWordLength]
end
SHORT[Select the
shortest word]
ALL[Wait until all tasks
are completed]
EW((End
Workflow))
SW --> GWL
GWL --> ALL
ALL --> SHORT
SHORT --> EW
Run the tutorial
-
Use a terminal to navigate to the
tutorials/workflow/csharp/fan-out-fan-in
folder. -
Build the project using the .NET CLI.
dotnet build ./FanOutFanIn/
-
Use the Dapr CLI to run the Dapr Multi-App run file
dapr run -f .
-
Use the POST request in the
fanoutfanin.http
file to start the workflow.The input for the workflow is an array of strings:
[ "which", "word", "is", "the", "shortest" ]
-
Use the GET request in the
fanoutfanin.http
file to get the status of the workflow.The expected serialized output of the workflow is:
"\"is\""
-
Stop the Dapr Multi-App run process by pressing
Ctrl+C
.