models

package
v0.14.7-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConcurrencyPolicySuspend = "suspend"
	ConcurrencyPolicyReplace = "replace"
	ConcurrencyPolicySkip    = "skip"

	ScheduleStatusSuccess    = "success"
	ScheduleStatusRunning    = "running"
	ScheduleStatusFailed     = "failed"
	ScheduleStatusTerminated = "terminated"
)

Variables

View Source
var ScheduleNotFinalStatusList = []string{
	ScheduleStatusRunning,
}

Functions

func CountActiveRunsForSchedule added in v0.14.3

func CountActiveRunsForSchedule(logEntry *log.Entry, scheduleID string) (int64, error)

func CountRun added in v0.14.3

func CountRun(logEntry *log.Entry, pk int64, maxKeys int, userFilter, fsFilter, runFilter, nameFilter, statusFilter, scheduleIdFilter []string) (count int64, err error)

func CreateRun

func CreateRun(logEntry *log.Entry, run *Run) (string, error)

func CreateRunCache

func CreateRunCache(logEntry *log.Entry, cache *RunCache) (string, error)

func CreateRunDag added in v0.14.3

func CreateRunDag(logEntry *log.Entry, runDag *RunDag) (int64, error)

func CreateRunJob added in v0.14.3

func CreateRunJob(logEntry *log.Entry, runJob *RunJob) (int64, error)

func CreateSchedule added in v0.14.3

func CreateSchedule(logEntry *log.Entry, schedule Schedule) (scheduleID string, err error)

func DeleteRun

func DeleteRun(logEntry *log.Entry, runID string) error

func DeleteRunCache

func DeleteRunCache(logEntry *log.Entry, cacheID string) error

func DeleteSchedule added in v0.14.3

func DeleteSchedule(logEntry *log.Entry, scheduleID string) error

func GetCacheCount

func GetCacheCount(logEntry *log.Entry, runID string) (int64, error)

func GetNextGlobalWakeupTime added in v0.14.3

func GetNextGlobalWakeupTime(logEntry *log.Entry) (*time.Time, error)

计算timeout先不加事务,虽然select和 CountActiveRunsForSchedule 是非原子性,因为只影响休眠时间的计算结果

func IsLastSchedulePk added in v0.14.3

func IsLastSchedulePk(logEntry *log.Entry, pk int64, pplFilter, pplVersionFilter, userFilter, scheduleFilter, nameFilter, statusFilter []string) (bool, error)

func IsScheduleFinalStatus added in v0.14.3

func IsScheduleFinalStatus(status string) bool

func ScheduleUsedFsIDs added in v0.14.3

func ScheduleUsedFsIDs() (map[string]bool, error)

func UpdateCache

func UpdateCache(logEntry *log.Entry, cacheID string, cache RunCache) error

func UpdateRun

func UpdateRun(logEntry *log.Entry, runID string, run Run) error

func UpdateRunDag added in v0.14.3

func UpdateRunDag(logEntry *log.Entry, pk int64, runDag RunDag) error

func UpdateRunJob

func UpdateRunJob(logEntry *log.Entry, pk int64, runJob RunJob) error

func UpdateRunStatus

func UpdateRunStatus(logEntry *log.Entry, runID, status string) error

func UpdateScheduleStatus added in v0.14.3

func UpdateScheduleStatus(logEntry *log.Entry, scheduleID, status string) error

Types

type FsConfig added in v0.14.3

type FsConfig struct {
	Username string `json:"username"`
}

func DecodeFsConfig added in v0.14.3

func DecodeFsConfig(strConfig string) (fc FsConfig, err error)

func (*FsConfig) Encode added in v0.14.3

func (fc *FsConfig) Encode(logEntry *log.Entry) (string, error)

type Run

type Run struct {
	Pk                 int64                  `gorm:"primaryKey;autoIncrement;not null" json:"-"`
	ID                 string                 `gorm:"type:varchar(60);not null"         json:"runID"`
	Name               string                 `gorm:"type:varchar(128);not null"         json:"name"`
	Source             string                 `gorm:"type:varchar(256);not null"        json:"source"` // pipelineID or yamlPath
	UserName           string                 `gorm:"type:varchar(60);not null"         json:"username"`
	FsID               string                 `gorm:"type:varchar(60);not null"         json:"-"`
	FsName             string                 `gorm:"type:varchar(60);not null"         json:"fsName"`
	FsOptions          schema.FsOptions       `gorm:"-"                                 json:"fsOptions"`
	Description        string                 `gorm:"type:text;size:65535;not null"     json:"description"`
	ParametersJson     string                 `gorm:"type:text;size:65535;not null"     json:"-"`
	Parameters         map[string]interface{} `gorm:"-"                                 json:"parameters"`
	RunYaml            string                 `gorm:"type:text;size:65535;not null"     json:"runYaml"`
	WorkflowSource     schema.WorkflowSource  `gorm:"-"                                 json:"-"` // RunYaml's dynamic struct
	Runtime            schema.RuntimeView     `gorm:"-"                                 json:"runtime"`
	PostProcess        schema.PostProcessView `gorm:"-"                                 json:"postProcess"`
	FailureOptions     *schema.FailureOptions `gorm:"-"                                 json:"failureOptions"`
	FailureOptionsJson string                 `gorm:"type:text;size:65535;not null"     json:"-"`
	DockerEnv          string                 `gorm:"type:varchar(128);not null"        json:"dockerEnv"`
	Disabled           string                 `gorm:"type:text;size:65535;not null"     json:"disabled"`
	ScheduleID         string                 `gorm:"type:varchar(60);not null"         json:"scheduleID"`
	Message            string                 `gorm:"type:text;size:65535;not null"     json:"runMsg"`
	Status             string                 `gorm:"type:varchar(32);not null"         json:"status"` // StatusRun%%%
	RunOptions         schema.RunOptions      `gorm:"-"                                 json:"-"`
	RunOptionsJson     string                 `gorm:"type:text;size:65535;not null"     json:"-"`
	RunCachedIDs       string                 `gorm:"type:text;size:65535;not null"     json:"runCachedIDs"`
	ScheduledAt        sql.NullTime           `                                         json:"-"`
	CreateTime         string                 `gorm:"-"                                 json:"createTime"`
	ActivateTime       string                 `gorm:"-"                                 json:"activateTime"`
	UpdateTime         string                 `gorm:"-"                                 json:"updateTime"`
	CreatedAt          time.Time              `                                         json:"-"`
	ActivatedAt        sql.NullTime           `                                         json:"-"`
	UpdatedAt          time.Time              `                                         json:"-"`
	DeletedAt          gorm.DeletedAt         `                                         json:"-"`
}

func GetLastRun

func GetLastRun(logEntry *log.Entry) (Run, error)

func GetRunByID

func GetRunByID(logEntry *log.Entry, runID string) (Run, error)

func ListRun

func ListRun(logEntry *log.Entry, pk int64, maxKeys int, userFilter, fsFilter, runFilter, nameFilter, statusFilter, scheduleIdFilter []string) ([]Run, error)

func ListRunsByStatus

func ListRunsByStatus(logEntry *log.Entry, statusList []string) ([]Run, error)

func (*Run) Encode

func (r *Run) Encode() error

func (*Run) GetRunCacheIDList

func (r *Run) GetRunCacheIDList() []string

func (*Run) InitRuntime added in v0.14.3

func (r *Run) InitRuntime(jobs []RunJob, dags []RunDag) error

func (*Run) ProcessRuntimeView added in v0.14.3

func (r *Run) ProcessRuntimeView(componentViews map[string][]schema.ComponentView, components map[string]schema.Component) error

补全ComponentView中的Deps

func (*Run) RemoveOuterDagView added in v0.14.3

func (r *Run) RemoveOuterDagView(runtimeView map[string][]schema.ComponentView) map[string][]schema.ComponentView

func (Run) TableName

func (Run) TableName() string

type RunCache

type RunCache struct {
	Pk          int64          `json:"-"                    gorm:"primaryKey;autoIncrement;not null"`
	ID          string         `json:"cacheID"              gorm:"type:varchar(60);not null;index"`
	FirstFp     string         `json:"firstFp"              gorm:"type:varchar(256)"`
	SecondFp    string         `json:"secondFp"             gorm:"type:varchar(256)"`
	RunID       string         `json:"runID"                gorm:"type:varchar(60);not null"`
	Source      string         `json:"source"               gorm:"type:varchar(256);not null"`
	JobID       string         `json:"jobID"                gorm:"type:varchar(60);not null"`
	FsID        string         `json:"-"                    gorm:"type:varchar(60);not null"`
	FsName      string         `json:"fsname"               gorm:"type:varchar(60);not null"`
	UserName    string         `json:"username"             gorm:"type:varchar(60);not null"`
	ExpiredTime string         `json:"expiredTime"          gorm:"type:varchar(64);default:'-1'"`
	Strategy    string         `json:"strategy"             gorm:"type:varchar(16);default:'conservative'"`
	Custom      string         `json:"custom"               gorm:"type:text;size:65535"`
	CreateTime  string         `json:"createTime"           gorm:"-"`
	UpdateTime  string         `json:"updateTime,omitempty" gorm:"-"`
	CreatedAt   time.Time      `json:"-"`
	UpdatedAt   time.Time      `json:"-"`
	DeletedAt   gorm.DeletedAt `json:"-"                    gorm:"index"`
}

