Documentation
¶
Index ¶
Constants ¶
View Source
const (
// LoopForever is a constant indicating that timer should loop forever
LoopForever = -1
)
Variables ¶
View Source
var ( // Manager manager for all Timers Manager = &struct { incrementID int64 // auto increment id timers sync.Map // all Timers ChClosingTimer chan int64 // timer for closing ChCreatedTimer chan *Timer }{} // Precision indicates the precision of timer, default is time.Second Precision = time.Second // GlobalTicker represents global ticker that all cron job will be executed // in globalTicker. GlobalTicker *time.Ticker )
Functions ¶
func Cron ¶
func Cron()
Cron executes scheduled tasks TODO: if closing Timers'count in single cron call more than timerBacklog will case problem.
func RegisterComponent ¶ added in v1.1.24
func RegisterComponent()
func SetTimerBacklog ¶
func SetTimerBacklog(c int)
SetTimerBacklog set the timer created/closing channel backlog, A small backlog may cause the logic to be blocked when call NewTimer/NewCountTimer/timer.OnStop in main logic gorontine.
Types ¶
type Component ¶
type Component struct {
cherryFacade.Component
// contains filtered or unexported fields
}
func NewComponent ¶
func NewComponent() *Component
func (*Component) OnBeforeStop ¶
func (p *Component) OnBeforeStop()
type Func ¶
type Func func()
Func represents a function which will be called periodically in main logic goroutine.
type Timer ¶
type Timer struct {
ID int64 // timer id
// contains filtered or unexported fields
}
Timer represents a cron job
func NewCounterTimer ¶
NewCounterTimer creates a cron job
func NewEveryDayTimer ¶
NewEveryDayTimer 每天的x分x秒执行一次(每天1次)
func NewEveryHourTimer ¶
NewEveryHourTimer 每小时的x分x秒执行一次(每天24次)
func (*Timer) SetCondition ¶
SetCondition sets the condition used for verifying when the cron job should run
Click to show internal directories.
Click to hide internal directories.