cronjob

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 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 CronJob

type CronJob struct {
	Cron *cron.Cron // 暴露原库 API
}

cron job:

func New

func New() *CronJob

func (*CronJob) RegisterTask

func (m *CronJob) RegisterTask(tasks ...Task) (err error)

注册 task:

func (*CronJob) Run

func (m *CronJob) Run(tasks ...Task)

注册和启动分开, 灵活调用位置

func (*CronJob) RunAsync added in v0.1.8

func (m *CronJob) RunAsync(tasks ...Task)

异步:

func (*CronJob) RunSync added in v0.1.8

func (m *CronJob) RunSync(tasks ...Task)

同步:

func (*CronJob) Stop added in v0.1.8

func (m *CronJob) Stop()

stop:

type Task

type Task struct {
	Name     string
	Schedule string // 执行计划周期: cron 表达式 //
	TaskFunc func() // 任务方法
}

单个任务:

type Tasks

type Tasks struct {
	Task []Task
}

一批任务:

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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