@@ -50,19 +50,24 @@ func createSubWorkflowInstance[TResult any](ctx Context, options SubWorkflowOpti
50
50
}
51
51
52
52
// Check return type
53
- if err := a.ReturnTypeMatch [TResult ](wf ); err != nil {
54
- f .Set (* new (TResult ), err )
55
- return f
56
- }
53
+ var workflowName string
54
+ if name , ok := wf .(string ); ok {
55
+ workflowName = name
56
+ } else {
57
+ workflowName = fn .Name (wf )
58
+
59
+ if err := a.ReturnTypeMatch [TResult ](wf ); err != nil {
60
+ f .Set (* new (TResult ), err )
61
+ return f
62
+ }
57
63
58
- // Check arguments
59
- if err := a .ParamsMatch (wf , args ... ); err != nil {
60
- f .Set (* new (TResult ), err )
61
- return f
64
+ // Check arguments
65
+ if err := a .ParamsMatch (wf , args ... ); err != nil {
66
+ f .Set (* new (TResult ), err )
67
+ return f
68
+ }
62
69
}
63
70
64
- name := fn .Name (wf )
65
-
66
71
cv := contextvalue .Converter (ctx )
67
72
inputs , err := a .ArgsToInputs (cv , args ... )
68
73
if err != nil {
@@ -74,9 +79,9 @@ func createSubWorkflowInstance[TResult any](ctx Context, options SubWorkflowOpti
74
79
scheduleEventID := wfState .GetNextScheduleEventID ()
75
80
76
81
ctx , span := workflowtracer .Tracer (ctx ).Start (ctx ,
77
- fmt .Sprintf ("CreateSubworkflowInstance: %s" , name ),
82
+ fmt .Sprintf ("CreateSubworkflowInstance: %s" , workflowName ),
78
83
trace .WithAttributes (
79
- attribute .String (log .WorkflowNameKey , name ),
84
+ attribute .String (log .WorkflowNameKey , workflowName ),
80
85
attribute .Int64 (log .ScheduleEventIDKey , scheduleEventID ),
81
86
attribute .Int (log .AttemptKey , attempt ),
82
87
))
@@ -90,7 +95,7 @@ func createSubWorkflowInstance[TResult any](ctx Context, options SubWorkflowOpti
90
95
return f
91
96
}
92
97
93
- cmd := command .NewScheduleSubWorkflowCommand (scheduleEventID , wfState .Instance (), options .InstanceID , name , inputs , metadata )
98
+ cmd := command .NewScheduleSubWorkflowCommand (scheduleEventID , wfState .Instance (), options .InstanceID , workflowName , inputs , metadata )
94
99
95
100
wfState .AddCommand (cmd )
96
101
wfState .TrackFuture (scheduleEventID , workflowstate .AsDecodingSettable (cv , f ))
0 commit comments