cronjob

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EtcdKeyJobPrefix    = "/juno/cronjob/job/"                        // Job下发
	EtcdKeyFmtOnceJob   = "/juno/cronjob/once/{{hostname}}/{{jobId}}" // 单次任务
	EtcdKeyFmtTaskLock  = "/juno/cronjob/lock/{{jobId}}//{{taskId}}"  // 执行锁
	EtcdKeyResultPrefix = "/juno/cronjob/result/"                     // 执行结果通知 /juno/cronjob/result/{{jobId}}/{{taskId}}
	EtcdKeyPrefixProc   = "/juno/cronjob/proc/"                       // 当前运行的进程
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CronJob

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

CronJob ..

func New

func New(db *gorm.DB) *CronJob

New ..

func (*CronJob) Create

func (j *CronJob) Create(uid uint, params view.CronJob) (err error)

Create 创建 Job

func (*CronJob) Delete

func (j *CronJob) Delete(id uint) (err error)

Delete 删除 id 对应的 Job

func (*CronJob) DispatchOnce

func (j *CronJob) DispatchOnce(id uint, node string) (err error)

DispatchOnce 下发任务手动执行单次

func (*CronJob) List

func (j *CronJob) List(params view.ReqQueryJobs) (list []view.CronJobListItem, pagination core.Pagination, err error)

List Job 列表

func (*CronJob) ListTask

func (j *CronJob) ListTask(params view.ReqQueryTasks) (list []view.CronTask, pagination view.Pagination, err error)

ListTask 任务列表

func (*CronJob) StartWatch

func (j *CronJob) StartWatch()

func (*CronJob) TaskDetail

func (j *CronJob) TaskDetail(id uint) (detail view.CronTaskDetail, err error)

TaskDetail Task 详情

func (*CronJob) Update

func (j *CronJob) Update(params view.CronJob) (err error)

Update ..

type Dispatcher

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

type Job

type Job struct {
	ID            string   `json:"id"`
	Name          string   `json:"name"`
	Script        string   `json:"script"`
	Timers        []Timer  `json:"timers"`
	Enable        bool     `json:"enable"`  // 可手工控制的状态
	Timeout       uint     `json:"timeout"` // 单位时间秒,任务执行时间超时设置,大于 0 时有效
	RetryCount    uint     `json:"retry_count"`
	RetryInterval uint     `json:"retry_interval"`
	Env           string   `json:"env"`
	Zone          string   `json:"zone"`
	Nodes         []string `json:"nodes"`

	JobType db.CronJobType `json:"job_type"`
}

func GetJobFromKv

func GetJobFromKv(key []byte, value []byte) (*Job, error)

type OnceJob

type OnceJob struct {
	TaskID uint64 `json:"task_id"`

	Job
}

type ResultWatcher

type ResultWatcher struct {
	*clientv3.Client
	DB *gorm.DB

	Zone *view.UniqZone
}

func (*ResultWatcher) Start

func (r *ResultWatcher) Start()

type TaskResult

type TaskResult struct {
	TaskID      uint64            `json:"task_id"`
	ExecuteType int               `json:"execute_type"`
	Status      db.CronTaskStatus `json:"status"`
	Job         Job               `json:"job"`
	Logs        string            `json:"logs"`
	RunOn       string            `json:"run_on"`
	ExecutedAt  time.Time         `json:"executed_at"`
	FinishedAt  *time.Time        `json:"finished_at"`
}

type Timer

type Timer struct {
	ID   string `json:"id"`
	Cron string `json:"timer"`
}

Jump to

Keyboard shortcuts

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