Skip to content
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

Handle Nexus links #1605

Merged
merged 7 commits into from
Aug 28, 2024
Merged

Handle Nexus links #1605

merged 7 commits into from
Aug 28, 2024

Conversation

rodrigozhou
Copy link
Contributor

What was changed

Handle Nexus links

Why?

Support Nexus bi-directional links.

Checklist

  1. Closes

  2. How was this tested:

  1. Any docs updates needed?

@rodrigozhou rodrigozhou requested review from bergundy and cretz August 20, 2024 22:59
@rodrigozhou rodrigozhou requested a review from a team as a code owner August 20, 2024 22:59
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-links branch from 71b00c5 to ebcfdd8 Compare August 20, 2024 23:41
go.mod Outdated Show resolved Hide resolved
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-links branch 2 times, most recently from 3828bbe to 2709aa9 Compare August 21, 2024 22:03
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-links branch from 2709aa9 to 7803b3b Compare August 26, 2024 23:28
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-links branch from 7803b3b to ae9bcfe Compare August 27, 2024 17:13
Comment on lines 50 to 52
rePatternNamespace = fmt.Sprintf(`(?P<%s>[a-z0-9-.]+)`, urlPathNamespaceKey)
rePatternWorkflowID = fmt.Sprintf(`(?P<%s>[^/]+)`, urlPathWorkflowIDKey)
rePatternRunID = fmt.Sprintf(`(?P<%s>[a-zA-Z0-9-]+)`, urlPathRunIDKey)
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't be defining these regexps here, you should be able to split the paths and let the server do the validation.
If this made it into the server codebase, you should change there too, I may have missed it Friday.

Copy link
Member

Choose a reason for hiding this comment

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

For example, on the server, namespace doesn't have this character limitation:

func (wh *WorkflowHandler) validateNamespace(
	namespace string,
) error {
	if err := common.ValidateUTF8String("Namespace", namespace); err != nil {
		return err
	}
	if len(namespace) > wh.config.MaxIDLengthLimit() {
		return errNamespaceTooLong
	}
	return nil
}

If we changed the validation logic, we wouldn't want the SDK and server to go out of sync.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't add anything on the server side. I did here in SDK only.

converter/link_converter.go Outdated Show resolved Hide resolved
return nil, fmt.Errorf("failed to parse link to Link_WorkflowEvent")
}

matches := urlPathRE.FindStringSubmatch(link.URL.EscapedPath())
Copy link
Member

Choose a reason for hiding this comment

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

I would just use splits by / here but this is fine if the regexp doesn't limit characters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just thought that validating the individual parts of the split a bit ugly. Regex looks cleaner.

converter/link_converter.go Outdated Show resolved Hide resolved
internal/internal_nexus_task_handler.go Outdated Show resolved Hide resolved
internal/internal_nexus_task_handler.go Outdated Show resolved Hide resolved
converter/link_converter_test.go Outdated Show resolved Hide resolved
converter/link_converter.go Outdated Show resolved Hide resolved
))
)

func ConvertLinkWorkflowEventToNexusLink(we *commonpb.Link_WorkflowEvent) nexus.Link {
Copy link
Member

Choose a reason for hiding this comment

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

Is all of this intended to be public user-facing API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we need these functions in the server.

Copy link
Member

Choose a reason for hiding this comment

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

I think this converter package is for data/failure conversion, not for any thing that might need to be converted. I think this Nexus-specific stuff should go in the temporalnexus package. And I am not sure we should expose these utilities to users.

Copy link
Member

Choose a reason for hiding this comment

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

Ah good point. There's a want to reuse this code in the server codebase to avoid duplicating this logic.

Copy link
Member

Choose a reason for hiding this comment

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

👍 Can move it and leave it public and document it as user facing since it will be

converter/link_converter.go Outdated Show resolved Hide resolved
@bergundy
Copy link
Member

We should expose the links in the workflow API on the NexusOperationExecution https://pkg.go.dev/go.temporal.io/sdk@v1.28.1/workflow#NexusOperationExecution and in workflow info when a workflow is started with a link.

We can do that in a follow up PR AFAIC.

@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-links branch from 6ee5334 to 000358a Compare August 27, 2024 20:48
},
Type: "temporal.api.common.v1.Link.WorkflowEvent",
},
outputURL: "temporal:///namespaces/ns/workflows/wf-id/run-id/history?eventID=1&eventType=WorkflowExecutionStarted&referenceType=EventReference",
Copy link
Member

Choose a reason for hiding this comment

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

I like the idea of the run ID being a query param too, but meh not important

Copy link
Member

Choose a reason for hiding this comment

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

In the UI it's in the path.

Copy link
Member

Choose a reason for hiding this comment

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

How much of this is meant to match UI path vs HTTP API paths?

internal/internal_nexus_task_handler.go Show resolved Hide resolved
},
Type: "temporal.api.common.v1.Link.WorkflowEvent",
},
outputURL: "temporal:///namespaces/ns/workflows/wf-id/run-id/history?eventID=1&eventType=WorkflowExecutionStarted&referenceType=EventReference",
Copy link
Member

Choose a reason for hiding this comment

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

In the UI it's in the path.

@rodrigozhou rodrigozhou enabled auto-merge (squash) August 28, 2024 16:52
@rodrigozhou rodrigozhou disabled auto-merge August 28, 2024 16:54
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-links branch from f4ab96e to 8952557 Compare August 28, 2024 17:14
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/nexus-links branch from 8952557 to 89148d1 Compare August 28, 2024 17:15
@rodrigozhou rodrigozhou merged commit 5364a47 into master Aug 28, 2024
14 checks passed
@rodrigozhou rodrigozhou deleted the rodrigozhou/nexus-links branch August 28, 2024 18:44
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