timer

package
v0.0.0-...-3363d21 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Timer

type Timer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Timer 定时任务管理

func NewTimer

func NewTimer() *Timer

func (*Timer) AddTaskByFunc

func (t *Timer) AddTaskByFunc(taskName string, spec string, task func()) (cron.EntryID, error)

AddTaskByFunc 通过函数的方法添加任务

func (*Timer) AddTaskByJob

func (t *Timer) AddTaskByJob(taskName string, spec string, job interface{ Run() }) (cron.EntryID, error)

AddTaskByJob 通过接口的方法添加任务

func (*Timer) Clear

func (t *Timer) Clear(taskName string)

Clear 清除任务

func (*Timer) Close

func (t *Timer) Close()

Close 释放资源

func (*Timer) FindCron

func (t *Timer) FindCron(taskName string) (*cron.Cron, bool)

FindCron 获取对应taskName的cron 可能会为空

func (*Timer) Remove

func (t *Timer) Remove(taskName string, id int)

Remove 从taskName 删除指定任务

func (*Timer) StartTask

func (t *Timer) StartTask(taskName string)

StartTask 开始任务

func (*Timer) StopTask

func (t *Timer) StopTask(taskName string)

StopTask 停止任务

Jump to

Keyboard shortcuts

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