264
targetWorkflow Workflow,
265
targetWorkflowEventsSlice ...*persistence.WorkflowEvents,
267
>
268
>
isCurrentWorkflow, err := r.isWorkflowCurrent(ctx, chasm.WorkflowArchetypeID, targetWorkflow)
269
>
if err != nil {
270
return 0, historyi.TransactionPolicyActive, err
271
}
272
>
isWorkflowRunning := targetWorkflow.GetMutableState().IsWorkflowExecutionRunning()
transaction_manager.go
273
>
targetWorkflowActiveCluster := targetWorkflow.GetMutableState().GetNamespaceEntry().ActiveClusterName(namespace.RoutingKey{ID: targetWorkflow.GetMutableState().GetExecutionInfo().WorkflowId})
274
>
currentCluster := r.clusterMetadata.GetCurrentClusterName()
275
>
isActiveCluster := targetWorkflowActiveCluster == currentCluster
276
>
277
>
// workflow events reapplication
278
>
// we need to handle 3 cases
279
>
// 1. target workflow is self & self being current & active
280
>
// a. workflow still running -> just reapply
281
>
// b. workflow closed -> reset current workflow & reapply
282
>
// 2. anything not case 1 -> find the current & active workflow to reapply
283
>
284
>
// case 1
285
>
if isCurrentWorkflow && isActiveCluster {
286
var totalEvents []*historypb.HistoryEvent
287
for _, events := range targetWorkflowEventsSlice {