-
Notifications
You must be signed in to change notification settings - Fork 42
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
Make workflow show output json usable for replay #110
Conversation
319a726
to
b385f4c
Compare
b385f4c
to
3b24b0c
Compare
3b24b0c
to
15a7c6b
Compare
common/defs-flags.go
Outdated
FlagInputSTQDefinition = "Optional Query input, in JSON format.\nFor multiple parameters, concatenate them and separate by space." | ||
FlagInputFileSTQDefinition = "Passes optional Query input from a JSON file.\nIf there are multiple JSON, concatenate them and separate by space or newline.\n" + "Input from the command line will overwrite file input." | ||
FlagInputSTQDefinition = "Optional Query input, in JSON format.\nFor multiple parameters, concatenate them and separate by space." | ||
FlagInputFileSTQDefinition = "Passes optional Query input from a JSON file.\nIf there are multiple JSON, concatenate them and separate by space or newline.\n" + "Input from the command line will overwrite file input." |
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.
nit: why aren't we using multiline strings here for better readability?
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.
I'll change in a new PR
cc @DJSanti
workflow/workflow_commands.go
Outdated
var lastEvent historypb.HistoryEvent // used for print result of this run | ||
var lastEvent historypb.HistoryEvent |
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.
Why remove the comment?
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.
if lastEvent
usage changes later in code then the comment needs to be updated as well. Figured it's better to give a good name to the variable than commenting it (i think the name is already good, or another option executionResult
)
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.
changed to wfResult, should clarify the variable better and not need the comment?
hIter := sdkClient.GetWorkflowHistory(tcCtx, wid, rid, watch, enumspb.HISTORY_EVENT_FILTER_TYPE_ALL_EVENT) | ||
iter := &historyIterator{iter: hIter, maxFieldLength: maxFieldLength, lastEvent: &lastEvent} | ||
err = output.PrintIterator(c, iter, po) | ||
iter := sdkClient.GetWorkflowHistory(tcCtx, wid, rid, watch, enumspb.HISTORY_EVENT_FILTER_TYPE_ALL_EVENT) |
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.
Watch and JSON aren't compatible, can we ensure they're not both set?
workflow/workflow_commands.go
Outdated
history := &historypb.History{} | ||
history.Events = events | ||
|
||
common.PrettyPrintJSONObject(history) |
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.
Just verifying that this will not generate pretty output when stdout is not a TTY.
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.
This requires tests.
97ce5b8
to
c00c2f4
Compare
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.
I mostly want to see a test for this but otherwise LGTM.
I’d rather use the cli for the test server so we utilize it as much as possible |
i'm split between these options: Ideally i would like integration tests to directly cover CLI dev server, the commands and options. To test one thing at a time instead of implicitly proxy testing CLI server in unrelated tests. I see your point though update: changing to SDK based dev server |
49d0693
to
92652d1
Compare
if err != nil { | ||
fmt.Printf("Error when try to print pretty: %v", err) | ||
fmt.Println(o) | ||
fmt.Fprintf(w, "Error when try to print pretty: %v", err) |
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.
All fmt.Printf
should be fmt.Fprintf
. No?
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.
yes! i'll send separately to not mix
Co-authored-by: Alex Shtin <[email protected]>
What was changed
Made
workflow show --output json
produce replayable historyDepends on temporalio/tctl-kit#39
Why?
Allows exporting replayable history with syntax
Checklist
Closes
How was this tested:
E2E test here #171