Skip to content

Commit 7a35af6

Browse files
authored
Merge pull request #35 from acroca/improve-suborchestration-completion-routing
2 parents 00ff61e + 329acbf commit 7a35af6

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

backend/runtimestate/runtimestate.go

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -140,28 +140,16 @@ func ApplyActions(s *protos.OrchestrationRuntimeState, customStatus *wrapperspb.
140140
},
141141
Router: action.Router,
142142
})
143-
if s.StartEvent.GetParentInstance() != nil {
144-
// Create a router for the completion event that routes back to the parent
143+
if parentInstance := s.StartEvent.GetParentInstance(); parentInstance != nil {
145144
var completionRouter *protos.TaskRouter
146-
if action.Router != nil {
147-
var parentAppID *string
148-
149-
allEvents := append(s.OldEvents, s.NewEvents...)
150-
for _, event := range allEvents {
151-
if es := event.GetExecutionStarted(); es != nil && event.GetRouter() != nil {
152-
parentAppID = ptr.Of(event.GetRouter().GetSourceAppID())
153-
break
154-
}
155-
}
156145

157-
if parentAppID != nil {
158-
completionRouter = &protos.TaskRouter{
159-
SourceAppID: action.Router.SourceAppID,
160-
TargetAppID: parentAppID,
161-
}
162-
} else {
163-
completionRouter = action.Router
146+
if parentInstance.AppID != nil {
147+
completionRouter = &protos.TaskRouter{
148+
SourceAppID: action.Router.GetSourceAppID(),
149+
TargetAppID: ptr.Of(parentInstance.GetAppID()),
164150
}
151+
} else {
152+
completionRouter = action.Router
165153
}
166154

167155
msg := &protos.OrchestrationRuntimeStateMessage{
@@ -261,6 +249,7 @@ func ApplyActions(s *protos.OrchestrationRuntimeState, customStatus *wrapperspb.
261249
TaskScheduledId: action.Id,
262250
Name: wrapperspb.String(s.StartEvent.Name),
263251
OrchestrationInstance: &protos.OrchestrationInstance{InstanceId: string(s.InstanceId)},
252+
AppID: ptr.Of(action.Router.GetSourceAppID()),
264253
},
265254
Input: createSO.Input,
266255
OrchestrationInstance: &protos.OrchestrationInstance{

0 commit comments

Comments
 (0)