taskrun

package
v5.0.4-release+incompa... Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AtLeastOnceStrategy = "AtLeastOnce"

AtLeastOnceStrategy 至少已执行一次

View Source
var SameNodeStrategy = "SameNode"

SameNodeStrategy 相同节点已执行

Functions

This section is empty.

Types

type DependStrategy

type DependStrategy struct {
	DependTaskID      string `json:"depend_task_id"`
	DetermineStrategy string `json:"strategy"`
}

DependStrategy 依赖策略

type Jobs

type Jobs map[string]*job.Job

Jobs jobs

type Manager

type Manager interface {
	Start(errchan chan error)
	Stop() error
}

Manager Manager

func Newmanager

func Newmanager(cfg *option.Conf) (Manager, error)

Newmanager new server

type Scheduler

type Scheduler struct {
	Mode   string                     `json:"mode"` //立即调度(Intime),触发调度(Passive)
	Status map[string]SchedulerStatus `json:"status"`
}

Scheduler 调度状态

type SchedulerStatus

type SchedulerStatus struct {
	Status          string    `json:"status"`
	Message         string    `json:"message"`
	SchedulerTime   time.Time `json:"scheduler_time"`   //调度时间
	SchedulerMaster string    `json:"scheduler_master"` //调度的管理节点
}

SchedulerStatus 调度状态

type Shell

type Shell struct {
	Cmd []string `json:"cmd"`
}

Shell 执行脚本配置

type Task

type Task struct {
	Name    string    `json:"name" validate:"name|required"`
	ID      string    `json:"id" validate:"id|uuid"`
	TempID  string    `json:"temp_id,omitempty" validate:"temp_id|uuid"`
	Temp    *TaskTemp `json:"temp,omitempty"`
	GroupID string    `json:"group_id,omitempty"`
	//执行的节点
	Nodes []string `json:"nodes"`
	//执行时间定义
	//例如每30分钟执行一次:@every 30m
	Timer   string `json:"timer"`
	TimeOut int64  `json:"time_out"`
	// 执行任务失败重试次数
	// 默认为 0,不重试
	Retry int `json:"retry"`
	// 执行任务失败重试时间间隔
	// 单位秒,如果不大于 0 则马上重试
	Interval int `json:"interval"`
	//ExecCount 执行次数
	ExecCount int `json:"exec_count"`
	//每个执行节点执行状态
	Status       map[string]TaskStatus `json:"status,omitempty"`
	Scheduler    Scheduler             `json:"scheduler"`
	CreateTime   time.Time             `json:"create_time"`
	StartTime    time.Time             `json:"start_time"`
	CompleteTime time.Time             `json:"complete_time"`
	ResultPath   string                `json:"result_path"`
	EventID      string                `json:"event_id"`
	RunMode      string                `json:"run_mode"`
	OutPut       []*TaskOutPut         `json:"out_put"`
}

Task 任务

func (Task) CanBeDelete

func (t Task) CanBeDelete() bool

CanBeDelete 能否被删除

func (*Task) Decode

func (t *Task) Decode(data []byte) error

Decode Decode

func (Task) String

func (t Task) String() string

func (*Task) UpdataOutPut

func (t *Task) UpdataOutPut(output TaskOutPut)

UpdataOutPut 更新状态

type TaskGroup

type TaskGroup struct {
	Name       string           `json:"name" validate:"name|required"`
	ID         string           `json:"id" validate:"id|uuid"`
	Tasks      []*Task          `json:"tasks"`
	CreateTime time.Time        `json:"create_time"`
	Status     *TaskGroupStatus `json:"status"`
}

TaskGroup 任务组

func (TaskGroup) CanBeDelete

func (t TaskGroup) CanBeDelete() bool

CanBeDelete 是否能被删除

func (TaskGroup) String

func (t TaskGroup) String() string

type TaskGroupStatus

type TaskGroupStatus struct {
	TaskStatus map[string]TaskStatus `json:"task_status"`
	InitTime   time.Time             `json:"init_time"`
	StartTime  time.Time             `json:"start_time"`
	EndTime    time.Time             `json:"end_time"`
	Status     string                `json:"status"` //create init exec complete timeout
}

TaskGroupStatus 任务组状态

type TaskOutPut

type TaskOutPut struct {
	NodeID string            `json:"node_id"`
	JobID  string            `json:"job_id"`
	Global map[string]string `json:"global"`
	Inner  map[string]string `json:"inner"`
	//返回数据类型,检测结果类(check) 执行安装类 (install) 普通类 (common)
	Type       string             `json:"type"`
	Status     []TaskOutPutStatus `json:"status"`
	ExecStatus string             `json:"exec_status"`
	Body       string             `json:"body"`
}

TaskOutPut 任务输出

func ParseTaskOutPut

func ParseTaskOutPut(body string) (t TaskOutPut, err error)

ParseTaskOutPut json parse

type TaskOutPutStatus

type TaskOutPutStatus struct {
	Name string `json:"name"`
	//节点属性
	ConditionType string `json:"condition_type"`
	//节点属性值
	ConditionStatus string   `json:"condition_status"`
	NextTask        []string `json:"next_tasks,omitempty"`
	NextGroups      []string `json:"next_groups,omitempty"`
}

TaskOutPutStatus 输出数据

type TaskStatus

type TaskStatus struct {
	JobID        string    `json:"job_id"`
	Status       string    `json:"status"` //执行状态,create init exec complete timeout
	StartTime    time.Time `json:"start_time"`
	EndTime      time.Time `json:"end_time"`
	TakeTime     int       `json:"take_time"`
	CompleStatus string    `json:"comple_status"`
	//脚本退出码
	ShellCode int    `json:"shell_code"`
	Message   string `json:"message,omitempty"`
}

TaskStatus 任务状态

type TaskTemp

type TaskTemp struct {
	Name       string            `json:"name" validate:"name|required"`
	ID         string            `json:"id" validate:"id|uuid"`
	Shell      Shell             `json:"shell"`
	Envs       map[string]string `json:"envs,omitempty"`
	Input      string            `json:"input,omitempty"`
	Args       []string          `json:"args,omitempty"`
	Depends    []DependStrategy  `json:"depends,omitempty"`
	Timeout    int               `json:"timeout" validate:"timeout|required|numeric"`
	CreateTime time.Time         `json:"create_time"`
	Labels     map[string]string `json:"labels,omitempty"`
}

TaskTemp 任务模版

func (TaskTemp) String

func (t TaskTemp) String() string

Jump to

Keyboard shortcuts

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