-
Notifications
You must be signed in to change notification settings - Fork 328
Add poison message handling to the dispatchers #1366
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
sophiatev
wants to merge
24
commits into
main
Choose a base branch
from
stevosyan/add-poison-message-handling
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
24 commits
Select commit
Hold shift + click to select a range
de244ff
initial implementation
8f6bf9d
fixing the compilation errors
ea5a36f
addressing copilot comments
3ab0859
Merge branch 'main' into stevosyan/add-poison-message-handling
sophiatev 4c7665d
fixing the error in the logger where I was incorrectly calling Discar…
3bd1dc9
moved the max dispatch count from IOrchestrationService to dispatch p…
2e3c7c2
updated the implementations to remove all exception-throwing in the c…
eecc077
comment updates
f0fc35d
fixed a typo, added an argument range check for the max dispatch count
ea7a67f
Apply suggestion from @cgillum
sophiatev c976817
Apply suggestions from code review
sophiatev 559bb4d
redid the implementation to follow an interface format
68dbde9
mroe cleanup and PR comments
b9a875d
updated to wait for the async calls
8a77b40
Merge branch 'main' into stevosyan/add-poison-message-handling
c7d5803
fixing a bug related to the results count and something incorrect i h…
b091049
some more updates, adding a private 0 arg constructor to the rewind e…
868b856
Potential fix for pull request finding 'Nested 'if' statements can be…
sophiatev d13c7b3
Potential fix for pull request finding 'Nested 'if' statements can be…
sophiatev 85ae250
updating the iteration logic in the entity dispatcher
7cbb931
addressing the first round of PR comments
756d592
missed changing one place from error to warning
d54925a
removed the IsPoisonMessage method in favor of MaxDispatchCount
2657e8d
updated variable names to be more descriptive
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
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
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
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
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,70 @@ | ||
| // ---------------------------------------------------------------------------------- | ||
| // Copyright Microsoft Corporation | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // ---------------------------------------------------------------------------------- | ||
| #nullable enable | ||
| namespace DurableTask.Core | ||
| { | ||
| using System.Threading.Tasks; | ||
| using DurableTask.Core.History; | ||
|
|
||
| /// <summary> | ||
| /// Provides extensibility points for detecting and handling "poison" messages and invalid work items | ||
| /// in the task dispatchers. | ||
| /// </summary> | ||
| public interface IPoisonMessageHandler | ||
| { | ||
| /// <summary> | ||
| /// The maximum dispatch count after which a message should be considered "poisoned" if it is dispatched again. | ||
| /// </summary> | ||
| public int MaxDispatchCount { get; } | ||
|
|
||
| /// <summary> | ||
| /// Invoked to handle a poison message in the case that a message cannot necessarily | ||
| /// be "failed" by the dispatchers, so the <see cref="IPoisonMessageHandler"/> must | ||
| /// decide what to do. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// If this method returns false, the dispatcher should fall back to the default behavior | ||
| /// followed when poison message handling is not enabled. | ||
| /// </remarks> | ||
| /// <param name="orchestrationInstance">The orchestration instance the event was sent to, or null | ||
| /// if this information is not available.</param> | ||
| /// <param name="historyEvent">The "poisoned" history event.</param> | ||
| /// <param name="reason">The reason the event is "poisoned".</param> | ||
| /// <returns>True if the poison message was successfully handled, otherwise false.</returns> | ||
|
sophiatev marked this conversation as resolved.
|
||
| public Task<bool> HandlePoisonMessageAsync(OrchestrationInstance? orchestrationInstance, HistoryEvent historyEvent, string reason); | ||
|
|
||
| /// <summary> | ||
| /// Invoked to handle a work item that is invalid and cannot be processed at all. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// If this method returns false, the dispatcher should fall back to the default behavior | ||
| /// followed in the case of an invalid work item. | ||
| /// </remarks> | ||
| /// <param name="workItem">The work item that could not be processed.</param> | ||
| /// <param name="reason">Why the work item is invalid.</param> | ||
| /// <returns>True if the poison message was successfully handled, otherwise false.</returns> | ||
| public Task<bool> HandleInvalidWorkItemAsync(TaskOrchestrationWorkItem workItem, string reason); | ||
|
|
||
| /// <summary> | ||
| /// Invoked to handle a work item that is invalid and cannot be processed at all. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// If this method returns false, the dispatcher should fall back to the default behavior | ||
| /// followed in the case of an invalid work item. | ||
| /// </remarks> | ||
| /// <param name="workItem">The work item that could not be processed.</param> | ||
| /// <param name="reason">Why the work item is invalid.</param> | ||
| /// <returns>True if the poison message was successfully handled, otherwise false.</returns> | ||
| public Task<bool> HandleInvalidWorkItemAsync(TaskActivityWorkItem workItem, string reason); | ||
| } | ||
| } | ||
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Unrelated to this PR but I bug I found when testing (JSON was not able to deserialize this event because it lacked a 0-arg constructor and the other constructors all had multiple parameters)