Documentation ¶
Overview ¶
Example (CronAddSingleton) ¶
package main import ( "github.com/osgochina/donkeygo/os/dcron" "github.com/osgochina/donkeygo/os/dlog" "time" ) func main() { dcron.AddSingleton("* * * * * *", func() { dlog.Println("doing") time.Sleep(2 * time.Second) }) select {} }
Output:
Index ¶
- Constants
- func CronPlan(pattern string, t time.Time, queryTimes ...int) ([]time.Time, error)
- 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 (that *Cron) Add(pattern string, job func(), name ...string) (*Entry, error)
- func (that *Cron) AddOnce(pattern string, job func(), name ...string) (*Entry, error)
- func (that *Cron) AddSingleton(pattern string, job func(), name ...string) (*Entry, error)
- func (that *Cron) AddTimes(pattern string, times int, job func(), name ...string) (*Entry, error)
- func (that *Cron) Close()
- func (that *Cron) DelayAdd(delay time.Duration, pattern string, job func(), name ...string)
- func (that *Cron) DelayAddOnce(delay time.Duration, pattern string, job func(), name ...string)
- func (that *Cron) DelayAddSingleton(delay time.Duration, pattern string, job func(), name ...string)
- func (that *Cron) DelayAddTimes(delay time.Duration, pattern string, times int, job func(), name ...string)
- func (that *Cron) Entries() []*Entry
- func (that *Cron) GetLogLevel() int
- func (that *Cron) GetLogPath() string
- func (that *Cron) Remove(name string)
- func (that *Cron) Search(name string) *Entry
- func (that *Cron) SetLogLevel(level int)
- func (that *Cron) SetLogPath(path string)
- func (that *Cron) Size() int
- func (that *Cron) Start(name ...string)
- func (that *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
- func (that *Entry) Close()
- func (that *Entry) IsSingleton() bool
- func (that *Entry) Next(t time.Time, queryTimes ...int) ([]time.Time, error)
- func (that *Entry) SetSingleton(enabled bool)
- func (that *Entry) SetStatus(status int) int
- func (that *Entry) SetTimes(times int)
- func (that *Entry) Start()
- func (that *Entry) Status() int
- func (that *Entry) Stop()
Examples ¶
Constants ¶
View Source
const ( StatusReady = dtimer.StatusReady //已就绪 StatusRunning = dtimer.StatusRunning // 运行中 StatusStopped = dtimer.StatusStopped //已停止 StatusClosed = dtimer.StatusClosed // 已关闭 )
Variables ¶
This section is empty.
Functions ¶
func DelayAddOnce ¶
DelayAddOnce 添加一个指定延迟时间,在解析规则,只运行一次的定时任务
func DelayAddSingleton ¶
DelayAddSingleton 添加指定延迟时间,再解析规则,并且运行时候有并发限制的的任务
func DelayAddTimes ¶
DelayAddTimes 添加一个指定延迟时间,再解析定时规则,并且运行指定运行次数的定时任务。
Types ¶
type Cron ¶
type Cron struct {
// contains filtered or unexported fields
}
func (*Cron) AddSingleton ¶
AddSingleton 添加单例模式的定时任务
func (*Cron) DelayAddOnce ¶
DelayAddOnce 延迟添加执行一次的定时任务
func (*Cron) DelayAddSingleton ¶
func (that *Cron) DelayAddSingleton(delay time.Duration, pattern string, job func(), name ...string)
DelayAddSingleton 延迟添加单例模式的定时任务
type Entry ¶
type Entry struct { Name string // 任务的自定义名字 Job func() //任务处理方法地址 Time time.Time // 任务建立时间 // contains filtered or unexported fields }
Entry 定时任务条目
func AddSingleton ¶
AddSingleton 添加一个并发限制的定时任务到处理器
Click to show internal directories.
Click to hide internal directories.