Add getParent() API to TaskOrchestrationContext for parent instance support#284
Open
bachuv wants to merge 5 commits into
Open
Add getParent() API to TaskOrchestrationContext for parent instance support#284bachuv wants to merge 5 commits into
bachuv wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds parent-orchestration discovery for sub-orchestrations by introducing a TaskOrchestrationContext#getParent() API (modeled after .NET), wiring it from the ExecutionStartedEvent.parentInstance protobuf field, and providing tests + a runnable sample to demonstrate parent-present vs standalone behavior.
Changes:
- Introduces
ParentOrchestrationInstance(name + instanceId) and a non-breaking defaultTaskOrchestrationContext#getParent()method (returnsnullwhen absent). - Populates parent instance info in
TaskOrchestrationExecutorduringEXECUTIONSTARTEDevent processing. - Adds unit tests and a new sample + Gradle run task to validate and demonstrate the feature.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| samples/src/main/java/io/durabletask/samples/ParentInstanceSample.java | New runnable sample demonstrating ctx.getParent() for sub-orchestrations vs standalone runs. |
| samples/build.gradle | Adds runParentInstanceSample JavaExec task to run the new sample. |
| client/src/test/java/com/microsoft/durabletask/TaskOrchestrationExecutorTest.java | Adds unit tests covering parent present/absent, replay stability, and model equality. |
| client/src/main/java/com/microsoft/durabletask/TaskOrchestrationExecutor.java | Wires parent instance extraction from ExecutionStartedEvent.parentInstance into context implementation. |
| client/src/main/java/com/microsoft/durabletask/TaskOrchestrationContext.java | Adds default getParent() API returning null when not a sub-orchestration. |
| client/src/main/java/com/microsoft/durabletask/ParentOrchestrationInstance.java | Adds the new immutable parent instance model type. |
5a4752b to
56523d7
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue describing the changes in this PR
Adds
getParent()API toTaskOrchestrationContext, bringing the Java SDK to parity with .NET'sTaskOrchestrationContext.Parentproperty. This allows sub-orchestrations to discover their parent orchestration's name and instance ID at runtime.Changes:
ParentOrchestrationInstance— immutable model withgetName()andgetInstanceId()getParent()onTaskOrchestrationContext— returnsnullfor standalone orchestrations (non-breaking, backward-compatible)TaskOrchestrationExecutor— populates parent fromExecutionStartedEvent.parentInstanceprotobuf fieldParentInstanceSample— runnable sample demonstrating both sub-orchestration (parent detected) and standalone (null parent) scenariosPull request checklist
CHANGELOG.mdAdditional information
defaultinterface method to avoid breaking existingTaskOrchestrationContextimplementersParentInstanceInfofields (taskScheduledId,version) used for internal completion routing are intentionally not exposed, matching .NET's public API surface./gradlew runParentInstanceSample