Skip to content

Add support for Standalone Nexus Operations#1046

Draft
Quinn-With-Two-Ns wants to merge 2 commits into
mainfrom
NEXUS-332
Draft

Add support for Standalone Nexus Operations#1046
Quinn-With-Two-Ns wants to merge 2 commits into
mainfrom
NEXUS-332

Conversation

@Quinn-With-Two-Ns
Copy link
Copy Markdown
Contributor

What was changed

Add support for Standalone Nexus Operations

Why?

So users can interact with them through the CLI

Checklist

  1. Closes

  2. How was this tested:

  3. Any docs updates needed?

Copy link
Copy Markdown

@Evanthx Evanthx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few nit-picks! Your call on whether they are worth addressing, they are all quite minor.

if err := printNexusOperationFailure(cctx, operationID, runID, v.Failure); err != nil {
cctx.Logger.Error("Nexus operation failed, and printing the output also failed", "error", err)
}
return fmt.Errorf("nexus operation failed")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should Nexus be capitalized? Same for line 112 above and 131, 492 below. Didn't do a complete check for places, but looking at the code for "fmt.Errorf.*nexus" I see it both ways!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in errors it should be lower case based on convention, same as workflow and logs it may be uppercase

// Matches the SDK's pollActivityTimeout in internal_activity_client.go.
const pollNexusOperationTimeout = 60 * time.Second

// pollNexusOperationOutcome polls for a nexus operation result using a
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to ignore this comment - would this be better as a method on Handle then, both for reuse and so that if someone made a change to Handle.Get later this method would be visible there to get the equivalent change? ie, maybe Handle would then have a Get and a RawGet method, something like that?

if cctx.JSONShorthandPayloads {
var valuePtr any
if err = converter.GetDefaultDataConverter().FromPayload(result, &valuePtr); err != nil {
return fmt.Errorf("failed decoding result: %w", err)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might add a little more context here - ie, Nexus operation completed, but failed decoding result, something like that?

Same for the other errors being returned below.

}
resultJSON, err := json.Marshal(valuePtr)
if err != nil {
return fmt.Errorf("failed marshaling result: %w", err)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 202 and 210 return the exact same string as 177 and 184. So if we get that error, we won't actually know which line failed, just that it's one of those two. Given that they are doing the same thing to the same object it might not matter much, but it's nice to just go to the offending log line without having to wonder which line it was.

if err != nil {
return fmt.Errorf("failed marshaling failure: %w", err)
}
_ = cctx.Printer.PrintStructured(struct {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

printNexusOperationResult gets the error from PrintStructured and returns it (line 208), this ignores any error values from PrintStructured and returns nil. Should they both behave the same way?

}

func (s *SharedServerSuite) TestNexusOperationCancel() {
endpointName := "test-ep-" + uuid.NewString()[:8]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestNexusOperationCancel and TestNexusOperationTerminate both set up endpoints - can that be combined into a helper function using setupNexusEndpointAndWorker?

Copy link
Copy Markdown

@VegetarianOrc VegetarianOrc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor nits, but looks good to me!

Comment thread internal/temporalcli/commands.yaml
Comment thread internal/temporalcli/commands.yaml
Comment thread internal/temporalcli/commands.yaml
Comment thread internal/temporalcli/commands.yaml
Comment thread internal/temporalcli/commands.nexus_operation.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants