crontask

package
v0.0.0-...-8b65dd2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChanMap map[string]chan interface{} = make(map[string]chan interface{})

定时任务管道

View Source
var CronTask *cron.Cron = cron.New()

定时任务管理实例

Functions

func RangeRand

func RangeRand(min, max int64) int64

生成区间[-m, n]的安全随机数

func RecoverTaskRun

func RecoverTaskRun(taskName string, ctx context.Context)

定时任务运行异常,捕获异常后,需要释放该任务的任务管道

func RegisterTask

func RegisterTask(taskTime string, job cron.Job, flag bool)

*注册定时任务

taskTime:定时任务的周期
     job:具体的定时任务对象
      ch:job任务中的定时管道
    flag:是否随系统启动时,执行一次该任务

*

func StartTask

func StartTask(task TaskInterface, period time.Duration, flag bool)

********************参数含义***************

task:定时任务结构体
period:定时周期的单位:秒
flag:是否在系统启动前启动定时任务

******************************************

func TaskStart

func TaskStart()

*

启动定时任务

*

Types

type TaskInterface

type TaskInterface interface {
	Run()
}

定时任务接口

Jump to

Keyboard shortcuts

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