@@ -43,9 +43,9 @@ import (
43
43
"errors"
44
44
"strings"
45
45
46
+ "github.com/google/uuid"
46
47
"github.com/nexus-rpc/sdk-go/nexus"
47
48
"go.temporal.io/api/common/v1"
48
- "go.temporal.io/api/enums/v1"
49
49
"go.temporal.io/sdk/client"
50
50
"go.temporal.io/sdk/internal"
51
51
"go.temporal.io/sdk/internal/common/metrics"
@@ -280,6 +280,7 @@ type workflowHandle[T any] struct {
280
280
id string
281
281
runID string
282
282
cachedToken string
283
+ requestID string
283
284
}
284
285
285
286
func (h workflowHandle [T ]) ID () string {
@@ -291,14 +292,14 @@ func (h workflowHandle[T]) RunID() string {
291
292
}
292
293
293
294
func (h workflowHandle [T ]) link () nexus.Link {
294
- // Create the link information about the new workflow and return to the caller.
295
+ // Create the link information about the workflow and return to the caller.
295
296
link := & common.Link_WorkflowEvent {
296
297
Namespace : h .namespace ,
297
298
WorkflowId : h .ID (),
298
299
RunId : h .RunID (),
299
- Reference : & common.Link_WorkflowEvent_EventRef {
300
- EventRef : & common.Link_WorkflowEvent_EventReference {
301
- EventType : enums . EVENT_TYPE_WORKFLOW_EXECUTION_STARTED ,
300
+ Reference : & common.Link_WorkflowEvent_RequestIdRef {
301
+ RequestIdRef : & common.Link_WorkflowEvent_RequestIdReference {
302
+ RequestId : h . requestID ,
302
303
},
303
304
},
304
305
}
@@ -350,9 +351,13 @@ func ExecuteUntypedWorkflow[R any](
350
351
return nil , internal .ErrMissingWorkflowID
351
352
}
352
353
353
- if nexusOptions .RequestID != "" {
354
- internal .SetRequestIDOnStartWorkflowOptions (& startWorkflowOptions , nexusOptions .RequestID )
354
+ requestID := nexusOptions .RequestID
355
+ if requestID == "" {
356
+ // Assigning a random UUID so the workflowHandle is able to create the link to the workflow.
357
+ // Client.ExecuteWorkflow already does the same, so this is just assigning an UUID ahead.
358
+ requestID = uuid .NewString ()
355
359
}
360
+ internal .SetRequestIDOnStartWorkflowOptions (& startWorkflowOptions , requestID )
356
361
357
362
var encodedToken string
358
363
if nexusOptions .CallbackURL != "" {
@@ -404,6 +409,7 @@ func ExecuteUntypedWorkflow[R any](
404
409
id : run .GetID (),
405
410
runID : run .GetRunID (),
406
411
cachedToken : encodedToken ,
412
+ requestID : requestID ,
407
413
}, nil
408
414
}
409
415
0 commit comments