func (wh *WorkflowHandler) ListArchivedWorkflowExecutions(
	ctx context.Context,
	listRequest *types.ListArchivedWorkflowExecutionsRequest,
) (resp *types.ListArchivedWorkflowExecutionsResponse, retError error) {
	defer log.CapturePanic(wh.GetLogger(), &retError)

	scope, sw := wh.startRequestProfileWithDomain(ctx, metrics.FrontendListArchivedWorkflowExecutionsScope, 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.GetPageSize() <= 0 {
		listRequest.PageSize = int32(wh.config.VisibilityMaxPageSize(listRequest.GetDomain()))
	}

	maxPageSize := wh.config.VisibilityArchivalQueryMaxPageSize()
	if int(listRequest.GetPageSize()) > maxPageSize {
		return nil, wh.error(&types.BadRequestError{
			Message: fmt.Sprintf("Pagesize is larger than allowed %d", maxPageSize)}, scope)
	}

	if !wh.GetArchivalMetadata().GetVisibilityConfig().ClusterConfiguredForArchival() {
		return nil, wh.error(&types.BadRequestError{Message: "Cluster is not configured for visibility archival"}, scope)
	}

	if !wh.GetArchivalMetadata().GetVisibilityConfig().ReadEnabled() {
		return nil, wh.error(&types.BadRequestError{Message: "Cluster is not configured for reading archived visibility records"}, scope)
	}

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

	if entry.GetConfig().VisibilityArchivalStatus != types.ArchivalStatusEnabled {
		return nil, wh.error(&types.BadRequestError{Message: "Domain is not configured for visibility archival"}, scope)
	}

	URI, err := archiver.NewURI(entry.GetConfig().VisibilityArchivalURI)
	if err != nil {
		return nil, wh.error(err, scope)
	}

	visibilityArchiver, err := wh.GetArchiverProvider().GetVisibilityArchiver(URI.Scheme(), service.Frontend)
	if err != nil {
		return nil, wh.error(err, scope)
	}

	archiverRequest := &archiver.QueryVisibilityRequest{
		DomainID:      entry.GetInfo().ID,
		PageSize:      int(listRequest.GetPageSize()),
		NextPageToken: listRequest.NextPageToken,
		Query:         listRequest.GetQuery(),
	}

	archiverResponse, err := visibilityArchiver.Query(ctx, URI, archiverRequest)
	if err != nil {
		return nil, wh.error(err, scope)
	}

	// special handling of ExecutionTime for cron or retry
	for _, execution := range archiverResponse.Executions {
		if execution.GetExecutionTime() == 0 {
			execution.ExecutionTime = common.Int64Ptr(execution.GetStartTime())
		}
	}

	return &types.ListArchivedWorkflowExecutionsResponse{
		Executions:    archiverResponse.Executions,
		NextPageToken: archiverResponse.NextPageToken,
	}, nil
}
// ListArchivedWorkflowExecutions - retrieves archived info for closed workflow executions in a domain
retrieves archived info for closed workflow executions in a domain
// ListArchivedWorkflowExecutions - retrieves archived info for closed workflow executions in a domain
func (wh *WorkflowHandler) ListArchivedWorkflowExecutions(
	ctx context.Context,
	listRequest *types.ListArchivedWorkflowExecutionsRequest,
) (resp *types.ListArchivedWorkflowExecutionsResponse, retError error) {
	defer log.CapturePanic(wh.GetLogger(), &retError)
	scope, sw := wh.startRequestProfileWithDomain(ctx, metrics.FrontendListArchivedWorkflowExecutionsScope, 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.GetPageSize() <= 0 {
		listRequest.PageSize = int32(wh.config.VisibilityMaxPageSize(listRequest.GetDomain()))
	}
	maxPageSize := wh.config.VisibilityArchivalQueryMaxPageSize()
	if int(listRequest.GetPageSize()) > maxPageSize {
		return nil, wh.error(&types.BadRequestError{
			Message: fmt.Sprintf("Pagesize is larger than allowed %d", maxPageSize)}, scope)
	}
	if !wh.GetArchivalMetadata().GetVisibilityConfig().ClusterConfiguredForArchival() {
		return nil, wh.error(&types.BadRequestError{Message: "Cluster is not configured for visibility archival"}, scope)
	}
	if !wh.GetArchivalMetadata().GetVisibilityConfig().ReadEnabled() {
		return nil, wh.error(&types.BadRequestError{Message: "Cluster is not configured for reading archived visibility records"}, scope)
	}
	entry, err := wh.GetDomainCache().GetDomain(listRequest.GetDomain())
	if err != nil {
		return nil, wh.error(err, scope)
	}
	if entry.GetConfig().VisibilityArchivalStatus != types.ArchivalStatusEnabled {
		return nil, wh.error(&types.BadRequestError{Message: "Domain is not configured for visibility archival"}, scope)
	}
	URI, err := archiver.NewURI(entry.GetConfig().VisibilityArchivalURI)
	if err != nil {
		return nil, wh.error(err, scope)
	}
	visibilityArchiver, err := wh.GetArchiverProvider().GetVisibilityArchiver(URI.Scheme(), service.Frontend)
	if err != nil {
		return nil, wh.error(err, scope)
	}
	archiverRequest := &archiver.QueryVisibilityRequest{
		DomainID:      entry.GetInfo().ID,
		PageSize:      int(listRequest.GetPageSize()),
		NextPageToken: listRequest.NextPageToken,
		Query:         listRequest.GetQuery(),
	}
	archiverResponse, err := visibilityArchiver.Query(ctx, URI, archiverRequest)
	if err != nil {
		return nil, wh.error(err, scope)
	}
	for _, execution := range archiverResponse.Executions {
		if execution.GetExecutionTime() == 0 {
			execution.ExecutionTime = common.Int64Ptr(execution.GetStartTime())
		}
	}
	return &types.ListArchivedWorkflowExecutionsResponse{
		Executions:    archiverResponse.Executions,
		NextPageToken: archiverResponse.NextPageToken,
	}, nil
}
func ( wh * WorkflowHandler ) ListArchivedWorkflowExecutions ( ctx context . Context , listRequest * types . ListArchivedWorkflowExecutionsRequest , ) ( resp * types . ListArchivedWorkflowExecutionsResponse , retError error ) { defer log . CapturePanic ( wh . GetLogger ( ) , & retError ) scope , sw := wh . startRequestProfileWithDomain ( ctx , metrics . FrontendListArchivedWorkflowExecutionsScope , 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 . GetPageSize ( ) <= 0 { listRequest . PageSize = int32 ( wh . config . VisibilityMaxPageSize ( listRequest . GetDomain ( ) ) ) } maxPageSize := wh . config . VisibilityArchivalQueryMaxPageSize ( ) if int ( listRequest . GetPageSize ( ) ) > maxPageSize { return nil , wh . error ( & types . BadRequestError { Message : fmt . Sprintf ( " " , maxPageSize ) } , scope ) } if ! wh . GetArchivalMetadata ( ) . GetVisibilityConfig ( ) . ClusterConfiguredForArchival ( ) { return nil , wh . error ( & types . BadRequestError { Message : " " } , scope ) } if ! wh . GetArchivalMetadata ( ) . GetVisibilityConfig ( ) . ReadEnabled ( ) { return nil , wh . error ( & types . BadRequestError { Message : " " } , scope ) } entry , err := wh . GetDomainCache ( ) . GetDomain ( listRequest . GetDomain ( ) ) if err != nil { return nil , wh . error ( err , scope ) } if entry . GetConfig ( ) . VisibilityArchivalStatus != types . ArchivalStatusEnabled { return nil , wh . error ( & types . BadRequestError { Message : " " } , scope ) } URI , err := archiver . NewURI ( entry . GetConfig ( ) . VisibilityArchivalURI ) if err != nil { return nil , wh . error ( err , scope ) } visibilityArchiver , err := wh . GetArchiverProvider ( ) . GetVisibilityArchiver ( URI . Scheme ( ) , service . Frontend ) if err != nil { return nil , wh . error ( err , scope ) } archiverRequest := & archiver . QueryVisibilityRequest { DomainID : entry . GetInfo ( ) . ID , PageSize : int ( listRequest . GetPageSize ( ) ) , NextPageToken : listRequest . NextPageToken , Query : listRequest . GetQuery ( ) , } archiverResponse , err := visibilityArchiver . Query ( ctx , URI , archiverRequest ) if err != nil { return nil , wh . error ( err , scope ) } for _ , execution := range archiverResponse . Executions { if execution . GetExecutionTime ( ) == 0 { execution . ExecutionTime = common . Int64Ptr ( execution . GetStartTime ( ) ) } } return & types . ListArchivedWorkflowExecutionsResponse { Executions : archiverResponse . Executions , NextPageToken : archiverResponse . NextPageToken , } , nil }
retrieves archived info for closed workflow executions in a domain
retrieves archived info for closed workflow executions in a domain
// special handling of ExecutionTime for cron or retry