18
shardContext historyi.ShardContext,
19
workflowConsistencyChecker api.WorkflowConsistencyChecker,
20
>
) (resp *historyservice.TerminateWorkflowExecutionResponse, retError error) {
api.go
21
>
namespaceEntry, err := api.GetActiveNamespace(shardContext, namespace.ID(req.GetNamespaceId()), req.TerminateRequest.WorkflowExecution.WorkflowId)
22
>
if err != nil {
23
return nil, err
24
}
25
>
namespaceID := namespaceEntry.ID()
api.go
26
>
27
>
request := req.TerminateRequest
28
>
parentExecution := req.ExternalWorkflowExecution
29
>
childWorkflowOnly := req.ChildWorkflowOnly
30
>
workflowID := request.WorkflowExecution.WorkflowId
31
>
runID := request.WorkflowExecution.RunId
32
>
firstExecutionRunID := request.FirstExecutionRunId
33
>
if len(request.FirstExecutionRunId) != 0 {
34
>
runID = ""
35
>
}
36
37
>
err = api.GetAndUpdateWorkflowWithNew(
api.go
38
>
ctx,
39
>
nil,
40
>
definition.NewWorkflowKey(
41
>
namespaceID.String(),
42
>
workflowID,
43
>
runID,
44
>
),
45
>
func(workflowLease api.WorkflowLease) (*api.UpdateWorkflowAction, error) {
46
>
mutableState := workflowLease.GetMutableState()
47
>
if !mutableState.IsWorkflowExecutionRunning() {
48
return nil, consts.ErrWorkflowCompleted
49
}