github.com/kubevela/workflow@v0.6.0/pkg/backup/interface.go (about)

     1  package backup
     2  
     3  import (
     4  	"fmt"
     5  
     6  	monitorContext "github.com/kubevela/pkg/monitor/context"
     7  	"github.com/kubevela/workflow/api/v1alpha1"
     8  	"github.com/kubevela/workflow/pkg/backup/sls"
     9  )
    10  
    11  const (
    12  	// PersistTypeSLS is the SLS persister.
    13  	PersistTypeSLS string = "sls"
    14  )
    15  
    16  // NewPersister is a factory method for creating a persister.
    17  func NewPersister(config map[string][]byte, persistType string) (PersistWorkflowRecord, error) {
    18  	if config == nil {
    19  		return nil, fmt.Errorf("empty config")
    20  	}
    21  	switch persistType {
    22  	case PersistTypeSLS:
    23  		return sls.NewSLSHandler(config)
    24  	case "":
    25  		return nil, nil
    26  	default:
    27  		return nil, fmt.Errorf("unsupported persist type %s", persistType)
    28  	}
    29  }
    30  
    31  // PersistWorkflowRecord is the interface for record persist
    32  type PersistWorkflowRecord interface {
    33  	Store(ctx monitorContext.Context, run *v1alpha1.WorkflowRun) error
    34  }