747
return historyEvent
748
})
749
>
workflowTaskCompleteToChildWorkflowInitial := NewHistoryEventEdge(workflowTaskComplete, childWorkflowInitial)
history_event_util.go
750
>
childWorkflowInitialToFail := NewHistoryEventEdge(childWorkflowInitial, childWorkflowInitialFail)
751
>
childWorkflowInitialToStart := NewHistoryEventEdge(childWorkflowInitial, childWorkflowStart)
752
>
childWorkflowStartToCancel := NewHistoryEventEdge(childWorkflowStart, childWorkflowCancel)
753
>
childWorkflowStartToFail := NewHistoryEventEdge(childWorkflowStart, childWorkflowFail)
754
>
childWorkflowStartToComplete := NewHistoryEventEdge(childWorkflowStart, childWorkflowComplete)
755
>
childWorkflowStartToTerminate := NewHistoryEventEdge(childWorkflowStart, childWorkflowTerminate)
756
>
childWorkflowStartToTimedOut := NewHistoryEventEdge(childWorkflowStart, childWorkflowTimedOut)
757
>
childWorkflowCancelToWorkflowTaskSchedule := NewHistoryEventEdge(childWorkflowCancel, workflowTaskSchedule)
758
>
childWorkflowCancelToWorkflowTaskSchedule.SetCondition(notPendingWorkflowTask)
759
>
childWorkflowFailToWorkflowTaskSchedule := NewHistoryEventEdge(childWorkflowFail, workflowTaskSchedule)
760
>
childWorkflowFailToWorkflowTaskSchedule.SetCondition(notPendingWorkflowTask)
761
>
childWorkflowCompleteToWorkflowTaskSchedule := NewHistoryEventEdge(childWorkflowComplete, workflowTaskSchedule)
762
>
childWorkflowCompleteToWorkflowTaskSchedule.SetCondition(notPendingWorkflowTask)
763
>
childWorkflowTerminateToWorkflowTaskSchedule := NewHistoryEventEdge(childWorkflowTerminate, workflowTaskSchedule)
764
>
childWorkflowTerminateToWorkflowTaskSchedule.SetCondition(notPendingWorkflowTask)
765
>
childWorkflowTimedOutToWorkflowTaskSchedule := NewHistoryEventEdge(childWorkflowTimedOut, workflowTaskSchedule)
766
>
childWorkflowTimedOutToWorkflowTaskSchedule.SetCondition(notPendingWorkflowTask)
767
>
childWorkflowInitialFailToWorkflowTaskSchedule := NewHistoryEventEdge(childWorkflowInitialFail, workflowTaskSchedule)
768
>
childWorkflowInitialFailToWorkflowTaskSchedule.SetCondition(notPendingWorkflowTask)
769
>
childWorkflowModel.AddEdge(workflowTaskCompleteToChildWorkflowInitial, childWorkflowInitialToFail, childWorkflowInitialToStart,
770
>
childWorkflowStartToCancel, childWorkflowStartToFail, childWorkflowStartToComplete, childWorkflowStartToTerminate,
771
>
childWorkflowStartToTimedOut, childWorkflowCancelToWorkflowTaskSchedule, childWorkflowFailToWorkflowTaskSchedule,
772
>
childWorkflowCompleteToWorkflowTaskSchedule, childWorkflowTerminateToWorkflowTaskSchedule, childWorkflowTimedOutToWorkflowTaskSchedule,
773
>
childWorkflowInitialFailToWorkflowTaskSchedule)
774
>
775
>
// Setup external workflow model
776
>
externalWorkflowModel := NewHistoryEventModel()
777
>
externalWorkflowSignal := NewHistoryEventVertex(enumspb.EVENT_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_INITIATED.String())
778
>
externalWorkflowSignal.SetDataFunc(func(input ...any) any {
780
>
lastGeneratedEvent := input[1].(*historypb.HistoryEvent)
781
>
eventID := lastGeneratedEvent.GetEventId() + 1
782
>
version := input[2].(int64)
783
>
historyEvent := getDefaultHistoryEvent(eventID, version)
784
>
historyEvent.EventType = enumspb.EVENT_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_INITIATED
785
>
historyEvent.Attributes = &historypb.HistoryEvent_SignalExternalWorkflowExecutionInitiatedEventAttributes{SignalExternalWorkflowExecutionInitiatedEventAttributes: &historypb.SignalExternalWorkflowExecutionInitiatedEventAttributes{
786
>
WorkflowTaskCompletedEventId: lastEvent.EventId,
787
>
Namespace: nsName.String(),
788
>
NamespaceId: nsID.String(),
789
>
WorkflowExecution: &commonpb.WorkflowExecution{
790
>
WorkflowId: externalWorkflowID,
791
>
RunId: uuid.NewString(),
792
>
},
793
>
SignalName: "signal",
794
>
ChildWorkflowOnly: false,
795
>
}}
796
>
return historyEvent
797
>
})
798
>
externalWorkflowSignalFailed := NewHistoryEventVertex(enumspb.EVENT_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED.String())
history_event_util.go
799
>
externalWorkflowSignalFailed.SetDataFunc(func(input ...any) any {
801
>
lastGeneratedEvent := input[1].(*historypb.HistoryEvent)
802
>
eventID := lastGeneratedEvent.GetEventId() + 1
803
>
version := input[2].(int64)
804
>
historyEvent := getDefaultHistoryEvent(eventID, version)
805
>
historyEvent.EventType = enumspb.EVENT_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED
806
>
historyEvent.Attributes = &historypb.HistoryEvent_SignalExternalWorkflowExecutionFailedEventAttributes{SignalExternalWorkflowExecutionFailedEventAttributes: &historypb.SignalExternalWorkflowExecutionFailedEventAttributes{
807
>
Cause: enumspb.SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_EXTERNAL_WORKFLOW_EXECUTION_NOT_FOUND,
808
>
WorkflowTaskCompletedEventId: lastEvent.GetSignalExternalWorkflowExecutionInitiatedEventAttributes().WorkflowTaskCompletedEventId,
809
>
Namespace: nsName.String(),
810
>
NamespaceId: nsID.String(),
811
>
WorkflowExecution: &commonpb.WorkflowExecution{
812
>
WorkflowId: lastEvent.GetSignalExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().WorkflowId,
813
>
RunId: lastEvent.GetSignalExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().RunId,
814
>
},
815
>
InitiatedEventId: lastEvent.EventId,
816
>
}}
817
>
return historyEvent
818
>
})
819
>
externalWorkflowSignaled := NewHistoryEventVertex(enumspb.EVENT_TYPE_EXTERNAL_WORKFLOW_EXECUTION_SIGNALED.String())
history_event_util.go
820
>
externalWorkflowSignaled.SetDataFunc(func(input ...any) any {
822
>
lastGeneratedEvent := input[1].(*historypb.HistoryEvent)
823
>
eventID := lastGeneratedEvent.GetEventId() + 1
824
>
version := input[2].(int64)
825
>
historyEvent := getDefaultHistoryEvent(eventID, version)
826
>
historyEvent.EventType = enumspb.EVENT_TYPE_EXTERNAL_WORKFLOW_EXECUTION_SIGNALED
827
>
historyEvent.Attributes = &historypb.HistoryEvent_ExternalWorkflowExecutionSignaledEventAttributes{ExternalWorkflowExecutionSignaledEventAttributes: &historypb.ExternalWorkflowExecutionSignaledEventAttributes{
828
>
InitiatedEventId: lastEvent.EventId,
829
>
Namespace: nsName.String(),
830
>
NamespaceId: nsID.String(),
831
>
WorkflowExecution: &commonpb.WorkflowExecution{
832
>
WorkflowId: lastEvent.GetSignalExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().WorkflowId,
833
>
RunId: lastEvent.GetSignalExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().RunId,
834
>
},
835
>
}}
836
>
return historyEvent
837
>
})
838
>
externalWorkflowCancel := NewHistoryEventVertex(enumspb.EVENT_TYPE_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_INITIATED.String())
history_event_util.go
839
>
externalWorkflowCancel.SetDataFunc(func(input ...any) any {
841
>
lastGeneratedEvent := input[1].(*historypb.HistoryEvent)
842
>
eventID := lastGeneratedEvent.GetEventId() + 1
843
>
version := input[2].(int64)
844
>
historyEvent := getDefaultHistoryEvent(eventID, version)
845
>
historyEvent.EventType = enumspb.EVENT_TYPE_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_INITIATED
846
>
historyEvent.Attributes = &historypb.HistoryEvent_RequestCancelExternalWorkflowExecutionInitiatedEventAttributes{
847
>
RequestCancelExternalWorkflowExecutionInitiatedEventAttributes: &historypb.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes{
848
>
WorkflowTaskCompletedEventId: lastEvent.EventId,
849
>
Namespace: nsName.String(),
850
>
NamespaceId: nsID.String(),
851
>
WorkflowExecution: &commonpb.WorkflowExecution{
852
>
WorkflowId: externalWorkflowID,
853
>
RunId: uuid.NewString(),
854
>
},
855
>
ChildWorkflowOnly: false,
856
>
}}
857
>
return historyEvent
858
>
})
859
>
externalWorkflowCancelFail := NewHistoryEventVertex(enumspb.EVENT_TYPE_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED.String())
history_event_util.go
860
>
externalWorkflowCancelFail.SetDataFunc(func(input ...any) any {
862
>
lastGeneratedEvent := input[1].(*historypb.HistoryEvent)
863
>
eventID := lastGeneratedEvent.GetEventId() + 1
864
>
version := input[2].(int64)
865
>
historyEvent := getDefaultHistoryEvent(eventID, version)
866
>
historyEvent.EventType = enumspb.EVENT_TYPE_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED
867
>
historyEvent.Attributes = &historypb.HistoryEvent_RequestCancelExternalWorkflowExecutionFailedEventAttributes{RequestCancelExternalWorkflowExecutionFailedEventAttributes: &historypb.RequestCancelExternalWorkflowExecutionFailedEventAttributes{
868
>
Cause: enumspb.CANCEL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_EXTERNAL_WORKFLOW_EXECUTION_NOT_FOUND,
869
>
WorkflowTaskCompletedEventId: lastEvent.GetRequestCancelExternalWorkflowExecutionInitiatedEventAttributes().WorkflowTaskCompletedEventId,
870
>
Namespace: nsName.String(),
871
>
NamespaceId: nsID.String(),
872
>
WorkflowExecution: &commonpb.WorkflowExecution{
873
>
WorkflowId: lastEvent.GetRequestCancelExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().WorkflowId,
874
>
RunId: lastEvent.GetRequestCancelExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().RunId,
875
>
},
876
>
InitiatedEventId: lastEvent.EventId,
877
>
}}
878
>
return historyEvent
879
>
})
880
>
externalWorkflowCanceled := NewHistoryEventVertex(enumspb.EVENT_TYPE_EXTERNAL_WORKFLOW_EXECUTION_CANCEL_REQUESTED.String())
history_event_util.go
881
>
externalWorkflowCanceled.SetDataFunc(func(input ...any) any {
883
>
lastGeneratedEvent := input[1].(*historypb.HistoryEvent)
884
>
eventID := lastGeneratedEvent.GetEventId() + 1
885
>
version := input[2].(int64)
886
>
historyEvent := getDefaultHistoryEvent(eventID, version)
887
>
historyEvent.EventType = enumspb.EVENT_TYPE_EXTERNAL_WORKFLOW_EXECUTION_CANCEL_REQUESTED
888
>
historyEvent.Attributes = &historypb.HistoryEvent_ExternalWorkflowExecutionCancelRequestedEventAttributes{ExternalWorkflowExecutionCancelRequestedEventAttributes: &historypb.ExternalWorkflowExecutionCancelRequestedEventAttributes{
889
>
InitiatedEventId: lastEvent.EventId,
890
>
Namespace: nsName.String(),
891
>
NamespaceId: nsID.String(),
892
>
WorkflowExecution: &commonpb.WorkflowExecution{
893
>
WorkflowId: lastEvent.GetRequestCancelExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().WorkflowId,
894
>
RunId: lastEvent.GetRequestCancelExternalWorkflowExecutionInitiatedEventAttributes().GetWorkflowExecution().RunId,
895
>
},
896
>
}}
897
>
return historyEvent
898
>
})
899
>
workflowTaskCompleteToExternalWorkflowSignal := NewHistoryEventEdge(workflowTaskComplete, externalWorkflowSignal)
history_event_util.go
900
>
workflowTaskCompleteToExternalWorkflowCancel := NewHistoryEventEdge(workflowTaskComplete, externalWorkflowCancel)
901
>
externalWorkflowSignalToFail := NewHistoryEventEdge(externalWorkflowSignal, externalWorkflowSignalFailed)
902
>
externalWorkflowSignalToSignaled := NewHistoryEventEdge(externalWorkflowSignal, externalWorkflowSignaled)
903
>
externalWorkflowCancelToFail := NewHistoryEventEdge(externalWorkflowCancel, externalWorkflowCancelFail)
904
>
externalWorkflowCancelToCanceled := NewHistoryEventEdge(externalWorkflowCancel, externalWorkflowCanceled)
905
>
externalWorkflowSignaledToWorkflowTaskSchedule := NewHistoryEventEdge(externalWorkflowSignaled, workflowTaskSchedule)
906
>
externalWorkflowSignaledToWorkflowTaskSchedule.SetCondition(notPendingWorkflowTask)
907
>
externalWorkflowSignalFailedToWorkflowTaskSchedule := NewHistoryEventEdge(externalWorkflowSignalFailed, workflowTaskSchedule)
908
>
externalWorkflowSignalFailedToWorkflowTaskSchedule.SetCondition(notPendingWorkflowTask)
909
>
externalWorkflowCanceledToWorkflowTaskSchedule := NewHistoryEventEdge(externalWorkflowCanceled, workflowTaskSchedule)
910
>
externalWorkflowCanceledToWorkflowTaskSchedule.SetCondition(notPendingWorkflowTask)
911
>
externalWorkflowCancelFailToWorkflowTaskSchedule := NewHistoryEventEdge(externalWorkflowCancelFail, workflowTaskSchedule)
912
>
externalWorkflowCancelFailToWorkflowTaskSchedule.SetCondition(notPendingWorkflowTask)
913
>
externalWorkflowModel.AddEdge(workflowTaskCompleteToExternalWorkflowSignal, workflowTaskCompleteToExternalWorkflowCancel,
914
>
externalWorkflowSignalToFail, externalWorkflowSignalToSignaled, externalWorkflowCancelToFail, externalWorkflowCancelToCanceled,
915
>
externalWorkflowSignaledToWorkflowTaskSchedule, externalWorkflowSignalFailedToWorkflowTaskSchedule,
916
>
externalWorkflowCanceledToWorkflowTaskSchedule, externalWorkflowCancelFailToWorkflowTaskSchedule)
917
>
918
>
// Config event generator
919
>
generator.SetBatchGenerationRule(canDoBatch)
920
>
generator.AddInitialEntryVertex(workflowStart)
921
>
generator.AddExitVertex(workflowComplete, workflowFail, workflowTerminate, workflowTimedOut, continueAsNew)
922
>
// generator.AddRandomEntryVertex(workflowSignal, workflowTerminate, workflowTimedOut)
923
>
generator.AddModel(historyEventModel)
924
>
generator.AddModel(workflowModel)
925
>
generator.AddModel(activityModel)
926
>
generator.AddModel(timerModel)
927
>
generator.AddModel(childWorkflowModel)
928
>
generator.AddModel(externalWorkflowModel)
929
>
return generator
930
}
931