model

package
v0.0.0-...-0de2bea Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2019 License: Apache-2.0 Imports: 6 Imported by: 9

Documentation

Index

Constants

View Source
const JobTypeChoice = "choice-job"
View Source
const JobTypeKube = "kube-job"
View Source
const JobTypeParallel = "parallel-job"

Variables

View Source
var CompletedTaskStatuses = []TaskStatusType{
	TaskSuccess,
	TaskFailed,
}
View Source
var UncompletedTaskStatuses = []TaskStatusType{
	TaskRunning,
}
View Source
var UncompletedWorkflowStatuses = []WorkflowStatusType{
	WfRunning,
	WfScheduled,
}

Functions

This section is empty.

Types

type ExecutionError

type ExecutionError struct {
	// contains filtered or unexported fields
}

type JobDef

type JobDef struct {
	Tasks []Task
}

func GetJobDefFromString

func GetJobDefFromString(jobDefStr string) *JobDef

func (*JobDef) GetCurrentTask

func (jobDef *JobDef) GetCurrentTask(te *TaskExecution) Task

Get te's task definition

func (*JobDef) GetNextTask

func (jobDef *JobDef) GetNextTask(te *TaskExecution) Task

Get next job Next job is decided by tasks' status which belong to the execution

func (*JobDef) GetStartTask

func (jobDef *JobDef) GetStartTask() Task

Get first job of this definition

type JobDefProvider

type JobDefProvider interface {
	GetJobDef() *JobDef
}

type KubeJobTask

type KubeJobTask struct {
	Name         string
	NextTaskName string
	KubeJobSpec  v1.Job
}

func (*KubeJobTask) GetJobType

func (task *KubeJobTask) GetJobType() string

func (*KubeJobTask) GetName

func (task *KubeJobTask) GetName() string

func (*KubeJobTask) GetNextTaskName

func (task *KubeJobTask) GetNextTaskName() string

type ParallelTask

type ParallelTask struct {
	Name         string
	NextTaskName string
	TaskSets     [][]Task
}

func (*ParallelTask) GetJobType

func (task *ParallelTask) GetJobType() string

func (*ParallelTask) GetName

func (task *ParallelTask) GetName() string

func (*ParallelTask) GetNextTaskName

func (task *ParallelTask) GetNextTaskName() string

func (*ParallelTask) GetTaskSets

func (task *ParallelTask) GetTaskSets() [][]Task

type Task

type Task interface {
	GetName() string
	GetNextTaskName() string
	GetJobType() string
}

type TaskExecution

type TaskExecution struct {
	ID                    uint               `gorm:"primary_key" json:"id"`
	WorkflowExecution     *WorkflowExecution `json:"-"`
	WorkflowExecutionID   uint               `gorm:"not null" json:"-"`
	ParentTaskExecution   *TaskExecution     `json:"-"`
	ParentTaskExecutionID uint               `json:"parentId"`
	NextTaskExecution     *TaskExecution     `json:"-"`
	NextTaskExecutionID   uint               `json:"nextId"`
	PrevTaskExecution     *TaskExecution     `json:"-"`
	PrevTaskExecutionID   uint               `json:"prevId"`
	ExecutionName         string             `gorm:"not null" json:"executionName"`
	TaskName              string             `gorm:"not null" json:"taskName"`
	TaskType              string             `gorm:"not null" json:"taskType"`
	StartedAt             *time.Time         `gorm:"not null" json:"startedAt"`
	EndedAt               *time.Time         `json:"endedAt"`
	ElapsedSec            uint               `json:"elapsedSec"`
	Status                TaskStatusType     `gorm:"not null" json:"status"`
	Input                 string             `gorm:"type:json;not null" json:"input"`
	Output                string             `gorm:"type:json;not null" json:"output"`
	ErrorReason           string             `json:"errorReason"`
	ErrorMsg              string             `json:"errorMsg"`
	CreatedAt             *time.Time         `json:"-"`
	UpdatedAt             *time.Time         `json:"-"`
}

func (*TaskExecution) IsCompleted

func (te *TaskExecution) IsCompleted() bool

func (*TaskExecution) IsFailed

func (te *TaskExecution) IsFailed() bool

func (*TaskExecution) IsSucceeded

func (te *TaskExecution) IsSucceeded() bool

func (*TaskExecution) MarkFailed

func (te *TaskExecution) MarkFailed(endedAt *time.Time, errReason string, errMsg string)

func (*TaskExecution) MarkSuccess

func (te *TaskExecution) MarkSuccess(endedAt *time.Time)

type TaskStatusType

type TaskStatusType int
const (
	TaskRunning TaskStatusType = iota
	TaskSuccess
	TaskFailed
)

type User

type User struct {
	ID        uint   `gorm:"primary_key"`
	Name      string `gorm:"not null"`
	CreatedAt *time.Time
	UpdatedAt *time.Time
}

type Workflow

type Workflow struct {
	ID         uint       `gorm:"primary_key" json:"id"`
	Name       string     `gorm:"not null" json:"name"`
	Definition string     `gorm:"type:json;not null" json:"definition"`
	User       *User      `gorm:"not null" json:"user"`
	UserID     uint       `gorm:"not null" json:"-"`
	CreatedAt  *time.Time `json:"-"`
	UpdatedAt  *time.Time `json:"-"`
	// contains filtered or unexported fields
}

func (*Workflow) GetJobDef

func (workflow *Workflow) GetJobDef() *JobDef

type WorkflowExecution

type WorkflowExecution struct {
	ID             uint               `gorm:"primary_key" json:"id"`
	Workflow       *Workflow          `json:"workflow"`
	WorkflowID     uint               `gorm:"not null" json:"-"`
	TaskExecutions []TaskExecution    `json:"taskExecutions"`
	Name           string             `gorm:"not null" json:"name"`
	StartedAt      *time.Time         `json:"startedAt"`
	EndedAt        *time.Time         `json:"endedAt"`
	Status         WorkflowStatusType `gorm:"not null" json:"status"`
	Input          string             `gorm:"type:json;not null" json:"input"`
	Output         string             `gorm:"type:json;not null" json:"output"`
	Definition     string             `gorm:"type:json;not null" json:"definition"`
	Attempt        int                `gorm:"not null;default:1" json:"attempt"`
	ErrorMsg       string             `json:"errorMsg"`
	CreatedAt      *time.Time         `json:"-"`
	UpdatedAt      *time.Time         `json:"-"`
	// contains filtered or unexported fields
}

func (*WorkflowExecution) GetJobDef

func (execution *WorkflowExecution) GetJobDef() *JobDef

type WorkflowStatusType

type WorkflowStatusType int
const (
	WfScheduled WorkflowStatusType = iota
	WfRunning
	WfSuccess
	WfFailed
)

Jump to

Keyboard shortcuts

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