Skip to content

Commit

Permalink
Support memo and search attributes in child workflow (uber#2266)
Browse files Browse the repository at this point in the history
  • Loading branch information
vancexu authored Jul 24, 2019
1 parent 2626e2f commit b64466a
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 8 deletions.
180 changes: 174 additions & 6 deletions .gen/go/shared/shared.go

Large diffs are not rendered by default.

19 changes: 17 additions & 2 deletions host/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,19 @@ func (s *integrationSuite) TestChildWorkflowExecution() {
var startedEvent *workflow.HistoryEvent
var completedEvent *workflow.HistoryEvent

memoInfo, _ := json.Marshal("memo")
memo := &workflow.Memo{
Fields: map[string][]byte{
"Info": memoInfo,
},
}
attrValBytes, _ := json.Marshal("attrVal")
searchAttr := &workflow.SearchAttributes{
IndexedFields: map[string][]byte{
"CustomKeywordField": attrValBytes,
},
}

// Parent Decider Logic
dtHandlerParent := func(execution *workflow.WorkflowExecution, wt *workflow.WorkflowType,
previousStartedEventID, startedEventID int64, history *workflow.History) ([]byte, []*workflow.Decision, error) {
Expand All @@ -1655,6 +1668,8 @@ func (s *integrationSuite) TestChildWorkflowExecution() {
TaskStartToCloseTimeoutSeconds: common.Int32Ptr(2),
ChildPolicy: common.ChildPolicyPtr(workflow.ChildPolicyRequestCancel),
Control: nil,
Memo: memo,
SearchAttributes: searchAttr,
},
}}, nil
} else if previousStartedEventID > 0 {
Expand Down Expand Up @@ -1746,6 +1761,8 @@ func (s *integrationSuite) TestChildWorkflowExecution() {
s.Equal(workflow.ChildPolicyRequestCancel, childStartedEvent.WorkflowExecutionStartedEventAttributes.GetChildPolicy())
s.Equal(header, startedEvent.ChildWorkflowExecutionStartedEventAttributes.Header)
s.Equal(header, childStartedEvent.WorkflowExecutionStartedEventAttributes.Header)
s.Equal(memo, childStartedEvent.WorkflowExecutionStartedEventAttributes.GetMemo())
s.Equal(searchAttr, childStartedEvent.WorkflowExecutionStartedEventAttributes.GetSearchAttributes())

// Process ChildExecution completed event and complete parent execution
_, err = pollerParent.PollAndProcessDecisionTask(false, false)
Expand All @@ -1757,8 +1774,6 @@ func (s *integrationSuite) TestChildWorkflowExecution() {
s.Equal(childID, *completedAttributes.WorkflowExecution.WorkflowId)
s.Equal(wtChild, *completedAttributes.WorkflowType.Name)
s.Equal([]byte("Child Done."), completedAttributes.Result)

s.Logger.Info("Parent Workflow Execution History: ")
}

func (s *integrationSuite) TestCronChildWorkflowExecution() {
Expand Down
4 changes: 4 additions & 0 deletions idl/github.com/uber/cadence/shared.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ struct StartChildWorkflowExecutionDecisionAttributes {
110: optional RetryPolicy retryPolicy
120: optional string cronSchedule
130: optional Header header
140: optional Memo memo
150: optional SearchAttributes searchAttributes
}

struct Decision {
Expand Down Expand Up @@ -764,6 +766,8 @@ struct StartChildWorkflowExecutionInitiatedEventAttributes {
120: optional RetryPolicy retryPolicy
130: optional string cronSchedule
140: optional Header header
150: optional Memo memo
160: optional SearchAttributes searchAttributes
}

struct StartChildWorkflowExecutionFailedEventAttributes {
Expand Down
2 changes: 2 additions & 0 deletions service/history/historyBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,8 @@ func (b *historyBuilder) newStartChildWorkflowExecutionInitiatedEvent(decisionTa
attributes.WorkflowIdReusePolicy = startAttributes.WorkflowIdReusePolicy
attributes.RetryPolicy = startAttributes.RetryPolicy
attributes.CronSchedule = startAttributes.CronSchedule
attributes.Memo = startAttributes.Memo
attributes.SearchAttributes = startAttributes.SearchAttributes
historyEvent.StartChildWorkflowExecutionInitiatedEventAttributes = attributes

return historyEvent
Expand Down
2 changes: 2 additions & 0 deletions service/history/transferQueueActiveProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,8 @@ func (t *transferQueueActiveProcessorImpl) processStartChildExecution(
ChildPolicy: attributes.ChildPolicy,
RetryPolicy: attributes.RetryPolicy,
CronSchedule: attributes.CronSchedule,
Memo: attributes.Memo,
SearchAttributes: attributes.SearchAttributes,
},
ParentExecutionInfo: &h.ParentExecutionInfo{
DomainUUID: common.StringPtr(domainID),
Expand Down

0 comments on commit b64466a

Please sign in to comment.