Repository navigation
Add compensation workflow pattern example - #952
Conversation
Signed-off-by: Babyy-dev <rishabh1raj567@gmail.com>
WhitWaldo
left a comment
There was a problem hiding this comment.
Looks good to me - thank you for your contribution!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #952 +/- ##
=======================================
Coverage 85.48% 85.48%
=======================================
Files 160 160
Lines 5884 5884
Branches 1222 1222
=======================================
Hits 5030 5030
Misses 664 664
Partials 190 190
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@holopin-bot @Babyy-dev sdk-badge Thank you! Here's a digital badge as a small token of appreciation. |
|
Congratulations @Babyy-dev, the maintainer of this repository has issued you a badge! Here it is: https://holopin.io/claim/cmwt2xx9l0003l308ukv55kvd This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account. |
Description
Adds a JS example of the workflow compensation (saga) pattern, matching the Java SDK compensation example.
examples/workflow/authoring/src/compensation.tsbooks a flight, a hotel and a car. After each booking succeeds, its cancellation activity is added to a list.bookCarfails on purpose. Its failure surfaces as an error at theyield, so the workflow catches it and runs the registered cancellations in reverse order (hotel, then flight). Each cancellation gets aRetryPolicy, and a failed cancellation is logged without stopping the remaining ones. The workflow then completes with"Trip booking failed, compensation applied".The example uses the same client and runtime setup as
activity-sequence.ts, and logs from the workflow through the replay-safectx.logger.Also:
start:compensation/start:dapr:compensationscripts inexamples/workflow/authoring/package.jsonIssue reference
Please reference the issue this PR will close: #702
Checklist
tscon the authoring examples reports no errors incompensation.ts, and eslint and prettier pass.OrchestrationExecutorwith a history of flight ✓, hotel ✓, car ✗. It scheduledcancelHotel, thencancelFlight, then completed with the compensation result. Happy to add that as a unit test if useful.