Skip to content

Compensation example for Workflows #1333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
May 29, 2025

Conversation

cicoyle
Copy link
Contributor

@cicoyle cicoyle commented May 5, 2025

Add a compensation workflow example

@salaboy
Copy link
Collaborator

salaboy commented May 7, 2025

@cicoyle I was looking at this PR. The example doesn't seem to show that compensations are executed, right? Was this already implemented in dotnet? Do we have any reference of how it was implemented in dotnet? Did you used that implementation as inspiration for this PR?

Signed-off-by: Cassandra Coyle <[email protected]>
@cicoyle
Copy link
Contributor Author

cicoyle commented May 19, 2025

@cicoyle I was looking at this PR. The example doesn't seem to show that compensations are executed, right? Was this already implemented in dotnet? Do we have any reference of how it was implemented in dotnet? Did you used that implementation as inspiration for this PR?

This is a new pattern entirely. There are no examples in any other sdk or in the dapr docs. Its a simple example to illustrate how users can use the compensation workflow pattern.

@cicoyle cicoyle marked this pull request as ready for review May 21, 2025 14:48
@cicoyle cicoyle requested review from a team as code owners May 21, 2025 14:48
Copy link
Contributor

@siri-varma siri-varma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM.

I think most of the files are missing a new line. If we could add that, the PR is good to go.

Signed-off-by: artur-ciocanu <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
artur-ciocanu
artur-ciocanu previously approved these changes May 22, 2025
Copy link
Contributor

@artur-ciocanu artur-ciocanu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cicoyle awesome job! I love the docs related to Mechanical Markdown.

My only concern is the comment from @javier-aliaga regarding retries. Either we mention this is the code comment or add some note, so developers are aware how handling the exception might affect the retry behavior.

@cicoyle
Copy link
Contributor Author

cicoyle commented May 29, 2025

Will circle back to the build failures

@salaboy salaboy requested review from salaboy and removed request for javier-aliaga May 29, 2025 16:57
salaboy
salaboy previously approved these changes May 29, 2025
Copy link
Collaborator

@salaboy salaboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not 100% sure about this but here is the label

Signed-off-by: Cassandra Coyle <[email protected]>
cicoyle added 2 commits May 29, 2025 13:35
Signed-off-by: Cassandra Coyle <[email protected]>
Signed-off-by: Cassandra Coyle <[email protected]>
Copy link
Contributor

@artur-ciocanu artur-ciocanu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cicoyle cicoyle merged commit 114e354 into dapr:master May 29, 2025
9 of 10 checks passed
Copy link

codecov bot commented May 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.13%. Comparing base (d759c53) to head (13a0891).
Report is 161 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1333      +/-   ##
============================================
+ Coverage     76.91%   78.13%   +1.22%     
- Complexity     1592     1830     +238     
============================================
  Files           145      223      +78     
  Lines          4843     5663     +820     
  Branches        562      601      +39     
============================================
+ Hits           3725     4425     +700     
- Misses          821      917      +96     
- Partials        297      321      +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

cicoyle added a commit to cicoyle/java-sdk that referenced this pull request Jun 11, 2025
* add basic compensation example for wf

Signed-off-by: Cassandra Coyle <[email protected]>

* update commands to run + wf id

Signed-off-by: Cassandra Coyle <[email protected]>

* update readme + add mechanical markdown

Signed-off-by: Cassandra Coyle <[email protected]>

* fix import

Signed-off-by: Cassandra Coyle <[email protected]>

* fix mechanical markdown + add how to test it locally

Signed-off-by: Cassandra Coyle <[email protected]>

* move compensation example readme to workflows readme

Signed-off-by: Cassandra Coyle <[email protected]>

* Update BookCarActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookFlightActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookHotelActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripClient.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripWorker.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripWorkflow.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelCarActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelFlightActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelHotelActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* add retry IT tests and catch TaskFailedException

Signed-off-by: Cassandra Coyle <[email protected]>

* add test for no compensation if successful and assert attempts

Signed-off-by: Cassandra Coyle <[email protected]>

* update mechanical markdown

Signed-off-by: Cassandra Coyle <[email protected]>

* add back pubsub... but this should be removed long term

Signed-off-by: Cassandra Coyle <[email protected]>

* try adding waitforsidecar

Signed-off-by: Cassandra Coyle <[email protected]>

* rm tests from examples pr

Signed-off-by: Cassandra Coyle <[email protected]>

* reset unintended changes

Signed-off-by: Cassandra Coyle <[email protected]>

---------

