crontab

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJobBlocked = errors.New("job is blocked")
	BlockedLimit  = 2 * time.Second
)

Functions

func DataStats

func DataStats() *jsongen.Map

func IsRealBlocked

func IsRealBlocked() error

IsRealBlocked 场景: 任务设置了立即执行, 00:59.999 刚开始执行, 下次执行时间 01:00 跟着就到了, 再次启动了任务, 但没抢到锁, 忽略该次 Blocked

func Runtime

func Runtime() error

Runtime 重新加载配置时运行

func Start

func Start() error

Start 程序启动时初始化

func Stop

func Stop() error

Stop 程序退出时运行

func StopJob

func StopJob(name string) bool

StopJob 通过名称停止任务

Types

type Job

type Job struct {
	// contains filtered or unexported fields
}

func AddJob

func AddJob(ctx context.Context, name, spec string, runner Runner, opts ...cron.EntryOption) (*Job, error)

AddJob 添加任务

func GetJob

func GetJob(name string) (*Job, bool)

GetJob 通过名称获取任务对象

func (*Job) IsRunning

func (j *Job) IsRunning() bool

func (*Job) Name

func (j *Job) Name() string

func (*Job) Next

func (j *Job) Next() time.Time

func (*Job) Prev

func (j *Job) Prev() time.Time

func (*Job) Stop

func (j *Job) Stop()

type Runner

type Runner interface {
	Run(ctx context.Context) error
}

Jump to

Keyboard shortcuts

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