jobs

package
v0.0.0-...-cfb18d5 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddJob

func AddJob(job Job) (int, error)

添加任务 AddJob(invokeTarget string, jobId int, jobName string, cronExpression string)

func Remove

func Remove(entryID int) chan struct{}

移除任务

func Startup

func Startup()

初始化

Types

type Base

type Base struct {
	JobId          uint   // 数据库id
	EntryId        int    // cron id
	Name           string // 名称
	InvokeTarget   string // 调用目标名
	CronExpression string // cron linux表达式
	Args           string // 回调参数
}

Base base job

func (*Base) Expression

func (b *Base) Expression() string

Expression implement Job interface

func (*Base) Run

func (*Base) Run()

Run implement Job interface

func (*Base) SetEntryId

func (b *Base) SetEntryId(id int)

SetEntryId implement Job interface

type ExamplesOne

type ExamplesOne struct{}

新添加的job 必须按照以下格式定义,并实现Exec函数

func (ExamplesOne) Exec

func (ExamplesOne) Exec(arg interface{}) error

type ExecJob

type ExecJob struct {
	Base
}

ExecJob exec job

func (*ExecJob) Run

func (e *ExecJob) Run()

type HttpJob

type HttpJob struct {
	Base
}

HttpJob http job

func (*HttpJob) Run

func (h *HttpJob) Run()

http 任务接口

type Job

type Job interface {
	Expression() string
	Run()
	SetEntryId(id int)
}

func Convert

func Convert(item models.Job) Job

type JobExec

type JobExec interface {
	Exec(arg interface{}) error
}

Jump to

Keyboard shortcuts

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