func (wh *WorkflowHandler) QueryWorkflow(
	ctx context.Context,
	queryRequest *types.QueryWorkflowRequest,
) (resp *types.QueryWorkflowResponse, retError error) {
	defer log.CapturePanic(wh.GetLogger(), &retError)

	scope, sw := wh.startRequestProfileWithDomain(ctx, metrics.FrontendQueryWorkflowScope, queryRequest)
	defer sw.Stop()

	if wh.isShuttingDown() {
		return nil, errShuttingDown
	}

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

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

	domainName := queryRequest.GetDomain()
	wfExecution := queryRequest.GetExecution()
	tags := getDomainWfIDRunIDTags(domainName, wfExecution)

	if domainName == "" {
		return nil, wh.error(errDomainNotSet, scope, tags...)
	}

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

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

	if wh.config.DisallowQuery(domainName) {
		return nil, wh.error(errQueryDisallowedForDomain, scope, tags...)
	}

	if queryRequest.Query == nil {
		return nil, wh.error(errQueryNotSet, scope, tags...)
	}

	if queryRequest.Query.GetQueryType() == "" {
		return nil, wh.error(errQueryTypeNotSet, scope, tags...)
	}

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

	sizeLimitError := wh.config.BlobSizeLimitError(domainName)
	sizeLimitWarn := wh.config.BlobSizeLimitWarn(domainName)

	if err := common.CheckEventBlobSizeLimit(
		len(queryRequest.GetQuery().GetQueryArgs()),
		sizeLimitWarn,
		sizeLimitError,
		domainID,
		queryRequest.GetExecution().GetWorkflowID(),
		queryRequest.GetExecution().GetRunID(),
		scope,
		wh.GetThrottledLogger(),
		tag.BlobSizeViolationOperation("QueryWorkflow")); err != nil {
		return nil, wh.error(err, scope, tags...)
	}

	req := &types.HistoryQueryWorkflowRequest{
		DomainUUID: domainID,
		Request:    queryRequest,
	}
	hResponse, err := wh.GetHistoryClient().QueryWorkflow(ctx, req)
	if err != nil {
		return nil, wh.error(err, scope, tags...)
	}
	return hResponse.GetResponse(), nil
}
// QueryWorkflow returns query result for a specified workflow execution
QueryWorkflow returns query result for a specified workflow execution
// QueryWorkflow returns query result for a specified workflow execution
func (wh *WorkflowHandler) QueryWorkflow(
	ctx context.Context,
	queryRequest *types.QueryWorkflowRequest,
) (resp *types.QueryWorkflowResponse, retError error) {
	defer log.CapturePanic(wh.GetLogger(), &retError)
	scope, sw := wh.startRequestProfileWithDomain(ctx, metrics.FrontendQueryWorkflowScope, queryRequest)
	defer sw.Stop()
	if wh.isShuttingDown() {
		return nil, errShuttingDown
	}
	if err := wh.versionChecker.ClientSupported(ctx, wh.config.EnableClientVersionCheck()); err != nil {
		return nil, wh.error(err, scope)
	}
	if queryRequest == nil {
		return nil, wh.error(errRequestNotSet, scope)
	}
	domainName := queryRequest.GetDomain()
	wfExecution := queryRequest.GetExecution()
	tags := getDomainWfIDRunIDTags(domainName, wfExecution)
	if domainName == "" {
		return nil, wh.error(errDomainNotSet, scope, tags...)
	}
	if ok := wh.allow(true, queryRequest); !ok {
		return nil, wh.error(createServiceBusyError(), scope, tags...)
	}
	if err := validateExecution(wfExecution); err != nil {
		return nil, wh.error(err, scope, tags...)
	}
	if wh.config.DisallowQuery(domainName) {
		return nil, wh.error(errQueryDisallowedForDomain, scope, tags...)
	}
	if queryRequest.Query == nil {
		return nil, wh.error(errQueryNotSet, scope, tags...)
	}
	if queryRequest.Query.GetQueryType() == "" {
		return nil, wh.error(errQueryTypeNotSet, scope, tags...)
	}
	domainID, err := wh.GetDomainCache().GetDomainID(domainName)
	if err != nil {
		return nil, wh.error(err, scope, tags...)
	}
	sizeLimitError := wh.config.BlobSizeLimitError(domainName)
	sizeLimitWarn := wh.config.BlobSizeLimitWarn(domainName)
	if err := common.CheckEventBlobSizeLimit(
		len(queryRequest.GetQuery().GetQueryArgs()),
		sizeLimitWarn,
		sizeLimitError,
		domainID,
		queryRequest.GetExecution().GetWorkflowID(),
		queryRequest.GetExecution().GetRunID(),
		scope,
		wh.GetThrottledLogger(),
		tag.BlobSizeViolationOperation("QueryWorkflow")); err != nil {
		return nil, wh.error(err, scope, tags...)
	}
	req := &types.HistoryQueryWorkflowRequest{
		DomainUUID: domainID,
		Request:    queryRequest,
	}
	hResponse, err := wh.GetHistoryClient().QueryWorkflow(ctx, req)
	if err != nil {
		return nil, wh.error(err, scope, tags...)
	}
	return hResponse.GetResponse(), nil
}
func ( wh * WorkflowHandler ) QueryWorkflow ( ctx context . Context , queryRequest * types . QueryWorkflowRequest , ) ( resp * types . QueryWorkflowResponse , retError error ) { defer log . CapturePanic ( wh . GetLogger ( ) , & retError ) scope , sw := wh . startRequestProfileWithDomain ( ctx , metrics . FrontendQueryWorkflowScope , queryRequest ) defer sw . Stop ( ) if wh . isShuttingDown ( ) { return nil , errShuttingDown } if err := wh . versionChecker . ClientSupported ( ctx , wh . config . EnableClientVersionCheck ( ) ) ; err != nil { return nil , wh . error ( err , scope ) } if queryRequest == nil { return nil , wh . error ( errRequestNotSet , scope ) } domainName := queryRequest . GetDomain ( ) wfExecution := queryRequest . GetExecution ( ) tags := getDomainWfIDRunIDTags ( domainName , wfExecution ) if domainName == " " { return nil , wh . error ( errDomainNotSet , scope , tags ... ) } if ok := wh . allow ( true , queryRequest ) ; ! ok { return nil , wh . error ( createServiceBusyError ( ) , scope , tags ... ) } if err := validateExecution ( wfExecution ) ; err != nil { return nil , wh . error ( err , scope , tags ... ) } if wh . config . DisallowQuery ( domainName ) { return nil , wh . error ( errQueryDisallowedForDomain , scope , tags ... ) } if queryRequest . Query == nil { return nil , wh . error ( errQueryNotSet , scope , tags ... ) } if queryRequest . Query . GetQueryType ( ) == " " { return nil , wh . error ( errQueryTypeNotSet , scope , tags ... ) } domainID , err := wh . GetDomainCache ( ) . GetDomainID ( domainName ) if err != nil { return nil , wh . error ( err , scope , tags ... ) } sizeLimitError := wh . config . BlobSizeLimitError ( domainName ) sizeLimitWarn := wh . config . BlobSizeLimitWarn ( domainName ) if err := common . CheckEventBlobSizeLimit ( len ( queryRequest . GetQuery ( ) . GetQueryArgs ( ) ) , sizeLimitWarn , sizeLimitError , domainID , queryRequest . GetExecution ( ) . GetWorkflowID ( ) , queryRequest . GetExecution ( ) . GetRunID ( ) , scope , wh . GetThrottledLogger ( ) , tag . BlobSizeViolationOperation ( " " ) ) ; err != nil { return nil , wh . error ( err , scope , tags ... ) } req := & types . HistoryQueryWorkflowRequest { DomainUUID : domainID , Request : queryRequest , } hResponse , err := wh . GetHistoryClient ( ) . QueryWorkflow ( ctx , req ) if err != nil { return nil , wh . error ( err , scope , tags ... ) } return hResponse . GetResponse ( ) , nil }
QueryWorkflow returns query result for a specified workflow execution
QueryWorkflow returns query result for a specified workflow execution