crond

package module
v0.0.0-...-e7c7069 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CronTask

type CronTask interface {
	Signature() string // Signature 定时任务名称,即赋予定时任务的一个名称便于日志里识别
	Rule() string      // CronRule  定时规则:`Second | Minute | Hour | Dom (day of month) | Month | Dow (day of week)`
	Execute() error    // Execute   执行入口,返回nil执行成功,返回error或发生panic执行失败
}

CronTask 定时任务类契约

type Crontab

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

Crontab 定时任务实现

func New

func New(logger *zap.Logger) *Crontab

New 实例化crontab实例

func (*Crontab) Register

func (c *Crontab) Register(task CronTask)

Register 注册定时任务类

  • @param spec string 定时规则:`Second | Minute | Hour | Dom (day of month) | Month | Dow (day of week)`
  • @param task CronTask 任务类需实现命令契约,并且传递结构体实例的指针

func (*Crontab) Shutdown

func (c *Crontab) Shutdown()

Shutdown 优雅停止定时任务守护进程

func (*Crontab) Start

func (c *Crontab) Start()

Start 启动定时任务守护进程

Jump to

Keyboard shortcuts

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