Documentation
¶
Overview ¶
Package gcron implements a cron pattern parser and job runner.
定时任务.
Index ¶
- Constants
- func DelayAdd(delay time.Duration, pattern string, job func(), name ...string)
- func DelayAddOnce(delay time.Duration, pattern string, job func(), name ...string)
- func DelayAddSingleton(delay time.Duration, pattern string, job func(), name ...string)
- func DelayAddTimes(delay time.Duration, pattern string, times int, job func(), name ...string)
- func Remove(name string)
- func Size() int
- func Start(name string)
- func Stop(name string)
- type Cron
- func (c *Cron) Add(pattern string, job func(), name ...string) (*Entry, error)
- func (c *Cron) AddOnce(pattern string, job func(), name ...string) (*Entry, error)
- func (c *Cron) AddSingleton(pattern string, job func(), name ...string) (*Entry, error)
- func (c *Cron) AddTimes(pattern string, times int, job func(), name ...string) (*Entry, error)
- func (c *Cron) Close()
- func (c *Cron) DelayAdd(delay time.Duration, pattern string, job func(), name ...string)
- func (c *Cron) DelayAddOnce(delay time.Duration, pattern string, job func(), name ...string)
- func (c *Cron) DelayAddSingleton(delay time.Duration, pattern string, job func(), name ...string)
- func (c *Cron) DelayAddTimes(delay time.Duration, pattern string, times int, job func(), name ...string)
- func (c *Cron) Entries() []*Entry
- func (c *Cron) Remove(name string)
- func (c *Cron) Search(name string) *Entry
- func (c *Cron) Size() int
- func (c *Cron) Start(name ...string)
- func (c *Cron) Stop(name ...string)
- type Entry
- func Add(pattern string, job func(), name ...string) (*Entry, error)
- func AddOnce(pattern string, job func(), name ...string) (*Entry, error)
- func AddSingleton(pattern string, job func(), name ...string) (*Entry, error)
- func AddTimes(pattern string, times int, job func(), name ...string) (*Entry, error)
- func Entries() []*Entry
- func Search(name string) *Entry
Examples ¶
Constants ¶
View Source
const ( STATUS_READY = gtimer.STATUS_READY STATUS_RUNNING = gtimer.STATUS_RUNNING STATUS_STOPPED = gtimer.STATUS_STOPPED STATUS_CLOSED = gtimer.STATUS_CLOSED )
Variables ¶
This section is empty.
Functions ¶
func DelayAddOnce ¶ added in v1.4.6
延迟添加只运行一次的定时任务,delay参数单位为秒
func DelayAddSingleton ¶ added in v1.4.6
延迟添加单例定时任务,delay参数单位为秒
func DelayAddTimes ¶ added in v1.4.6
延迟添加运行指定次数的定时任务,delay参数单位为秒
Types ¶
type Cron ¶ added in v1.1.994
type Cron struct {
// contains filtered or unexported fields
}
定时任务管理对象
func (*Cron) AddSingleton ¶ added in v1.4.6
添加单例运行定时任务
Example ¶
package main import ( "gitee.com/johng/gf/g/os/gcron" "gitee.com/johng/gf/g/os/glog" "time" ) func main() { gcron.AddSingleton("* * * * * *", func() { glog.Println("doing") time.Sleep(2 * time.Second) }) select {} }
Output:
func (*Cron) DelayAddOnce ¶ added in v1.4.6
延迟添加运行指定次数的定时任务
func (*Cron) DelayAddSingleton ¶ added in v1.4.6
延迟添加单例定时任务
func (*Cron) DelayAddTimes ¶ added in v1.4.6
func (c *Cron) DelayAddTimes(delay time.Duration, pattern string, times int, job func(), name ...string)
延迟添加只运行一次的定时任务
type Entry ¶
type Entry struct { Name string // 定时任务名称 Job func() // 注册定时任务方法 Time time.Time // 注册时间 // contains filtered or unexported fields }
定时任务项
func AddSingleton ¶ added in v1.4.6
添加单例运行定时任务
Click to show internal directories.
Click to hide internal directories.