Add client APIs to list instance IDs and read orchestration history#292
Add client APIs to list instance IDs and read orchestration history#292bachuv wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds new Durable Task client capabilities for bulk instance enumeration and orchestration history retrieval, along with a new public com.microsoft.durabletask.history domain model and conversion layer from protobuf history events.
Changes:
- Adds
DurableTaskClient.listInstanceIds(ListInstanceIdsQuery)and supporting query/result types for paging terminal instance IDs by completion-time window and status. - Adds
DurableTaskClient.getOrchestrationHistory(String)backed by the sidecarStreamInstanceHistorygRPC operation, returning a typed public history-event model. - Introduces
HistoryEventConverterplus unit/integration tests for history conversion and the new client APIs.
Reviewed changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| client/src/test/java/com/microsoft/durabletask/IntegrationTests.java | Adds integration coverage for listing completed instance IDs and fetching typed history. |
| client/src/test/java/com/microsoft/durabletask/HistoryEventConverterTest.java | Adds unit tests validating protobuf→domain history event conversion. |
| client/src/main/java/com/microsoft/durabletask/ListInstanceIdsResult.java | New paging result model for instance ID enumeration. |
| client/src/main/java/com/microsoft/durabletask/ListInstanceIdsQuery.java | New query model for completion-window instance ID listing. |
| client/src/main/java/com/microsoft/durabletask/HistoryEventConverter.java | Implements protobuf→public domain model conversion for history events. |
| client/src/main/java/com/microsoft/durabletask/history/TraceContext.java | Adds public model for W3C trace context on history events. |
| client/src/main/java/com/microsoft/durabletask/history/TimerFiredEvent.java | Adds typed history event model for fired timers. |
| client/src/main/java/com/microsoft/durabletask/history/TimerCreatedEvent.java | Adds typed history event model for created timers. |
| client/src/main/java/com/microsoft/durabletask/history/TaskScheduledEvent.java | Adds typed history event model for scheduled activities. |
| client/src/main/java/com/microsoft/durabletask/history/TaskFailedEvent.java | Adds typed history event model for failed activities. |
| client/src/main/java/com/microsoft/durabletask/history/TaskCompletedEvent.java | Adds typed history event model for completed activities. |
| client/src/main/java/com/microsoft/durabletask/history/SubOrchestrationInstanceFailedEvent.java | Adds typed history event model for failed sub-orchestrations. |
| client/src/main/java/com/microsoft/durabletask/history/SubOrchestrationInstanceCreatedEvent.java | Adds typed history event model for created sub-orchestrations. |
| client/src/main/java/com/microsoft/durabletask/history/SubOrchestrationInstanceCompletedEvent.java | Adds typed history event model for completed sub-orchestrations. |
| client/src/main/java/com/microsoft/durabletask/history/ParentInstanceInfo.java | Adds model for parent-orchestration metadata referenced by history events. |
| client/src/main/java/com/microsoft/durabletask/history/OrchestratorStartedEvent.java | Adds typed history event model for replay/episode start markers. |
| client/src/main/java/com/microsoft/durabletask/history/OrchestratorCompletedEvent.java | Adds typed history event model for replay/episode end markers. |
| client/src/main/java/com/microsoft/durabletask/history/OrchestrationState.java | Adds snapshot model carried by history state checkpoint events. |
| client/src/main/java/com/microsoft/durabletask/history/OrchestrationInstance.java | Adds model identifying an orchestration instance (+ optional execution ID). |
| client/src/main/java/com/microsoft/durabletask/history/HistoryStateEvent.java | Adds typed history event model for orchestration state snapshots. |
| client/src/main/java/com/microsoft/durabletask/history/HistoryEvent.java | Adds base class for the public history event hierarchy. |
| client/src/main/java/com/microsoft/durabletask/history/GenericEvent.java | Adds typed history event model for generic/free-form payload events. |
| client/src/main/java/com/microsoft/durabletask/history/ExecutionTerminatedEvent.java | Adds typed history event model for termination. |
| client/src/main/java/com/microsoft/durabletask/history/ExecutionSuspendedEvent.java | Adds typed history event model for suspension. |
| client/src/main/java/com/microsoft/durabletask/history/ExecutionStartedEvent.java | Adds typed history event model for orchestration start. |
| client/src/main/java/com/microsoft/durabletask/history/ExecutionRewoundEvent.java | Adds typed history event model for rewind operations. |
| client/src/main/java/com/microsoft/durabletask/history/ExecutionResumedEvent.java | Adds typed history event model for resume. |
| client/src/main/java/com/microsoft/durabletask/history/ExecutionCompletedEvent.java | Adds typed history event model for terminal completion. |
| client/src/main/java/com/microsoft/durabletask/history/EventSentEvent.java | Adds typed history event model for sending external events. |
| client/src/main/java/com/microsoft/durabletask/history/EventRaisedEvent.java | Adds typed history event model for receiving external events. |
| client/src/main/java/com/microsoft/durabletask/history/EntityUnlockSentEvent.java | Adds typed history event model for entity unlock operations. |
| client/src/main/java/com/microsoft/durabletask/history/EntityOperationSignaledEvent.java | Adds typed history event model for one-way entity signals. |
| client/src/main/java/com/microsoft/durabletask/history/EntityOperationFailedEvent.java | Adds typed history event model for failed entity operations. |
| client/src/main/java/com/microsoft/durabletask/history/EntityOperationCompletedEvent.java | Adds typed history event model for completed entity operations. |
| client/src/main/java/com/microsoft/durabletask/history/EntityOperationCalledEvent.java | Adds typed history event model for two-way entity calls. |
| client/src/main/java/com/microsoft/durabletask/history/EntityLockRequestedEvent.java | Adds typed history event model for entity lock requests. |
| client/src/main/java/com/microsoft/durabletask/history/EntityLockGrantedEvent.java | Adds typed history event model for entity lock grants. |
| client/src/main/java/com/microsoft/durabletask/history/ContinueAsNewEvent.java | Adds typed history event model for continue-as-new. |
| client/src/main/java/com/microsoft/durabletask/DurableTaskGrpcClient.java | Implements new APIs over sidecar gRPC: listInstanceIds + stream history conversion. |
| client/src/main/java/com/microsoft/durabletask/DurableTaskClient.java | Adds new abstract public APIs for instance ID listing and orchestration history retrieval. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nytian
left a comment
There was a problem hiding this comment.
Left a few comments. Thanks for the PR!
| * @param query filter criteria: completion-time window, terminal runtime statuses, page size, and pagination cursor | ||
| * @return a page of matching instance IDs and a cursor for the next page | ||
| */ | ||
| public abstract ListInstanceIdsResult listInstanceIds(ListInstanceIdsQuery query); |
There was a problem hiding this comment.
Just wondering which classes extend DurableTaskClient? Only within this repo, right? Can we add a default implementation that throws UnsupportedOperationException? I think its safer for these breaking changes.
| * @param pageSize the maximum number of instance IDs to return per page | ||
| * @return this query object | ||
| */ | ||
| public ListInstanceIdsQuery setPageSize(int pageSize) { |
There was a problem hiding this comment.
Lets add a check here to ensure pageSize won't be negative or 0
| * Unit tests for {@link HistoryEventConverter}, which maps protobuf history events to the public | ||
| * {@code com.microsoft.durabletask.history} domain model. | ||
| */ | ||
| public class HistoryEventConverterTest { |
There was a problem hiding this comment.
Seems there are some history events are not tested here. Can you add them? Eg the entity types and suspend/resume and continueasnew etc,
| historyEvents.add(HistoryEventConverter.fromProto(protoEvent)); | ||
| } | ||
| } | ||
| return historyEvents; |
There was a problem hiding this comment.
nit: if cx has a very large history list, we have to return to them after processing them all in memory. So I fell like Stream/Page is better here, but I feel this is not super common case, so up to your decision :)
Issue describing the changes in this PR
Adds client APIs to enumerate orchestration instances and read a completed instance's
history, plus a public history-event model.
Changes
DurableTaskClient.listInstanceIds(ListInstanceIdsQuery)→ListInstanceIdsResult— page terminal/instance IDs by filter (completion window, statuses, continuation token).DurableTaskClient.getOrchestrationHistory(String instanceId)→List<HistoryEvent>— retrieve an instance's full ordered history.com.microsoft.durabletask.history—HistoryEventplus per-type subclasses (ExecutionStarted/Completed,TaskScheduled/Completed/Failed,Timer*,SubOrchestration*,EntityOperation*/EntityLock*,EventSent/Raised,Generic,HistoryState, …).ListInstanceIdsandStreamInstanceHistorygRPC operations (managed DTS; sidecar/emulator ≥ v0.4.22).Notes
Pull request checklist
CHANGELOG.md