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 GetLogLevel() int
- func GetLogPath() string
- func Remove(name string)
- func SetLogLevel(level int)
- func SetLogPath(path 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) GetLogLevel() int
- func (c *Cron) GetLogPath() string
- func (c *Cron) Remove(name string)
- func (c *Cron) Search(name string) *Entry
- func (c *Cron) SetLogLevel(level int)
- func (c *Cron) SetLogPath(path string)
- 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 ¶
延迟添加只运行一次的定时任务,delay参数单位为秒
func DelayAddSingleton ¶
延迟添加单例定时任务,delay参数单位为秒
func DelayAddTimes ¶
延迟添加运行指定次数的定时任务,delay参数单位为秒
Types ¶
type Cron ¶
type Cron struct {
// contains filtered or unexported fields
}
定时任务管理对象
func (*Cron) AddSingleton ¶
添加单例运行定时任务
Example ¶
package main import ( "github.com/gogf/gf/g/os/gcron" "github.com/gogf/gf/g/os/glog" "time" ) func main() { gcron.AddSingleton("* * * * * *", func() { glog.Println("doing") time.Sleep(2 * time.Second) }) select {} }
Output:
func (*Cron) DelayAddOnce ¶
延迟添加运行指定次数的定时任务
func (*Cron) DelayAddSingleton ¶
延迟添加单例定时任务
type Entry ¶
type Entry struct { Name string // Entry name. Job func() `json:"-"` // Callback function. Time time.Time // Registered time. // contains filtered or unexported fields }
Timed task entry.
func AddSingleton ¶
添加单例运行定时任务
Click to show internal directories.
Click to hide internal directories.