cron_tool

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OneOffCron   *cron.Cron
	PeriodicCron *cron.Cron
)

Functions

func AddOneOffTask

func AddOneOffTask(executionTime time.Time, taskFunc func()) (entryID int)

提供任务将在未来执行的时间、任务function,添加至一次性计划任务队列

func CleanUpCompletedOneOffTasks

func CleanUpCompletedOneOffTasks()

清理已完成的一次性计划任务

func GetOneOffEntryNextExcTime

func GetOneOffEntryNextExcTime(entryID int) time.Time

根据entry_id取出这个entry,返回这个entry的下次执行时间。由于是个一次性任务,如果返回值是零值time.Time{},则说明已经完成。 Next time the job will run, or the zero time if Cron has not been started or this entry's schedule is unsatisfiable

func InitOneOffCron

func InitOneOffCron()

创建一次性任务的队列,并开始运行。

func InitPeriodicCron

func InitPeriodicCron()

创建周期性任务,并开始运行。

func RemoveOneOffEntry

func RemoveOneOffEntry(entryID int)

清除一个一次性计划任务

Types

type OneOffScheduler

type OneOffScheduler struct {
	At time.Time // 在什么时间运行
}

https://stackoverflow.com/questions/45942266/is-there-a-way-to-invoke-a-cron-job-on-a-certain-date-time 一次性任务的Schedule

func (*OneOffScheduler) Next

func (ss *OneOffScheduler) Next(t time.Time) time.Time

返回在时间t之后的下一次执行时间 Next returns the next activation time, later than the given time. Next is invoked initially, and then each time the job is run.

Jump to

Keyboard shortcuts

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