task

package
v0.0.0-...-74c85ca Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusAdd add task flag
	StatusAdd = 1
	// StatusDel del task flag
	StatusDel = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option struct {
	TaskRenewTick time.Duration
}

Option struct

func NewOption

func NewOption() *Option

NewOption returns option instance

type Scheduler

type Scheduler struct {
	WaitGroup util.WaitGroupWrapper

	Tasks Tasks
	Raft  *raft.Raft
	// contains filtered or unexported fields
}

Scheduler is task scheduler struct

func NewScheduler

func NewScheduler(opt *Option, ts Tasks, r *raft.Raft) *Scheduler

NewScheduler returns scheduler instance

func (*Scheduler) Renew

func (s *Scheduler) Renew()

Renew is used to renew schedule task

func (*Scheduler) Run

func (s *Scheduler) Run()

Run start task schedule

type Task

type Task struct {
	Name            string               `json:"name"`
	Cmd             string               `json:"cmd"`
	CronLine        string               `json:"cron_line"`
	PlanExecTime    time.Time            `json:"-"`
	CronExpression  *cronexpr.Expression `json:"-"`
	Status          int                  `json:"-"`
	NodeID          string               `json:"-"`
	IP              string               `json:"-"`
	ActualStartTime time.Time            `json:"-"`
	ActualEndTime   time.Time            `json:"-"`
	Result          []byte               `json:"-"`
}

Task struct {"name":"task1", "cmd":"echo hello;", "cron_line":"*/5 * * * * * *"}`

func New

func New() *Task

New returns task

func (*Task) Exec

func (t *Task) Exec(ctx ctx.Context) (err error)

Exec task

func (*Task) Save

func (t *Task) Save()

Save task

type Tasks

type Tasks interface {
	heap.Interface
	Remove(name string)
	Top() interface{}
}

Tasks is app cached task data

func NewTasks

func NewTasks() Tasks

NewTasks returns Tasks instance

Jump to

Keyboard shortcuts

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