cron

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crontab

type Crontab struct {
	Scheduler *gocron.Scheduler
}

func NewCrontab

func NewCrontab() *Crontab

NewCrontab 初始化一个定时任务 不支持分布式调度,如果要支持分布式调度,建议使用redis锁配合实现

func (*Crontab) AddTaskFunc

func (c *Crontab) AddTaskFunc(cronName, cronExpression string, func_ interface{}, params ...interface{}) error

AddTaskFunc 1.快速添加一个定时任务

func (*Crontab) AddTaskFuncFree

func (c *Crontab) AddTaskFuncFree(callbacks ...func(scheduler Scheduler))

AddTaskFuncFree 2.自由的添加任务 示例可以参考文档 :https://github.com/go-co-op/gocron

func (*Crontab) Clear

func (c *Crontab) Clear()

Clear 清理所有的任务

func (*Crontab) Len

func (c *Crontab) Len() int

Len 任务长度

func (*Crontab) RemoveJobByTag

func (c *Crontab) RemoveJobByTag(tag string)

RemoveJobByTag 根据标签移除某个任务

func (*Crontab) RunJobByTag

func (c *Crontab) RunJobByTag(tag string)

RunJobByTag 临时运行某个任务(不阻塞)

func (*Crontab) StartAsync

func (c *Crontab) StartAsync()

StartAsync 异步启动 不阻塞当前进程

func (*Crontab) StartBlocking

func (c *Crontab) StartBlocking()

StartBlocking 同步启动

func (*Crontab) Stop

func (c *Crontab) Stop()

Stop 停止任务, 等待所有任务执行完毕后才会停止

type Scheduler

type Scheduler = *gocron.Scheduler

Jump to

Keyboard shortcuts

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