func (wh *WorkflowHandler) ListOpenWorkflowExecutions(
	ctx context.Context,
	listRequest *types.ListOpenWorkflowExecutionsRequest,
) (resp *types.ListOpenWorkflowExecutionsResponse, retError error) {
	defer log.CapturePanic(wh.GetLogger(), &retError)

	scope, sw := wh.startRequestProfileWithDomain(ctx, metrics.FrontendListOpenWorkflowExecutionsScope, listRequest)
	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 listRequest == nil {
		return nil, wh.error(errRequestNotSet, scope)
	}

	if listRequest.GetDomain() == "" {
		return nil, wh.error(errDomainNotSet, scope)
	}

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

	if listRequest.StartTimeFilter == nil {
		return nil, wh.error(&types.BadRequestError{Message: "StartTimeFilter is required"}, scope)
	}

	if listRequest.StartTimeFilter.EarliestTime == nil {
		return nil, wh.error(&types.BadRequestError{Message: "EarliestTime in StartTimeFilter is required"}, scope)
	}

	if listRequest.StartTimeFilter.LatestTime == nil {
		return nil, wh.error(&types.BadRequestError{Message: "LatestTime in StartTimeFilter is required"}, scope)
	}

	if listRequest.StartTimeFilter.GetEarliestTime() > listRequest.StartTimeFilter.GetLatestTime() {
		return nil, wh.error(&types.BadRequestError{Message: "EarliestTime in StartTimeFilter should not be larger than LatestTime"}, scope)
	}

	if listRequest.ExecutionFilter != nil && listRequest.TypeFilter != nil {
		return nil, wh.error(&types.BadRequestError{
			Message: "Only one of ExecutionFilter or TypeFilter is allowed"}, scope)
	}

	if listRequest.GetMaximumPageSize() <= 0 {
		listRequest.MaximumPageSize = int32(wh.config.VisibilityMaxPageSize(listRequest.GetDomain()))
	}

	if wh.isListRequestPageSizeTooLarge(listRequest.GetMaximumPageSize(), listRequest.GetDomain()) {
		return nil, wh.error(&types.BadRequestError{
			Message: fmt.Sprintf("Pagesize is larger than allow %d", wh.config.ESIndexMaxResultWindow())}, scope)
	}

	domain := listRequest.GetDomain()
	domainID, err := wh.GetDomainCache().GetDomainID(domain)
	if err != nil {
		return nil, wh.error(err, scope)
	}

	baseReq := persistence.ListWorkflowExecutionsRequest{
		DomainUUID:    domainID,
		Domain:        domain,
		PageSize:      int(listRequest.GetMaximumPageSize()),
		NextPageToken: listRequest.NextPageToken,
		EarliestTime:  listRequest.StartTimeFilter.GetEarliestTime(),
		LatestTime:    listRequest.StartTimeFilter.GetLatestTime(),
	}

	var persistenceResp *persistence.ListWorkflowExecutionsResponse
	if listRequest.ExecutionFilter != nil {
		if wh.config.DisableListVisibilityByFilter(domain) {
			err = errNoPermission
		} else {
			persistenceResp, err = wh.GetVisibilityManager().ListOpenWorkflowExecutionsByWorkflowID(
				ctx,
				&persistence.ListWorkflowExecutionsByWorkflowIDRequest{
					ListWorkflowExecutionsRequest: baseReq,
					WorkflowID:                    listRequest.ExecutionFilter.GetWorkflowID(),
				})
		}
		wh.GetLogger().Debug("List open workflow with filter",
			tag.WorkflowDomainName(listRequest.GetDomain()), tag.WorkflowListWorkflowFilterByID)
	} else if listRequest.TypeFilter != nil {
		if wh.config.DisableListVisibilityByFilter(domain) {
			err = errNoPermission
		} else {
			persistenceResp, err = wh.GetVisibilityManager().ListOpenWorkflowExecutionsByType(
				ctx,
				&persistence.ListWorkflowExecutionsByTypeRequest{
					ListWorkflowExecutionsRequest: baseReq,
					WorkflowTypeName:              listRequest.TypeFilter.GetName(),
				},
			)
		}
		wh.GetLogger().Debug("List open workflow with filter",
			tag.WorkflowDomainName(listRequest.GetDomain()), tag.WorkflowListWorkflowFilterByType)
	} else {
		persistenceResp, err = wh.GetVisibilityManager().ListOpenWorkflowExecutions(ctx, &baseReq)
	}

	if err != nil {
		return nil, wh.error(err, scope)
	}

	resp = &types.ListOpenWorkflowExecutionsResponse{}
	resp.Executions = persistenceResp.Executions
	resp.NextPageToken = persistenceResp.NextPageToken
	return resp, nil
}
// ListOpenWorkflowExecutions - retrieves info for open workflow executions in a domain
retrieves info for open workflow executions in a domain
// ListOpenWorkflowExecutions - retrieves info for open workflow executions in a domain
func (wh *WorkflowHandler) ListOpenWorkflowExecutions(
	ctx context.Context,
	listRequest *types.ListOpenWorkflowExecutionsRequest,
) (resp *types.ListOpenWorkflowExecutionsResponse, retError error) {
	defer log.CapturePanic(wh.GetLogger(), &retError)
	scope, sw := wh.startRequestProfileWithDomain(ctx, metrics.FrontendListOpenWorkflowExecutionsScope, listRequest)
	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 listRequest == nil {
		return nil, wh.error(errRequestNotSet, scope)
	}
	if listRequest.GetDomain() == "" {
		return nil, wh.error(errDomainNotSet, scope)
	}
	if ok := wh.allow(true, listRequest); !ok {
		return nil, wh.error(createServiceBusyError(), scope)
	}
	if listRequest.StartTimeFilter == nil {
		return nil, wh.error(&types.BadRequestError{Message: "StartTimeFilter is required"}, scope)
	}
	if listRequest.StartTimeFilter.EarliestTime == nil {
		return nil, wh.error(&types.BadRequestError{Message: "EarliestTime in StartTimeFilter is required"}, scope)
	}
	if listRequest.StartTimeFilter.LatestTime == nil {
		return nil, wh.error(&types.BadRequestError{Message: "LatestTime in StartTimeFilter is required"}, scope)
	}
	if listRequest.StartTimeFilter.GetEarliestTime() > listRequest.StartTimeFilter.GetLatestTime() {
		return nil, wh.error(&types.BadRequestError{Message: "EarliestTime in StartTimeFilter should not be larger than LatestTime"}, scope)
	}
	if listRequest.ExecutionFilter != nil && listRequest.TypeFilter != nil {
		return nil, wh.error(&types.BadRequestError{
			Message: "Only one of ExecutionFilter or TypeFilter is allowed"}, scope)
	}
	if listRequest.GetMaximumPageSize() <= 0 {
		listRequest.MaximumPageSize = int32(wh.config.VisibilityMaxPageSize(listRequest.GetDomain()))
	}
	if wh.isListRequestPageSizeTooLarge(listRequest.GetMaximumPageSize(), listRequest.GetDomain()) {
		return nil, wh.error(&types.BadRequestError{
			Message: fmt.Sprintf("Pagesize is larger than allow %d", wh.config.ESIndexMaxResultWindow())}, scope)
	}
	domain := listRequest.GetDomain()
	domainID, err := wh.GetDomainCache().GetDomainID(domain)
	if err != nil {
		return nil, wh.error(err, scope)
	}
	baseReq := persistence.ListWorkflowExecutionsRequest{
		DomainUUID:    domainID,
		Domain:        domain,
		PageSize:      int(listRequest.GetMaximumPageSize()),
		NextPageToken: listRequest.NextPageToken,
		EarliestTime:  listRequest.StartTimeFilter.GetEarliestTime(),
		LatestTime:    listRequest.StartTimeFilter.GetLatestTime(),
	}
	var persistenceResp *persistence.ListWorkflowExecutionsResponse
	if listRequest.ExecutionFilter != nil {
		if wh.config.DisableListVisibilityByFilter(domain) {
			err = errNoPermission
		} else {
			persistenceResp, err = wh.GetVisibilityManager().ListOpenWorkflowExecutionsByWorkflowID(
				ctx,
				&persistence.ListWorkflowExecutionsByWorkflowIDRequest{
					ListWorkflowExecutionsRequest: baseReq,
					WorkflowID:                    listRequest.ExecutionFilter.GetWorkflowID(),
				})
		}
		wh.GetLogger().Debug("List open workflow with filter",
			tag.WorkflowDomainName(listRequest.GetDomain()), tag.WorkflowListWorkflowFilterByID)
	} else if listRequest.TypeFilter != nil {
		if wh.config.DisableListVisibilityByFilter(domain) {
			err = errNoPermission
		} else {
			persistenceResp, err = wh.GetVisibilityManager().ListOpenWorkflowExecutionsByType(
				ctx,
				&persistence.ListWorkflowExecutionsByTypeRequest{
					ListWorkflowExecutionsRequest: baseReq,
					WorkflowTypeName:              listRequest.TypeFilter.GetName(),
				},
			)
		}
		wh.GetLogger().Debug("List open workflow with filter",
			tag.WorkflowDomainName(listRequest.GetDomain()), tag.WorkflowListWorkflowFilterByType)
	} else {
		persistenceResp, err = wh.GetVisibilityManager().ListOpenWorkflowExecutions(ctx, &baseReq)
	}
	if err != nil {
		return nil, wh.error(err, scope)
	}
	resp = &types.ListOpenWorkflowExecutionsResponse{}
	resp.Executions = persistenceResp.Executions
	resp.NextPageToken = persistenceResp.NextPageToken
	return resp, nil
}
func ( wh * WorkflowHandler ) ListOpenWorkflowExecutions ( ctx context . Context , listRequest * types . ListOpenWorkflowExecutionsRequest , ) ( resp * types . ListOpenWorkflowExecutionsResponse , retError error ) { defer log . CapturePanic ( wh . GetLogger ( ) , & retError ) scope , sw := wh . startRequestProfileWithDomain ( ctx , metrics . FrontendListOpenWorkflowExecutionsScope , listRequest ) 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 listRequest == nil { return nil , wh . error ( errRequestNotSet , scope ) } if listRequest . GetDomain ( ) == " " { return nil , wh . error ( errDomainNotSet , scope ) } if ok := wh . allow ( true , listRequest ) ; ! ok { return nil , wh . error ( createServiceBusyError ( ) , scope ) } if listRequest . StartTimeFilter == nil { return nil , wh . error ( & types . BadRequestError { Message : " " } , scope ) } if listRequest . StartTimeFilter . EarliestTime == nil { return nil , wh . error ( & types . BadRequestError { Message : " " } , scope ) } if listRequest . StartTimeFilter . LatestTime == nil { return nil , wh . error ( & types . BadRequestError { Message : " " } , scope ) } if listRequest . StartTimeFilter . GetEarliestTime ( ) > listRequest . StartTimeFilter . GetLatestTime ( ) { return nil , wh . error ( & types . BadRequestError { Message : " " } , scope ) } if listRequest . ExecutionFilter != nil && listRequest . TypeFilter != nil { return nil , wh . error ( & types . BadRequestError { Message : " " } , scope ) } if listRequest . GetMaximumPageSize ( ) <= 0 { listRequest . MaximumPageSize = int32 ( wh . config . VisibilityMaxPageSize ( listRequest . GetDomain ( ) ) ) } if wh . isListRequestPageSizeTooLarge ( listRequest . GetMaximumPageSize ( ) , listRequest . GetDomain ( ) ) { return nil , wh . error ( & types . BadRequestError { Message : fmt . Sprintf ( " " , wh . config . ESIndexMaxResultWindow ( ) ) } , scope ) } domain := listRequest . GetDomain ( ) domainID , err := wh . GetDomainCache ( ) . GetDomainID ( domain ) if err != nil { return nil , wh . error ( err , scope ) } baseReq := persistence . ListWorkflowExecutionsRequest { DomainUUID : domainID , Domain : domain , PageSize : int ( listRequest . GetMaximumPageSize ( ) ) , NextPageToken : listRequest . NextPageToken , EarliestTime : listRequest . StartTimeFilter . GetEarliestTime ( ) , LatestTime : listRequest . StartTimeFilter . GetLatestTime ( ) , } var persistenceResp * persistence . ListWorkflowExecutionsResponse if listRequest . ExecutionFilter != nil { if wh . config . DisableListVisibilityByFilter ( domain ) { err = errNoPermission } else { persistenceResp , err = wh . GetVisibilityManager ( ) . ListOpenWorkflowExecutionsByWorkflowID ( ctx , & persistence . ListWorkflowExecutionsByWorkflowIDRequest { ListWorkflowExecutionsRequest : baseReq , WorkflowID : listRequest . ExecutionFilter . GetWorkflowID ( ) , } ) } wh . GetLogger ( ) . Debug ( " " , tag . WorkflowDomainName ( listRequest . GetDomain ( ) ) , tag . WorkflowListWorkflowFilterByID ) } else if listRequest . TypeFilter != nil { if wh . config . DisableListVisibilityByFilter ( domain ) { err = errNoPermission } else { persistenceResp , err = wh . GetVisibilityManager ( ) . ListOpenWorkflowExecutionsByType ( ctx , & persistence . ListWorkflowExecutionsByTypeRequest { ListWorkflowExecutionsRequest : baseReq , WorkflowTypeName : listRequest . TypeFilter . GetName ( ) , } , ) } wh . GetLogger ( ) . Debug ( " " , tag . WorkflowDomainName ( listRequest . GetDomain ( ) ) , tag . WorkflowListWorkflowFilterByType ) } else { persistenceResp , err = wh . GetVisibilityManager ( ) . ListOpenWorkflowExecutions ( ctx , & baseReq ) } if err != nil { return nil , wh . error ( err , scope ) } resp = & types . ListOpenWorkflowExecutionsResponse { } resp . Executions = persistenceResp . Executions resp . NextPageToken = persistenceResp . NextPageToken return resp , nil }
retrieves info for open workflow executions in a domain
retrieves info for open workflow executions in a domain