Add mermaid diagrams

Signed-off-by: Marc Duiker <marcduiker@users.noreply.github.com>
This commit is contained in:
Marc Duiker 2025-03-24 18:11:49 +01:00
parent 790c73e4a2
commit 551f81e39c
No known key found for this signature in database
GPG Key ID: 6A36EA7754473DD7
8 changed files with 151 additions and 2 deletions

View File

@ -1,5 +1,46 @@
# Child Workflows
This tutorial demonstrates how a workflow can call child workflows that are part of the same application. Child workflow can be used to break up large workflows into smaller, re-usable parts. For more information about child workflows see the [Dapr docs](https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-patterns/#external-system-interaction).
## Inspect the code
Open the `ParentWorkflow.cs` file in the `tutorials/workflow/csharp/child-workflows/ChildWorkflows` folder. This file contains the definition for the workflow.
The workflow iterates over the input array and schedules the `ChildWorkflow` for each of the input elements. The `ChildWorkflow` contains a sequence of two activities.
### Parent workflow
```mermaid
graph LR
SW((Start
Workflow))
subgraph for each word in the input
GWL[Call child workflow]
end
ALL[Wait until all tasks
are completed]
EW((End
Workflow))
SW --> GWL
GWL --> ALL
ALL --> EW
```
### Child workflow
```mermaid
graph LR
SW((Start
Workflow))
A1[Activity1]
A2[Activity2]
EW((End
Workflow))
SW --> A1
A1 --> A2
A2 --> EW
```
## Run the tutorial
1. Use a terminal to navigate to the `tutorials/workflow/csharp/child-workflows` folder.

View File

@ -17,8 +17,6 @@ public class ExternalEventsWorkflow : Workflow<Order, string>
approvalStatus = await context.WaitForExternalEventAsync<ApprovalStatus>(
eventName: "approval-event",
timeout: TimeSpan.FromSeconds(120));
var logger = context.CreateReplaySafeLogger<ExternalEventsWorkflow>();
logger.LogWarning("Approval Status: {ApprovalStatus}", approvalStatus);
}
catch (TaskCanceledException)
{

View File

@ -2,6 +2,38 @@
This tutorial demonstrates how to author a workflow where the workflow will wait until it receives an external event. This pattern is often applied in workflows that require an approval step. For more information about the external system interaction pattern see the [Dapr docs](https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-patterns/#external-system-interaction).
## Inspect the code
Open the `ExternalEventsWorkflow.cs` file in the `tutorials/workflow/csharp/external-system-interaction/ExternalEvents` folder. This file contains the definition for the workflow.
```mermaid
graph LR
SW((Start
Workflow))
IF1{Is TotalPrice
> 250?}
IF2{Is Order Approved
or TotalPrice < 250?}
WAIT[Wait for
approval event]
EX{Event
received?}
PO[Process Order]
SN[Send Notification]
EW((End
Workflow))
SW --> IF1
IF1 -->|Yes| WAIT
IF1 -->|No| IF2
EX -->|Yes| IF2
EX -->|No| SN
WAIT --> EX
IF2 -->|Yes| PO
PO --> SN
IF2 -->|No| SN
SN --> EW
```
## Run the tutorial
1. Use a terminal to navigate to the `tutorials/workflow/csharp/external-system-interaction` folder.

View File

@ -2,6 +2,29 @@
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](https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-patterns/#fan-outfan-in).
## 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.
```mermaid
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
1. Use a terminal to navigate to the `tutorials/workflow/csharp/fan-out-fan-in` folder.

View File

@ -8,6 +8,19 @@ Open the `BasicWorkflow.cs` file in the `tutorials/workflow/csharp/fundamentals/
The workflow consists of two activities: `Activity1` and `Activity2`, which are called in sequence. You can find the Activity definitions in the `Activities` folder.
```mermaid
graph LR
SW((Start
Workflow))
A1[Activity1]
A2[Activity2]
EW((End
Workflow))
SW --> A1
A1 --> A2
A2 --> EW
```
## Run the tutorial
1. Use a terminal to navigate to the `tutorials/workflow/csharp/fundamentals` folder.

View File

@ -2,6 +2,28 @@
This tutorial demonstrates how to run a workflow in a loop. This can be used for recurring tasks that need to be executed on a certain frequency (e.g. a clean-up job that runs every hour). For more information on the monitor pattern see the [Dapr docs](https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-patterns/#monitor).
## Inspect the code
Open the `MonitorWorkflow.cs` file in the `tutorials/workflow/csharp/monitor-pattern/Monitor` folder. This file contains the definition for the workflow.
```mermaid
graph LR
SW((Start
Workflow))
CHECK[CheckStatus]
IF{Is Ready}
TIMER[Wait for a period of time]
NEW[Continue as a new instance]
EW((End
Workflow))
SW --> CHECK
CHECK --> IF
IF -->|Yes| EW
IF -->|No| TIMER
TIMER --> NEW
NEW --> SW
```
## Run the tutorial
1. Use a terminal to navigate to the `tutorials/workflow/csharp/monitor-pattern` folder.

View File

@ -2,6 +2,26 @@
This tutorial demonstrates how to chain multiple tasks together as a sequence in a workflow. For more information about the task chaining pattern see the [Dapr docs](https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-patterns/#task-chaining).
## Inspect the code
Open the `ChainingWorkflow.cs` file in the `tutorials/workflow/csharp/task-chaining/TaskChaining` folder. This file contains the definition for the workflow.
```mermaid
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
1. Use a terminal to navigate to the `tutorials/workflow/csharp/task-chaining` folder.