cron

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrHandler

func ErrHandler(job *JobStruct)

func RegisterTask

func RegisterTask(name string, f func(...string) string, cronExpression, concurrent, misfirePolicy string, logFunc func(name, info, state, cost string))

RegisterTask register a task,then run this task with giving cronExpression,concurrent and misfirePolicy. name is the register task name,f is what the task really run,cronExpression is cronExpression like linux crontab, concurrent 0 means the task is concurrent,1 means the task is non-concurrent misfirePolicy 0 means can run interval,1 run only once with cronExpression,2 run immediately only once with non-cronExpression logFunc is a func which will be call no matter task is run successful or failed. the params info is the returning result of f,state 0 means successful,1 means failed

Types

type JobStruct

type JobStruct struct {
	Id             cron.EntryID
	Name           string
	MisfirePolicy  string //0重复执行1执行一次2立即执行一次
	Concurrent     string //0并发执行1不并发执行
	CronExpression string
	F              func(...string) string
	InvokeTarget   string
	Params         []reflect.Value
	Param          []string
	LogFunc        func(name, info, state, cost string) //state 0成功1失败
	JobCron        *cron.Cron
	IsAdd          bool
	// contains filtered or unexported fields
}

func Get

func Get(name string) *JobStruct

Get 根据任务名称获取任务

func Register

func Register(name string, f func(...string) string) JobStruct

func (*JobStruct) Remove

func (job *JobStruct) Remove()

func (*JobStruct) Run

func (job *JobStruct) Run()

func (*JobStruct) Start

func (job *JobStruct) Start() error

func (*JobStruct) Stop

func (job *JobStruct) Stop() error

func (*JobStruct) UpdateParams

func (job *JobStruct) UpdateParams()

Jump to

Keyboard shortcuts

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