-
Notifications
You must be signed in to change notification settings - Fork 39
Enrich workflow activity context #85
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
Open
javier-aliaga
wants to merge
4
commits into
dapr:main
Choose a base branch
from
javier-aliaga:tasks-proposal
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # Enrich workflow activity context | ||
|
|
||
| * Author(s): Javier Aliaga (@javier-aliaga) | ||
| * State: Draft | ||
| * Updated: 2025-05-26 | ||
|
|
||
| ## Overview | ||
|
|
||
| This is a proposal to enrich workflow activity context by introducing new fields. This will make it easier for users to control the retries within activities. They are particularly useful for: | ||
|
|
||
| 1. **Idempotency**: Ensuring activities are not executed multiple times for the same task | ||
|
|
||
| ## Background | ||
|
|
||
| Workflow users have raised concerns about controlling and preventing an activity from being invoked more than once. | ||
| Input parameters can be used to control the workflow's state, but certain scenarios do not have enough data to do it. | ||
| Some examples are: | ||
|
|
||
| - A notification activity where the message content alone isn't enough to determine uniqueness | ||
| - An external service call where idempotency can't be guaranteed by the input parameters | ||
|
|
||
| The current implementations of the activity context do not expose any valuable field for this purpose. | ||
| - [GO-SDK](https://github.com/dapr/go-sdk/blob/main/workflow/activity_context.go) | ||
| - [JAVA-SDK](https://github.com/dapr/java-sdk/blob/master/sdk-workflows/src/main/java/io/dapr/workflows/WorkflowActivityContext.java) | ||
| - etc... | ||
|
|
||
| This limitation creates the need to extend the activity context with additional fields that can track execution uniqueness and state. By introducing these new fields to the activity context, users will have a better mechanism to ensure activities are not invoked multiple times, even in cases where input parameters are not enough for this purpose. | ||
|
|
||
|
|
||
| ## Related Items | ||
|
|
||
| ### Related proposals | ||
|
|
||
| N/A | ||
|
|
||
| ### Related issues | ||
|
|
||
| An attempt to solve this problem has been tried in the JAVA-SDK. However, the solution is not consistent with scenarios where the same task is executed multiple times as the task execution key is built using the workflow instance id and the task name. | ||
|
|
||
| - https://github.com/dapr/durabletask-java/pull/18 | ||
| - https://github.com/dapr/java-sdk/pull/1352 | ||
|
|
||
| ## Expectations and alternatives | ||
|
|
||
| * What is in scope for this proposal? | ||
| * Workflow runtime | ||
| * SDKs | ||
| * What advantages / disadvantages does this proposal have? | ||
| * Uniform across all SDKs | ||
|
|
||
| ## Implementation Details | ||
|
|
||
| ### Design | ||
|
|
||
| The proposed fields introduced in this document are: | ||
|
|
||
| - TaskExecutionId: This field will provide a unique identifier for the same activity among retries. This new field will be part of the [Activity Request](https://github.com/dapr/durabletask-protobuf/blob/main/protos/orchestrator_service.proto) and needs to be populated in the runtime. | ||
| The new field will be present in the following entities: | ||
| ``` | ||
| ActivityRequest | ||
| TaskScheduledEvent | ||
| TaskCompletedEvent | ||
| TaskFailedEvent | ||
| ScheduleTaskAction | ||
| ``` | ||
|
|
||
| ### Feature lifecycle outline | ||
|
|
||
| * Expectations | ||
| * Compatability guarantees | ||
| * Deprecation / co-existence with existing functionality | ||
| * Feature flags | ||
|
|
||
| ### Acceptance Criteria | ||
|
|
||
| How will success be measured? | ||
|
|
||
| * Integration and unit tests will be added to verify the new functionality. | ||
|
|
||
|
|
||
| ## Completion Checklist | ||
|
|
||
| What changes or actions are required to make this proposal complete? Some examples: | ||
|
|
||
| * Code changes | ||
| * Tests added (e2e, unit) | ||
| * SDK changes (if needed) | ||
| * Documentation | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't there some overlap between this proposal and Workflow: Rerun from Activity #80?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think so, as a rerun is a completely new run of the activity