func GetLastCacheForRun

func GetLastCacheForRun(logEntry *log.Entry, runID string) (RunCache, error)

func GetLastRunCache

func GetLastRunCache(logEntry *log.Entry) (RunCache, error)

func GetRunCache

func GetRunCache(logEntry *log.Entry, cacheID string) (RunCache, error)

func ListRunCache

func ListRunCache(logEntry *log.Entry, pk int64, maxKeys int, userFilter, fsFilter, runFilter []string) ([]RunCache, error)

func ListRunCacheByFirstFp

func ListRunCacheByFirstFp(logEntry *log.Entry, firstFp, fsID, source string) ([]RunCache, error)

func (RunCache) TableName

func (RunCache) TableName() string

type RunDag added in v0.14.3

type RunDag struct {
	Pk             int64             `gorm:"primaryKey;autoIncrement;not null"  json:"-"`
	ID             string            `gorm:"type:varchar(60);not null"          json:"dagID"`
	RunID          string            `gorm:"type:varchar(60);not null"          json:"runID"`
	ParentDagID    string            `gorm:"type:varchar(60);not null"          json:"parentDagID"`
	Name           string            `gorm:"type:varchar(60);not null"          json:"name"`
	DagName        string            `gorm:"type:varchar(60);not null"          json:"dag_name"`
	Parameters     map[string]string `gorm:"-"                                  json:"parameters"`
	ParametersJson string            `gorm:"type:text;size:65535;not null"      json:"-"`
	Artifacts      schema.Artifacts  `gorm:"-"                                  json:"artifacts"`
	ArtifactsJson  string            `gorm:"type:text;size:65535;not null"      json:"-"`
	LoopSeq        int               `gorm:"type:int;not null"                  json:"-"`
	Status         schema.JobStatus  `gorm:"type:varchar(32);not null"          json:"status"`
	Message        string            `gorm:"type:text;size:65535;not null"      json:"message"`
	CreateTime     string            `gorm:"-"                                  json:"createTime"`
	ActivateTime   string            `gorm:"-"                                  json:"activateTime"`
	UpdateTime     string            `gorm:"-"                                  json:"updateTime,omitempty"`
	CreatedAt      time.Time         `                                          json:"-"`
	ActivatedAt    sql.NullTime      `                                          json:"-"`
	UpdatedAt      time.Time         `                                          json:"-"`
	DeletedAt      gorm.DeletedAt    `gorm:"index"                              json:"-"`
}

func GetRunDagsOfRun added in v0.14.3

func GetRunDagsOfRun(logEntry *log.Entry, runID string) ([]RunDag, error)

func ParseRunDag added in v0.14.3

func ParseRunDag(dagView *schema.DagView) RunDag

func (*RunDag) Encode added in v0.14.3

func (rd *RunDag) Encode() error

func (*RunDag) Trans2DagView added in v0.14.3

func (rd *RunDag) Trans2DagView() schema.DagView

type RunJob

type RunJob struct {
	Pk             int64             `gorm:"primaryKey;autoIncrement;not null"  json:"-"`
	ID             string            `gorm:"type:varchar(60);not null"          json:"jobID"`
	RunID          string            `gorm:"type:varchar(60);not null"          json:"runID"`
	ParentDagID    string            `gorm:"type:varchar(60);not null"          json:"parentDagID"`
	Name           string            `gorm:"type:varchar(60);not null"          json:"name"`
	StepName       string            `gorm:"type:varchar(60);not null"          json:"step_name"`
	Command        string            `gorm:"type:text;size:65535;not null"      json:"command"`
	Parameters     map[string]string `gorm:"-"                                  json:"parameters"`
	ParametersJson string            `gorm:"type:text;size:65535;not null"      json:"-"`
	Artifacts      schema.Artifacts  `gorm:"-"                                  json:"artifacts"`
	ArtifactsJson  string            `gorm:"type:text;size:65535;not null"      json:"-"`
	Env            map[string]string `gorm:"-"                                  json:"env"`
	EnvJson        string            `gorm:"type:text;size:65535;not null"      json:"-"`
	DockerEnv      string            `gorm:"type:varchar(128);not null"         json:"docker_env"`
	LoopSeq        int               `gorm:"type:int;not null"                  json:"-"`
	Status         schema.JobStatus  `gorm:"type:varchar(32);not null"          json:"status"`
	Message        string            `gorm:"type:text;size:65535;not null"      json:"message"`
	Cache          schema.Cache      `gorm:"-"                                  json:"cache"`
	CacheJson      string            `gorm:"type:text;size:65535;not null"      json:"-"`
	CacheRunID     string            `gorm:"type:varchar(60);not null"          json:"cacheRunID"`
	CacheJobID     string            `gorm:"type:varchar(60);not null"          json:"cacheJobID"`
	ExtraFS        []schema.FsMount  `gorm:"-"                                  json:"extraFs"`
	ExtraFSJson    string            `gorm:"type:text;size:65535;not null"      json:"-"`
	CreateTime     string            `gorm:"-"                                  json:"createTime"`
	ActivateTime   string            `gorm:"-"                                  json:"activateTime"`
	UpdateTime     string            `gorm:"-"                                  json:"updateTime,omitempty"`
	CreatedAt      time.Time         `                                          json:"-"`
	ActivatedAt    sql.NullTime      `                                          json:"-"`
	UpdatedAt      time.Time         `                                          json:"-"`
	DeletedAt      gorm.DeletedAt    `gorm:"index"                              json:"-"`
}

