cron_line

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CronDispatch

type CronDispatch struct {
	ScheduleTable map[string]*CronJob // 停止消息
	// contains filtered or unexported fields
}

CronDispatch 定时任务调度器

func CronDis

func CronDis() (c *CronDispatch)

CronDis 实例化一个任务调度对象

func (*CronDispatch) AddCron

func (c *CronDispatch) AddCron(job jobFunc, args ...interface{}) string

AddCron 添加定时任务

func (*CronDispatch) Clear

func (c *CronDispatch) Clear(jobid string)

Clear 删除任务

func (*CronDispatch) ClearAll

func (c *CronDispatch) ClearAll()

ClearAll 删除所有任务

func (*CronDispatch) Start

func (c *CronDispatch) Start()

Start 启动定时任务计划功能

func (*CronDispatch) StartCron

func (c *CronDispatch) StartCron(jobid string)

StartCron 启用定时任务

func (*CronDispatch) Stop

func (c *CronDispatch) Stop(jobid string)

Stop 停止任务

func (*CronDispatch) StopAll

func (c *CronDispatch) StopAll()

StopAll 停用所有任务

type CronJob

type CronJob struct {
	JobID     string               // 任务ID 由sha 哈希生成
	ExprStr   string               // 任务表达式字符串
	Expr      *cronexpr.Expression // 解析表达式
	NextTime  time.Time            // expr.Next(now) 下一次执行的时间
	LastTime  time.Time            // 上一次执行时间
	JobFunc   jobFunc              // 需要执行的方法
	Type      int                  // 任务类型 0 方法, 1 脚本
	Status    int                  // 状态 1 启用 0 停用
	Disable   chan struct{}        // 停用信号量
	Enabled   bool                 // 启用状态
	ScriptTyp int                  // 脚本类型  0 数据库脚本 1 shell 脚本 2 其他
	Script    string               // 脚本
	// contains filtered or unexported fields
}

CronJob 代表一个任务

func (CronJob) Run

func (c CronJob) Run()

func (*CronJob) Stop

func (c *CronJob) Stop()

Stop 修改状态为停用

type CronQueue

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

func CQNew

func CQNew() *CronQueue

func (*CronQueue) Clear

func (q *CronQueue) Clear()

清空队列

func (CronQueue) Find

func (q CronQueue) Find(num int) (c CronJob)

func (CronQueue) First

func (q CronQueue) First() (c CronJob)

获取队列第一个 不出栈

func (*CronQueue) Last

func (q *CronQueue) Last() (c CronJob)

获取最后一个 不出栈

func (*CronQueue) Pop

func (q *CronQueue) Pop() CronJob

出栈

func (*CronQueue) Push

func (q *CronQueue) Push(c CronJob)

入栈

func (CronQueue) Size

func (q CronQueue) Size() int

队列长度

Jump to

Keyboard shortcuts

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