Signed-off-by: Cassandra Coyle <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
Co-authored-by: artur-ciocanu <[email protected]>
cicoyle added a commit that referenced this pull request Jun 11, 2025
* Compensation example for Workflows (#1333)

* add basic compensation example for wf

Signed-off-by: Cassandra Coyle <[email protected]>

* update commands to run + wf id

Signed-off-by: Cassandra Coyle <[email protected]>

* update readme + add mechanical markdown

Signed-off-by: Cassandra Coyle <[email protected]>

* fix import

Signed-off-by: Cassandra Coyle <[email protected]>

* fix mechanical markdown + add how to test it locally

Signed-off-by: Cassandra Coyle <[email protected]>

* move compensation example readme to workflows readme

Signed-off-by: Cassandra Coyle <[email protected]>

* Update BookCarActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookFlightActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookHotelActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripClient.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripWorker.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripWorkflow.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelCarActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelFlightActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelHotelActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* add retry IT tests and catch TaskFailedException

Signed-off-by: Cassandra Coyle <[email protected]>

* add test for no compensation if successful and assert attempts

Signed-off-by: Cassandra Coyle <[email protected]>

* update mechanical markdown

Signed-off-by: Cassandra Coyle <[email protected]>

* add back pubsub... but this should be removed long term

Signed-off-by: Cassandra Coyle <[email protected]>

* try adding waitforsidecar

Signed-off-by: Cassandra Coyle <[email protected]>

* rm tests from examples pr

Signed-off-by: Cassandra Coyle <[email protected]>

* reset unintended changes

Signed-off-by: Cassandra Coyle <[email protected]>

---------

Signed-off-by: Cassandra Coyle <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
Co-authored-by: artur-ciocanu <[email protected]>

* Adding Support for Suspend / Resume Workflows (#1405)

* adding IT test

Signed-off-by: salaboy <[email protected]>

* adding initial version of suspend/resume example

Signed-off-by: salaboy <[email protected]>

* updating README

Signed-off-by: salaboy <[email protected]>

* Update README.md

Signed-off-by: salaboy <[email protected]>

* following Javi's suggestion

Signed-off-by: salaboy <[email protected]>

* fixing wrong year in headers

Signed-off-by: salaboy <[email protected]>

* fixing paths in one more README.md file

Signed-off-by: salaboy <[email protected]>

* adding output validation

Signed-off-by: salaboy <[email protected]>

* adding missing port

Signed-off-by: salaboy <[email protected]>

* fixing check conditions

Signed-off-by: salaboy <[email protected]>

---------

Signed-off-by: salaboy <[email protected]>
Co-authored-by: Cassie Coyle <[email protected]>

---------

Signed-off-by: Cassandra Coyle <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
Signed-off-by: salaboy <[email protected]>
Co-authored-by: artur-ciocanu <[email protected]>
Co-authored-by: salaboy <[email protected]>
siri-varma pushed a commit to siri-varma/java-sdk that referenced this pull request Aug 6, 2025
* add basic compensation example for wf

Signed-off-by: Cassandra Coyle <[email protected]>

* update commands to run + wf id

Signed-off-by: Cassandra Coyle <[email protected]>

* update readme + add mechanical markdown

Signed-off-by: Cassandra Coyle <[email protected]>

* fix import

Signed-off-by: Cassandra Coyle <[email protected]>

* fix mechanical markdown + add how to test it locally

Signed-off-by: Cassandra Coyle <[email protected]>

* move compensation example readme to workflows readme

Signed-off-by: Cassandra Coyle <[email protected]>

* Update BookCarActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookFlightActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookHotelActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripClient.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripWorker.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripWorkflow.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelCarActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelFlightActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelHotelActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* add retry IT tests and catch TaskFailedException

Signed-off-by: Cassandra Coyle <[email protected]>

* add test for no compensation if successful and assert attempts

Signed-off-by: Cassandra Coyle <[email protected]>

* update mechanical markdown

Signed-off-by: Cassandra Coyle <[email protected]>

* add back pubsub... but this should be removed long term

Signed-off-by: Cassandra Coyle <[email protected]>

* try adding waitforsidecar

Signed-off-by: Cassandra Coyle <[email protected]>

* rm tests from examples pr

Signed-off-by: Cassandra Coyle <[email protected]>

* reset unintended changes

Signed-off-by: Cassandra Coyle <[email protected]>

---------

Signed-off-by: Cassandra Coyle <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
Co-authored-by: artur-ciocanu <[email protected]>
Signed-off-by: sirivarma <[email protected]>
siri-varma pushed a commit to siri-varma/java-sdk that referenced this pull request Aug 12, 2025
* Compensation example for Workflows (dapr#1333)

* add basic compensation example for wf

Signed-off-by: Cassandra Coyle <[email protected]>

* update commands to run + wf id

Signed-off-by: Cassandra Coyle <[email protected]>

* update readme + add mechanical markdown

Signed-off-by: Cassandra Coyle <[email protected]>

* fix import

Signed-off-by: Cassandra Coyle <[email protected]>

* fix mechanical markdown + add how to test it locally

Signed-off-by: Cassandra Coyle <[email protected]>

* move compensation example readme to workflows readme

Signed-off-by: Cassandra Coyle <[email protected]>

* Update BookCarActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookFlightActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookHotelActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripClient.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripWorker.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripWorkflow.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelCarActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelFlightActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelHotelActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* add retry IT tests and catch TaskFailedException

Signed-off-by: Cassandra Coyle <[email protected]>

* add test for no compensation if successful and assert attempts

Signed-off-by: Cassandra Coyle <[email protected]>

* update mechanical markdown

Signed-off-by: Cassandra Coyle <[email protected]>

* add back pubsub... but this should be removed long term

Signed-off-by: Cassandra Coyle <[email protected]>

* try adding waitforsidecar

Signed-off-by: Cassandra Coyle <[email protected]>

* rm tests from examples pr

Signed-off-by: Cassandra Coyle <[email protected]>

* reset unintended changes

Signed-off-by: Cassandra Coyle <[email protected]>

---------

Signed-off-by: Cassandra Coyle <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
Co-authored-by: artur-ciocanu <[email protected]>

* Adding Support for Suspend / Resume Workflows (dapr#1405)

* adding IT test

Signed-off-by: salaboy <[email protected]>

* adding initial version of suspend/resume example

Signed-off-by: salaboy <[email protected]>

* updating README

Signed-off-by: salaboy <[email protected]>

* Update README.md

Signed-off-by: salaboy <[email protected]>

* following Javi's suggestion

Signed-off-by: salaboy <[email protected]>

* fixing wrong year in headers

Signed-off-by: salaboy <[email protected]>

* fixing paths in one more README.md file

Signed-off-by: salaboy <[email protected]>

* adding output validation

Signed-off-by: salaboy <[email protected]>

* adding missing port

Signed-off-by: salaboy <[email protected]>

* fixing check conditions

Signed-off-by: salaboy <[email protected]>

---------

Signed-off-by: salaboy <[email protected]>
Co-authored-by: Cassie Coyle <[email protected]>

---------

Signed-off-by: Cassandra Coyle <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
Signed-off-by: salaboy <[email protected]>
Co-authored-by: artur-ciocanu <[email protected]>
Co-authored-by: salaboy <[email protected]>
Signed-off-by: siri-varma <[email protected]>
siri-varma pushed a commit to siri-varma/java-sdk that referenced this pull request Aug 12, 2025
* Compensation example for Workflows (dapr#1333)

* add basic compensation example for wf

Signed-off-by: Cassandra Coyle <[email protected]>

* update commands to run + wf id

Signed-off-by: Cassandra Coyle <[email protected]>

* update readme + add mechanical markdown

Signed-off-by: Cassandra Coyle <[email protected]>

* fix import

Signed-off-by: Cassandra Coyle <[email protected]>

* fix mechanical markdown + add how to test it locally

Signed-off-by: Cassandra Coyle <[email protected]>

* move compensation example readme to workflows readme

Signed-off-by: Cassandra Coyle <[email protected]>

* Update BookCarActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookFlightActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookHotelActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripClient.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripWorker.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update BookTripWorkflow.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelCarActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelFlightActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* Update CancelHotelActivity.java

Signed-off-by: artur-ciocanu <[email protected]>

* add retry IT tests and catch TaskFailedException

Signed-off-by: Cassandra Coyle <[email protected]>

* add test for no compensation if successful and assert attempts

Signed-off-by: Cassandra Coyle <[email protected]>

* update mechanical markdown

Signed-off-by: Cassandra Coyle <[email protected]>

* add back pubsub... but this should be removed long term

Signed-off-by: Cassandra Coyle <[email protected]>

* try adding waitforsidecar

Signed-off-by: Cassandra Coyle <[email protected]>

* rm tests from examples pr

Signed-off-by: Cassandra Coyle <[email protected]>

* reset unintended changes

Signed-off-by: Cassandra Coyle <[email protected]>

---------

Signed-off-by: Cassandra Coyle <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
Co-authored-by: artur-ciocanu <[email protected]>

* Adding Support for Suspend / Resume Workflows (dapr#1405)

* adding IT test

Signed-off-by: salaboy <[email protected]>

* adding initial version of suspend/resume example

Signed-off-by: salaboy <[email protected]>

* updating README

Signed-off-by: salaboy <[email protected]>

* Update README.md

Signed-off-by: salaboy <[email protected]>

* following Javi's suggestion

Signed-off-by: salaboy <[email protected]>

* fixing wrong year in headers

Signed-off-by: salaboy <[email protected]>

* fixing paths in one more README.md file

Signed-off-by: salaboy <[email protected]>

* adding output validation

Signed-off-by: salaboy <[email protected]>

* adding missing port

Signed-off-by: salaboy <[email protected]>

* fixing check conditions

Signed-off-by: salaboy <[email protected]>

---------

Signed-off-by: salaboy <[email protected]>
Co-authored-by: Cassie Coyle <[email protected]>

---------

Signed-off-by: Cassandra Coyle <[email protected]>
Signed-off-by: artur-ciocanu <[email protected]>
Signed-off-by: salaboy <[email protected]>
Co-authored-by: artur-ciocanu <[email protected]>
Co-authored-by: salaboy <[email protected]>
Signed-off-by: siri-varma <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants