11package io .temporal .nexus ;
22
3- import static io .temporal .internal .common .LinkConverter .workflowEventToNexusLink ;
4- import static io .temporal .internal .common .NexusUtil .nexusProtoLinkToLink ;
5-
63import io .nexusrpc .handler .*;
74import io .nexusrpc .handler .OperationHandler ;
8- import io .temporal .api .common .v1 .Link ;
9- import io .temporal .api .common .v1 .WorkflowExecution ;
10- import io .temporal .api .enums .v1 .EventType ;
115import io .temporal .client .WorkflowClient ;
126import io .temporal .internal .client .NexusStartWorkflowRequest ;
137import io .temporal .internal .client .NexusStartWorkflowResponse ;
148import io .temporal .internal .nexus .CurrentNexusOperationContext ;
159import io .temporal .internal .nexus .InternalNexusOperationContext ;
1610import io .temporal .internal .nexus .OperationTokenUtil ;
17- import java .net .URISyntaxException ;
1811
1912class WorkflowRunOperationImpl <T , R > implements OperationHandler <T , R > {
2013 private final WorkflowHandleFactory <T , R > handleFactory ;
@@ -40,38 +33,9 @@ public OperationStartResult<R> start(
4033
4134 NexusStartWorkflowResponse nexusStartWorkflowResponse =
4235 handle .getInvoker ().invoke (nexusRequest );
43- WorkflowExecution workflowExec = nexusStartWorkflowResponse .getWorkflowExecution ();
4436
45- // If the start workflow response returned a link use it, otherwise
46- // create the link information about the new workflow and return to the caller.
47- Link .WorkflowEvent workflowEventLink =
48- nexusCtx .getStartWorkflowResponseLink ().hasWorkflowEvent ()
49- ? nexusCtx .getStartWorkflowResponseLink ().getWorkflowEvent ()
50- : null ;
51- if (workflowEventLink == null ) {
52- workflowEventLink =
53- Link .WorkflowEvent .newBuilder ()
54- .setNamespace (nexusCtx .getNamespace ())
55- .setWorkflowId (workflowExec .getWorkflowId ())
56- .setRunId (workflowExec .getRunId ())
57- .setEventRef (
58- Link .WorkflowEvent .EventReference .newBuilder ()
59- .setEventType (EventType .EVENT_TYPE_WORKFLOW_EXECUTION_STARTED ))
60- .build ();
61- }
62- io .temporal .api .nexus .v1 .Link nexusLink = workflowEventToNexusLink (workflowEventLink );
63- // Attach the link to the operation result.
64- OperationStartResult .Builder <R > result =
65- OperationStartResult .newAsyncBuilder (nexusStartWorkflowResponse .getOperationToken ());
66- if (nexusLink != null ) {
67- try {
68- ctx .addLinks (nexusProtoLinkToLink (nexusLink ));
69- } catch (URISyntaxException e ) {
70- // Not expected as the link is constructed by the SDK.
71- throw new HandlerException (HandlerException .ErrorType .INTERNAL , "failed to parse URI" , e );
72- }
73- }
74- return result .build ();
37+ return OperationStartResult .<R >newAsyncBuilder (nexusStartWorkflowResponse .getOperationToken ())
38+ .build ();
7539 }
7640
7741 @ Override
0 commit comments