@@ -52,9 +52,9 @@ type OrchestrationContext struct {
52
52
53
53
// callSubOrchestratorOptions is a struct that holds the options for the CallSubOrchestrator orchestrator method.
54
54
type callSubOrchestratorOptions struct {
55
- instanceID string
56
- rawInput * wrapperspb.StringValue
57
-
55
+ instanceID string
56
+ rawInput * wrapperspb.StringValue
57
+ targetAppID * string
58
58
retryPolicy * RetryPolicy
59
59
}
60
60
@@ -64,6 +64,14 @@ type subOrchestratorOption func(*callSubOrchestratorOptions) error
64
64
// ContinueAsNewOption is a functional option type for the ContinueAsNew orchestrator method.
65
65
type ContinueAsNewOption func (* OrchestrationContext )
66
66
67
+ // WithSubOrchestratorAppID is a functional option type for the CallSubOrchestrator orchestrator method that specifies the app ID of the target activity.
68
+ func WithSubOrchestratorAppID (appID string ) subOrchestratorOption {
69
+ return func (opts * callSubOrchestratorOptions ) error {
70
+ opts .targetAppID = & appID
71
+ return nil
72
+ }
73
+ }
74
+
67
75
// WithKeepUnprocessedEvents returns a ContinueAsNewOptions struct that instructs the
68
76
// runtime to carry forward any unprocessed external events to the new instance.
69
77
func WithKeepUnprocessedEvents () ContinueAsNewOption {
@@ -205,7 +213,14 @@ func (ctx *OrchestrationContext) processEvent(e *backend.HistoryEvent) error {
205
213
} else if es := e .GetExecutionStarted (); es != nil {
206
214
// Extract source AppID from HistoryEvent Router if this is ExecutionStartedEvent
207
215
if e .GetRouter () != nil {
208
- ctx .appID = ptr .Of (e .GetRouter ().GetSource ())
216
+ router := e .GetRouter ()
217
+ // For cross-app suborchestrations, if we have a target, use that as our appID
218
+ // since that's where we're actually executing
219
+ if router .Target != nil {
220
+ ctx .appID = ptr .Of (router .GetTarget ())
221
+ } else {
222
+ ctx .appID = ptr .Of (router .GetSource ())
223
+ }
209
224
}
210
225
err = ctx .onExecutionStarted (es )
211
226
} else if ts := e .GetTaskScheduled (); ts != nil {
@@ -338,6 +353,15 @@ func (ctx *OrchestrationContext) internalCallSubOrchestrator(orchestratorName st
338
353
},
339
354
},
340
355
}
356
+ if ctx .appID != nil {
357
+ createSubOrchestrationAction .Router = & protos.TaskRouter {
358
+ Source : * ctx .appID ,
359
+ }
360
+
361
+ if options .targetAppID != nil {
362
+ createSubOrchestrationAction .Router .Target = options .targetAppID
363
+ }
364
+ }
341
365
ctx .pendingActions [createSubOrchestrationAction .Id ] = createSubOrchestrationAction
342
366
343
367
task := newTask (ctx )
@@ -758,6 +782,13 @@ func (ctx *OrchestrationContext) setCompleteInternal(
758
782
},
759
783
},
760
784
}
785
+
786
+ if ctx .appID != nil {
787
+ completedAction .Router = & protos.TaskRouter {
788
+ Source : * ctx .appID ,
789
+ }
790
+ }
791
+
761
792
ctx .pendingActions [sequenceNumber ] = completedAction
762
793
return nil
763
794
}
0 commit comments