func GetRunJob added in v0.14.3

func GetRunJob(logEntry *log.Entry, jobID string) (RunJob, error)

func GetRunJobsOfRun

func GetRunJobsOfRun(logEntry *log.Entry, runID string) ([]RunJob, error)

func ParseRunJob

func ParseRunJob(jobView *schema.JobView) RunJob

func (*RunJob) Encode

func (rj *RunJob) Encode() error

func (*RunJob) Finished added in v0.14.6

func (rj *RunJob) Finished() bool

func (*RunJob) ParseJobView

func (rj *RunJob) ParseJobView(step *schema.WorkflowSourceStep) schema.JobView

func (*RunJob) Trans2JobView added in v0.14.3

func (rj *RunJob) Trans2JobView() schema.JobView

type Schedule added in v0.14.3

type Schedule struct {
	Pk                int64          `gorm:"primaryKey;autoIncrement;not null" json:"-"`
	ID                string         `gorm:"type:varchar(60);not null"         json:"scheduleID"`
	Name              string         `gorm:"type:varchar(60);not null"         json:"name"`
	Desc              string         `gorm:"type:varchar(256);not null"       json:"desc"`
	PipelineID        string         `gorm:"type:varchar(60);not null"         json:"pipelineID"`
	PipelineVersionID string         `gorm:"type:varchar(60);not null"         json:"pipelineVersionID"`
	UserName          string         `gorm:"type:varchar(60);not null"         json:"username"`
	FsConfig          string         `gorm:"type:varchar(1024);not null"       json:"fsConfig"`
	Crontab           string         `gorm:"type:varchar(60);not null"         json:"crontab"`
	Options           string         `gorm:"type:text;size:65535;not null"     json:"options"`
	Message           string         `gorm:"type:text;size:65535;not null"     json:"scheduleMsg"`
	Status            string         `gorm:"type:varchar(32);not null"         json:"status"`
	StartAt           sql.NullTime   `                                         json:"-"`
	EndAt             sql.NullTime   `                                         json:"-"`
	NextRunAt         time.Time      `                                         json:"-"`
	CreatedAt         time.Time      `                                         json:"-"`
	UpdatedAt         time.Time      `                                         json:"-"`
	DeletedAt         gorm.DeletedAt `                                         json:"-"`
}

func GetSchedule added in v0.14.3

func GetSchedule(logEntry *log.Entry, scheduleID string) (Schedule, error)

func GetScheduleByName added in v0.14.3

func GetScheduleByName(logEntry *log.Entry, name, userName string) (Schedule, error)

func GetSchedulesByStatus added in v0.14.3

func GetSchedulesByStatus(logEntry *log.Entry, status string) (schedules []Schedule, err error)

func ListSchedule added in v0.14.3

func ListSchedule(logEntry *log.Entry, pk int64, maxKeys int, pplFilter, pplVersionFilter, userFilter, scheduleFilter, nameFilter, statusFilter []string) ([]Schedule, error)

func (Schedule) TableName added in v0.14.3

func (Schedule) TableName() string

type ScheduleOptions added in v0.14.3

type ScheduleOptions struct {
	Catchup           bool   `json:"catchup"`
	ExpireInterval    int    `json:"expireInterval"`
	Concurrency       int    `json:"concurrency"`
	ConcurrencyPolicy string `json:"concurrencyPolicy"`
}

func DecodeScheduleOptions added in v0.14.3

func DecodeScheduleOptions(StrOptions string) (so ScheduleOptions, err error)

func NewScheduleOptions added in v0.14.3

func NewScheduleOptions(logEntry *log.Entry, catchup bool, expireInterval int, concurrency int, concurrencyPolicy string) (so ScheduleOptions, err error)

func (*ScheduleOptions) Encode added in v0.14.3

func (so *ScheduleOptions) Encode(logEntry *log.Entry) (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL