cron

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package cron

Package cron

Package cron

Package cron 定时任务

Package cron

Package cron

Index

Constants

View Source
const (
	Yearly     = "@yearly"
	Annually   = "@annually"
	Monthly    = "@monthly"
	Daily      = "@daily"
	MidNightly = "@midnight"
	Hourly     = "@hourly"
	Weekly     = "@weekly"
	Every      = "@every" // 后面使用秒s 分m 时h
)

Variables

This section is empty.

Functions

func EveryFmt added in v1.0.5

func EveryFmt(t string) string

EveryFmt 每分或每秒 例如1s 例如5m 例如 1h1m

func ModuleName added in v1.0.5

func ModuleName() string

ModuleName 模块名称

Types

type Cron

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

func New added in v1.0.5

func New() *Cron

New 创建支持秒级的定时器

func NewWithOption added in v1.0.5

func NewWithOption(ops ...cron.Option) *Cron

NewWithOption 附加原生cron v3配置

func NewWithRecover added in v1.0.5

func NewWithRecover() *Cron

NewWithRecover 创建带recover的支持秒级的定时器

func (*Cron) AddFunc added in v1.0.5

func (cronJob *Cron) AddFunc(spec string, f func()) (int, error)

AddFunc 添加规则 spec 为标准的cronjob表达式 返回为唯一的定时id和错误

func (*Cron) Cancel added in v1.0.5

func (cronJob *Cron) Cancel(id int)

Cancel 取消指定的任务

func (*Cron) JobSpec added in v1.0.5

func (cronJob *Cron) JobSpec(id int) string

JobSpec 返回指定任务的规则

func (*Cron) Jobs added in v1.0.5

func (cronJob *Cron) Jobs() map[int]string

Jobs 展示当前加入的任务

func (*Cron) Start added in v1.0.5

func (cronJob *Cron) Start()

Start 启动cronJob

func (*Cron) Stop added in v1.0.5

func (cronJob *Cron) Stop()

Stop 停止cronJob

type CronGroup added in v1.0.5

type CronGroup struct {
	Spec string // cronjob规则
	// contains filtered or unexported fields
}

CronGroup 相同定时的任务组

func NewGroup added in v1.0.5

func NewGroup(spec string) *CronGroup

NewGroup 新建一个规则分组

func (*CronGroup) AddFunc added in v1.0.5

func (g *CronGroup) AddFunc(f func()) (int, error)

AddFunc 添加一个定时任务

func (*CronGroup) Cancel added in v1.0.5

func (g *CronGroup) Cancel(id int)

func (*CronGroup) JobSpec added in v1.0.5

func (g *CronGroup) JobSpec() string

func (*CronGroup) JobsCount added in v1.0.5

func (g *CronGroup) JobsCount() int

func (*CronGroup) Start added in v1.0.5

func (g *CronGroup) Start()

func (*CronGroup) Stop added in v1.0.5

func (g *CronGroup) Stop()

type ScheduleJob added in v1.0.6

type ScheduleJob struct {
	ExecTime time.Time // 执行时间
	Name     string    // 可选 任务名称
	// contains filtered or unexported fields
}

func NewSchedule added in v1.0.6

func NewSchedule(t time.Time, f func()) *ScheduleJob

NewSchedule 创建一个计划任务 给定的时间如果在过去或等于现在的时间 不做任何事情

func (*ScheduleJob) IsDone added in v1.0.6

func (s *ScheduleJob) IsDone() bool

IsDone 是否执行完毕

func (*ScheduleJob) IsStart added in v1.0.6

func (s *ScheduleJob) IsStart() bool

IsStart 任务是否启动

func (*ScheduleJob) IsStopped added in v1.0.6

func (s *ScheduleJob) IsStopped() bool

IsStopped 是否停止

func (*ScheduleJob) ReStart added in v1.0.6

func (s *ScheduleJob) ReStart()

ReStart 从停止状态下重新启动

func (*ScheduleJob) SetName added in v1.0.6

func (s *ScheduleJob) SetName(name string)

func (*ScheduleJob) Start added in v1.0.6

func (s *ScheduleJob) Start()

func (*ScheduleJob) Stop added in v1.0.6

func (s *ScheduleJob) Stop()

Jump to

Keyboard shortcuts

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