Conversation
8f06aca to
de6a5b0
Compare
af87649 to
34b5d4f
Compare
3a01f82 to
8254f69
Compare
ef6a516 to
597e8d2
Compare
| "time" | ||
|
|
||
| "github.com/gorilla/mux" | ||
| "github.com/nexus-rpc/sdk-go/nexus" |
There was a problem hiding this comment.
Moved here from components; adjusted some of the names to fit into new package better.
597e8d2 to
35c28a9
Compare
| // When the request has nil headers, it should fall back to the local client. | ||
| var gotPath string | ||
| ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| assert.Equal(t, commonnexus.PathCompletionCallbackNoIdentifier, r.URL.Path) |
There was a problem hiding this comment.
addressed linter error
| result: result, | ||
| retryPolicy: h.config.RetryPolicy(), | ||
| }) | ||
| return err |
There was a problem hiding this comment.
addressed linter error by moving out
1c5d51f to
b6ee1e8
Compare
| // user-agent header contains Nexus SDK client info in the form <sdk-name>/v<sdk-version> | ||
| headerUserAgent = "user-agent" | ||
| clientNameVersionDelim = "/v" | ||
| ) |
There was a problem hiding this comment.
^ these already exist in temporal/service/frontend/nexus_handler.go
There was a problem hiding this comment.
One step closer to eliminating the tech debt we created with the duplication of interceptors here.
| } | ||
|
|
||
| func (h *NexusHTTPHandler) parseTlsAndAuthInfo(r *http.Request, nc *nexusContext) (*http.Request, error) { | ||
| func (h *NexusOperationHTTPHandler) parseTLSAndAuthInfo(r *http.Request, nc *nexusContext) (*http.Request, error) { |
There was a problem hiding this comment.
address linter error
| // The update may legitimately delete the addressed component, in which case | ||
| // there is no new ref to return even though the transition succeeded. | ||
| return nil, nil | ||
| } |
There was a problem hiding this comment.
I had to add this stopgap to make tests pass.
cc @yycptt if you have thoughts on this issue
There was a problem hiding this comment.
LGTM, I think we just need to document chasm.UpdateComponent to mention that the returned ref could be nil if the component is not the root and it was deleted in the transaction.
bergundy
left a comment
There was a problem hiding this comment.
Overall this looks great.
JFYI (not blocking this PR), you're also missing the fallback to the "current" run. That's only relevant for workflow operations though. I think we'll need some special handling for the token for workflow. I think the archetype should be on the token and we can change the behavior based on that.
| fx.Invoke(EndpointRegistryLifetimeHooks), | ||
| fx.Provide(schedulerpb.NewSchedulerServiceLayeredClient), | ||
| nexusfrontend.Module, | ||
| chasmnexus.Module, |
There was a problem hiding this comment.
Isn't this supposed to be FrontendModule?
There was a problem hiding this comment.
see https://github.com/temporalio/temporal/pull/9951/changes#r3089760669
Yes, on the feature branch we have FrontendModule and I'll change it there; didn't want to pull that change in here.
| // user-agent header contains Nexus SDK client info in the form <sdk-name>/v<sdk-version> | ||
| headerUserAgent = "user-agent" | ||
| clientNameVersionDelim = "/v" | ||
| ) |
There was a problem hiding this comment.
One step closer to eliminating the tech debt we created with the duplication of interceptors here.
| // CompleteOperation implements nexus.CompletionHandler. | ||
| // nolint:revive // (cyclomatic complexity) This function is long but the complexity is justified. | ||
| func (h *completionHandler) CompleteOperation(ctx context.Context, r *nexusrpc.CompletionRequest) (retErr error) { | ||
| func (h *NexusCompletionHandler) CompleteOperation(ctx context.Context, r *nexusrpc.CompletionRequest) (retErr error) { |
There was a problem hiding this comment.
Does this struct need to be exported? I thought we only reference it from within the frontend package. (Same for the constructor, etc...)
There was a problem hiding this comment.
I saw that NexusOperationHTTPHandler and OpenAPIHTTPHandler are exported, too, and matched that here for consistency. It can be unexported. I'll make the change.
|
|
||
| completion, err := h.CallbackTokenGenerator.DecodeCompletion(token) | ||
| if err != nil { | ||
| if err != nil || completion == nil { |
There was a problem hiding this comment.
Why would the completion be nil and the error not be nil? That seems unexpected behavior to me.
| } | ||
| namespaceID = ref.GetNamespaceId() | ||
| businessID = ref.GetBusinessId() | ||
| } |
There was a problem hiding this comment.
System isn't relevant here, it follows a separate path.
|
|
||
| namespaceID := completion.GetNamespaceId() | ||
| businessID := completion.GetWorkflowId() | ||
| if namespaceID == "" && len(completion.GetComponentRef()) > 0 { |
There was a problem hiding this comment.
I would put validation in DecodeCompletion to ensure that either the HSM fields are all present of component ref is not empty. We should never have both variations populated.
| namespaceID = ref.GetNamespaceId() | ||
| businessID = ref.GetBusinessId() |
There was a problem hiding this comment.
Let's verify that these aren't empty here.
| return TransitionTimedOut.Apply(o, ctx, EventTimedOut{}) | ||
| } | ||
|
|
||
| func (o *Operation) HandleNexusCompletion( |
There was a problem hiding this comment.
Maybe put this next to saveInvocationResult because functionally there is a lot of overlap? And I would add a comment mentioning why these two separate methods exist. Ideally we'd have only one but I'd rather not spend time refactoring that right now. We can live with a bit of duplication here.
| // The update may legitimately delete the addressed component, in which case | ||
| // there is no new ref to return even though the transition succeeded. | ||
| return nil, nil | ||
| } |
There was a problem hiding this comment.
LGTM, I think we just need to document chasm.UpdateComponent to mention that the returned ref could be nil if the component is not the root and it was deleted in the transaction.
| callbackToken, err = gen.Tokenize(workflowNotFoundToken) | ||
| s.NoError(err) | ||
| completion.Header = nexus.Header{commonnexus.CallbackTokenHeader: callbackToken} | ||
| if !chasmEnabled { |
There was a problem hiding this comment.
You can have an equivalent token mutation test for the CHASM implementation though.
What changed?
Support Nexus async completion in CHASM.
PS: completion-before-start will be handled in a follow-up PR.
How did you test it?
Potential risks
Is behind feature flag.