You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+42-1Lines changed: 42 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,48 @@ This section describes the guidelines for contributing code / docs to Dapr.
54
54
### Things to consider when adding new API to SDK
55
55
56
56
1. All the new API's go under [dapr-sdk maven package](https://github.com/dapr/java-sdk/tree/master/sdk)
57
-
2. Make sure there is an example talking about how to use the API along with a README. [Example](https://github.com/dapr/java-sdk/pull/1235/files#diff-69ed756c4c01fd5fa884aac030dccb8f3f4d4fefa0dc330862d55a6f87b34a14)
57
+
2. Make sure there is an example talking about how to use the API along with a README with mechanical markdown. [Example](https://github.com/dapr/java-sdk/pull/1235/files#diff-69ed756c4c01fd5fa884aac030dccb8f3f4d4fefa0dc330862d55a6f87b34a14)
58
+
59
+
#### Mechanical Markdown
60
+
61
+
Mechanical markdown is used to validate example outputs in our CI pipeline. It ensures that the expected output in README files matches the actual output when running the examples. This helps maintain example output, catches any unintended changes in example behavior, and regressions.
62
+
63
+
To test mechanical markdown locally:
64
+
65
+
1. Install the package:
66
+
```bash
67
+
pip3 install mechanical-markdown
68
+
```
69
+
70
+
2. Run the test from the respective examples README directory, for example:
@@ -444,7 +444,7 @@ Started a new external-event model workflow with instance ID: 23410d96-1afe-4698
444
444
workflow instance with ID: 23410d96-1afe-4698-9fcd-c01c1e0db255 completed.
445
445
```
446
446
447
-
### child-workflow Pattern
447
+
### Child-workflow Pattern
448
448
The child-workflow pattern allows you to call a workflow from another workflow.
449
449
450
450
The `DemoWorkflow` class defines the workflow. It calls a child-workflow `DemoChildWorkflow` to do the work. See the code snippet below:
@@ -540,3 +540,171 @@ The log from client:
540
540
Started a new child-workflow model workflow with instance ID: c2fb9c83-435b-4b55-bdf1-833b39366cfb
541
541
workflow instance with ID: c2fb9c83-435b-4b55-bdf1-833b39366cfb completed with result: !wolfkroW rpaD olleH
542
542
```
543
+
544
+
### Compensation Pattern
545
+
The compensation pattern is used to "undo" or "roll back" previously completed steps if a later step fails. This pattern is particularly useful in scenarios where you need to ensure that all resources are properly cleaned up even if the process fails.
546
+
547
+
The example simulates a trip booking workflow that books a flight, hotel, and car. If any step fails, the workflow will automatically compensate (cancel) the previously completed bookings in reverse order.
548
+
549
+
The `BookTripWorkflow` class defines the workflow. It orchestrates the booking process and handles compensation if any step fails. See the code snippet below:
Each activity class (`BookFlightActivity`, `BookHotelActivity`, `BookCarActivity`) implements the booking logic, while their corresponding compensation activities (`CancelFlightActivity`, `CancelHotelActivity`, `CancelCarActivity`) implement the cancellation logic.
594
+
595
+
<!-- STEP
596
+
name: Run Compensation Pattern workflow worker
597
+
match_order: none
598
+
output_match_mode: substring
599
+
expected_stdout_lines:
600
+
- "Registered Workflow: BookTripWorkflow"
601
+
- "Registered Activity: BookFlightActivity"
602
+
- "Registered Activity: CancelFlightActivity"
603
+
- "Registered Activity: BookHotelActivity"
604
+
- "Registered Activity: CancelHotelActivity"
605
+
- "Registered Activity: BookCarActivity"
606
+
- "Registered Activity: CancelCarActivity"
607
+
- "Successfully built dapr workflow runtime"
608
+
- "Start workflow runtime"
609
+
- "Durable Task worker is connecting to sidecar at 127.0.0.1:50001."
0 commit comments