func (wh *WorkflowHandler) TerminateWorkflowExecution(
	ctx context.Context,
	terminateRequest *types.TerminateWorkflowExecutionRequest,
) (retError error) {
	defer log.CapturePanic(wh.GetLogger(), &retError)

	scope, sw := wh.startRequestProfileWithDomain(ctx, metrics.FrontendTerminateWorkflowExecutionScope, terminateRequest)
	defer sw.Stop()

	if wh.isShuttingDown() {
		return errShuttingDown
	}

	if err := wh.versionChecker.ClientSupported(ctx, wh.config.EnableClientVersionCheck()); err != nil {
		return wh.error(err, scope)
	}

	if terminateRequest == nil {
		return wh.error(errRequestNotSet, scope)
	}

	domainName := terminateRequest.GetDomain()
	wfExecution := terminateRequest.GetWorkflowExecution()
	tags := getDomainWfIDRunIDTags(domainName, wfExecution)

	if terminateRequest.GetDomain() == "" {
		return wh.error(errDomainNotSet, scope, tags...)
	}

	if ok := wh.allow(true, terminateRequest); !ok {
		return wh.error(createServiceBusyError(), scope, tags...)
	}

	if err := validateExecution(wfExecution); err != nil {
		return wh.error(err, scope, tags...)
	}

	domainID, err := wh.GetDomainCache().GetDomainID(domainName)
	if err != nil {
		return wh.error(err, scope, tags...)
	}

	err = wh.GetHistoryClient().TerminateWorkflowExecution(ctx, &types.HistoryTerminateWorkflowExecutionRequest{
		DomainUUID:       domainID,
		TerminateRequest: terminateRequest,
	})
	if err != nil {
		return wh.normalizeVersionedErrors(ctx, wh.error(err, scope, tags...))
	}

	return nil
}
// TerminateWorkflowExecution terminates an existing workflow execution by recording WorkflowExecutionTerminated event
// in the history and immediately terminating the execution instance.
TerminateWorkflowExecution terminates an existing workflow execution by recording WorkflowExecutionTerminated event
in the history and immediately terminating the execution instance.
// TerminateWorkflowExecution terminates an existing workflow execution by recording WorkflowExecutionTerminated event // in the history and immediately terminating the execution instance .
func (wh *WorkflowHandler) TerminateWorkflowExecution(
	ctx context.Context,
	terminateRequest *types.TerminateWorkflowExecutionRequest,
) (retError error) {
	defer log.CapturePanic(wh.GetLogger(), &retError)
	scope, sw := wh.startRequestProfileWithDomain(ctx, metrics.FrontendTerminateWorkflowExecutionScope, terminateRequest)
	defer sw.Stop()
	if wh.isShuttingDown() {
		return errShuttingDown
	}
	if err := wh.versionChecker.ClientSupported(ctx, wh.config.EnableClientVersionCheck()); err != nil {
		return wh.error(err, scope)
	}
	if terminateRequest == nil {
		return wh.error(errRequestNotSet, scope)
	}
	domainName := terminateRequest.GetDomain()
	wfExecution := terminateRequest.GetWorkflowExecution()
	tags := getDomainWfIDRunIDTags(domainName, wfExecution)
	if terminateRequest.GetDomain() == "" {
		return wh.error(errDomainNotSet, scope, tags...)
	}
	if ok := wh.allow(true, terminateRequest); !ok {
		return wh.error(createServiceBusyError(), scope, tags...)
	}
	if err := validateExecution(wfExecution); err != nil {
		return wh.error(err, scope, tags...)
	}
	domainID, err := wh.GetDomainCache().GetDomainID(domainName)
	if err != nil {
		return wh.error(err, scope, tags...)
	}
	err = wh.GetHistoryClient().TerminateWorkflowExecution(ctx, &types.HistoryTerminateWorkflowExecutionRequest{
		DomainUUID:       domainID,
		TerminateRequest: terminateRequest,
	})
	if err != nil {
		return wh.normalizeVersionedErrors(ctx, wh.error(err, scope, tags...))
	}
	return nil
}
func ( wh * WorkflowHandler ) TerminateWorkflowExecution ( ctx context . Context , terminateRequest * types . TerminateWorkflowExecutionRequest , ) ( retError error ) { defer log . CapturePanic ( wh . GetLogger ( ) , & retError ) scope , sw := wh . startRequestProfileWithDomain ( ctx , metrics . FrontendTerminateWorkflowExecutionScope , terminateRequest ) defer sw . Stop ( ) if wh . isShuttingDown ( ) { return errShuttingDown } if err := wh . versionChecker . ClientSupported ( ctx , wh . config . EnableClientVersionCheck ( ) ) ; err != nil { return wh . error ( err , scope ) } if terminateRequest == nil { return wh . error ( errRequestNotSet , scope ) } domainName := terminateRequest . GetDomain ( ) wfExecution := terminateRequest . GetWorkflowExecution ( ) tags := getDomainWfIDRunIDTags ( domainName , wfExecution ) if terminateRequest . GetDomain ( ) == " " { return wh . error ( errDomainNotSet , scope , tags ... ) } if ok := wh . allow ( true , terminateRequest ) ; ! ok { return wh . error ( createServiceBusyError ( ) , scope , tags ... ) } if err := validateExecution ( wfExecution ) ; err != nil { return wh . error ( err , scope , tags ... ) } domainID , err := wh . GetDomainCache ( ) . GetDomainID ( domainName ) if err != nil { return wh . error ( err , scope , tags ... ) } err = wh . GetHistoryClient ( ) . TerminateWorkflowExecution ( ctx , & types . HistoryTerminateWorkflowExecutionRequest { DomainUUID : domainID , TerminateRequest : terminateRequest , } ) if err != nil { return wh . normalizeVersionedErrors ( ctx , wh . error ( err , scope , tags ... ) ) } return nil }
TerminateWorkflowExecution terminates an existing workflow execution by recording WorkflowExecutionTerminated event
in the history and immediately terminating the execution instance.
TerminateWorkflowExecution terminates an existing workflow execution by recording WorkflowExecutionTerminated event in the history and immediately terminating the execution instance .