Repository navigation
Adding rewind client API #253
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
+743
−14
Merged
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a1e2098
initial commit
bachuv cab7522
added api
bachuv 5a804bc
updated EndToEndTests.java
bachuv 132532d
updated CHANGELOG
bachuv f73c058
updated build-validation.yml
bachuv 959da6a
Merge branch 'main' into vabachu/rewind
bachuv 46cc864
reverted build-validation.yml changes
bachuv 8b6b5af
Merge branch 'main' into vabachu/rewind
bachuv 2389289
updated test report paths
bachuv 8e5c920
added tests
bachuv 7cec5d1
addressed PR feedback
bachuv 72c1fc8
Merge branch 'main' into vabachu/rewind
bachuv c3c5e45
addressed copilot comments
bachuv cdefa97
addressed PR feedback
bachuv f17d006
Remove rewind tests from standalone SDK and keep Functions e2e tests
bachuv 4f8ac2d
Fix rewind e2e test
bachuv 7eb2567
Increase rewind e2e test polling timeouts for CI reliability
bachuv 66da59b
added tests
bachuv c6ca0e4
updated tests
bachuv 06b7fd7
updated StartRewindNonFailedOrchestration test
bachuv 4bfd85a
updated error handling
bachuv fb04187
added error handling for when an instance id doesn't exist
bachuv 37f27ab
updated comment
bachuv ad5982e
updated tests
bachuv 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
Some comments aren't visible on the classic Files Changed page.
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
|
bachuv marked this conversation as resolved.
Resolved
|
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,89 @@ | ||
| package com.functions; | ||
|
|
||
| import com.microsoft.azure.functions.ExecutionContext; | ||
| import com.microsoft.azure.functions.HttpMethod; | ||
| import com.microsoft.azure.functions.HttpRequestMessage; | ||
| import com.microsoft.azure.functions.HttpResponseMessage; | ||
| import com.microsoft.azure.functions.annotation.AuthorizationLevel; | ||
| import com.microsoft.azure.functions.annotation.FunctionName; | ||
| import com.microsoft.azure.functions.annotation.HttpTrigger; | ||
| import com.microsoft.durabletask.DurableTaskClient; | ||
| import com.microsoft.durabletask.TaskOrchestrationContext; | ||
| import com.microsoft.durabletask.azurefunctions.DurableActivityTrigger; | ||
| import com.microsoft.durabletask.azurefunctions.DurableClientContext; | ||
| import com.microsoft.durabletask.azurefunctions.DurableClientInput; | ||
| import com.microsoft.durabletask.azurefunctions.DurableOrchestrationTrigger; | ||
|
|
||
| import java.util.Optional; | ||
| import java.util.concurrent.atomic.AtomicBoolean; | ||
|
|
||
| /** | ||
| * Sample functions to test the rewind functionality. | ||
| * Rewind allows a failed orchestration to be replayed from its last known good state. | ||
| */ | ||
| public class RewindTest { | ||
|
|
||
| // Flag to control whether the activity should fail (first call fails, subsequent calls succeed) | ||
| private static final AtomicBoolean shouldFail = new AtomicBoolean(true); | ||
|
|
||
| /** | ||
| * HTTP trigger to start the rewindable orchestration. | ||
| */ | ||
| @FunctionName("StartRewindableOrchestration") | ||
| public HttpResponseMessage startRewindableOrchestration( | ||
| @HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request, | ||
| @DurableClientInput(name = "durableContext") DurableClientContext durableContext, | ||
| final ExecutionContext context) { | ||
| context.getLogger().info("Starting rewindable orchestration."); | ||
|
|
||
| // Reset the failure flag so the first activity call will fail | ||
| shouldFail.set(true); | ||
|
|
||
| DurableTaskClient client = durableContext.getClient(); | ||
| String instanceId = client.scheduleNewOrchestrationInstance("RewindableOrchestration"); | ||
| context.getLogger().info("Created new Java orchestration with instance ID = " + instanceId); | ||
| return durableContext.createCheckStatusResponse(request, instanceId); | ||
| } | ||
|
|
||
| /** | ||
| * Orchestration that calls an activity which will fail on the first attempt. | ||
| * After rewinding, the orchestration will replay and the activity will succeed. | ||
| */ | ||
| @FunctionName("RewindableOrchestration") | ||
| public String rewindableOrchestration( | ||
| @DurableOrchestrationTrigger(name = "ctx") TaskOrchestrationContext ctx) { | ||
| // Call the activity that may fail | ||
| String result = ctx.callActivity("FailOnceActivity", "RewindTest", String.class).await(); | ||
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Activity that fails on the first call but succeeds on subsequent calls. | ||
| * This simulates a transient failure that can be recovered by rewinding. | ||
| */ | ||
| @FunctionName("FailOnceActivity") | ||
| public String failOnceActivity( | ||
| @DurableActivityTrigger(name = "input") String input, | ||
| final ExecutionContext context) { | ||
| if (shouldFail.compareAndSet(true, false)) { | ||
| context.getLogger().warning("FailOnceActivity: Simulating failure for input: " + input); | ||
| throw new RuntimeException("Simulated transient failure - rewind to retry"); | ||
| } | ||
| context.getLogger().info("FailOnceActivity: Success for input: " + input); | ||
| return input + "-rewound-success"; | ||
| } | ||
|
|
||
| /** | ||
| * HTTP trigger to reset the failure flag (useful for testing). | ||
| */ | ||
| @FunctionName("ResetRewindFailureFlag") | ||
| public HttpResponseMessage resetRewindFailureFlag( | ||
| @HttpTrigger(name = "req", methods = {HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request, | ||
| final ExecutionContext context) { | ||
| shouldFail.set(true); | ||
| context.getLogger().info("Reset failure flag to true."); | ||
| return request.createResponseBuilder(com.microsoft.azure.functions.HttpStatus.OK) | ||
| .body("Failure flag reset to true") | ||
| .build(); | ||
| } | ||
| } |
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.