feat: add --reverse flag to temporal workflow show#988
Open
veeral-patel wants to merge 1 commit intomainfrom
Open
feat: add --reverse flag to temporal workflow show#988veeral-patel wants to merge 1 commit intomainfrom
temporal workflow show#988veeral-patel wants to merge 1 commit intomainfrom
Conversation
Fetches Event History newest-event-first via WorkflowService.GetWorkflowExecutionHistoryReverse, useful for inspecting recent activity on long-running workflows without pulling the full history. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
|
| } | ||
|
|
||
| func (s *structuredHistoryIter) nextRawEventReverse() (*history.HistoryEvent, error) { | ||
| for len(s.reverseBuf) == 0 { |
There was a problem hiding this comment.
Just a question: Under what conditions will this loop? Is this a polling thing only?
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.
What changed?
This PR adds a
--reverseflag to thetemporal workflow showcommand that fetches Event History newest-event-first viaWorkflowService.GetWorkflowExecutionHistoryReverse. Useful for inspecting recent activity on long-running workflows without pulling the full history from the beginning.Files changed
internal/temporalcli/commands.yamlreversebool option undertemporal workflow showinternal/temporalcli/commands.gen.gomake gen— addsReversefield and--reverseflag registrationinternal/temporalcli/commands.workflow_view.go--reverse+--follow; passesreverseandnamespaceinto the history iteratorinternal/temporalcli/commands.workflow_exec.gostructuredHistoryIterwith a reverse code path that pages throughGetWorkflowExecutionHistoryReverse; skips continue-as-new traversal in reverse modeinternal/temporalcli/commands.workflow_view_test.go--reverse --followrejectionHow did you test it?
Unit tests
--reverseWorkflowExecutionCompletedprints beforeWorkflowExecutionStartedin stdout--reverse -o jsonevents[].eventIdis strictly decreasing across the array--follow--reverse --follow--reverse cannot be combined with --followManual tests
Setup
Forward (default) vs reverse — tabular
Events are listed newest-first when
--reverseis set.JSON reverse
eventIdvalues are strictly decreasing, matching reverse order.Detailed reverse
Per-event detail sections are rendered in reverse order.
Reject
--followNonexistent workflow
Error-path behavior is unchanged from the forward implementation.