Documentation ¶
Overview ¶
Package ticker implements a cron task schedule tool wrappered from the go timer sdk
Index ¶
- type GlobalTicker
- func (gt *GlobalTicker) ClearRoutines()
- func (gt *GlobalTicker) RegisterOneTimeRoutine(name string, routine RoutineFunc, delay uint32)
- func (gt *GlobalTicker) RegisterPeriodicRoutine(name string, routine RoutineFunc, interval uint32)
- func (gt *GlobalTicker) RemoveRoutine(name string)
- func (gt *GlobalTicker) StartAndTriggerRoutine(name string)
- func (gt *GlobalTicker) StartTickerRoutine(name string, triggerNextTicker bool)
- func (gt *GlobalTicker) StopTickerRoutine(name string)
- type RoutineFunc
- type TickerRoutine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GlobalTicker ¶
type GlobalTicker struct {
// contains filtered or unexported fields
}
GlobalTicker is the schedule tool structure
func NewGlobalTicker ¶
func NewGlobalTicker(id string) *GlobalTicker
func (*GlobalTicker) ClearRoutines ¶
func (gt *GlobalTicker) ClearRoutines()
func (*GlobalTicker) RegisterOneTimeRoutine ¶
func (gt *GlobalTicker) RegisterOneTimeRoutine(name string, routine RoutineFunc, delay uint32)
RegisterOneTimeRoutine registers a specified once-task to the scheduler instance. It will be executed after the given heartbeats (in seconds) denoted by delay
func (*GlobalTicker) RegisterPeriodicRoutine ¶
func (gt *GlobalTicker) RegisterPeriodicRoutine(name string, routine RoutineFunc, interval uint32)
RegisterPeriodicRoutine registers a specified periodic task to the scheduler instance. The task denoted by the routine param will be executed every interval heartbeats (in seconds)
func (*GlobalTicker) RemoveRoutine ¶
func (gt *GlobalTicker) RemoveRoutine(name string)
func (*GlobalTicker) StartAndTriggerRoutine ¶
func (gt *GlobalTicker) StartAndTriggerRoutine(name string)
StartAndTriggerRoutine starts the specified routine. Note that, the task won't work if this function wasn't called after registered
func (*GlobalTicker) StartTickerRoutine ¶
func (gt *GlobalTicker) StartTickerRoutine(name string, triggerNextTicker bool)
StartTickerRoutine starts the specified routine. Note that, the task won't work if this function wasn't called after registered
func (*GlobalTicker) StopTickerRoutine ¶
func (gt *GlobalTicker) StopTickerRoutine(name string)
StopTickerRoutine stops the specified task
type RoutineFunc ¶
type RoutineFunc func() bool
RoutineFunc is the routine function which will be called at specified moment
type TickerRoutine ¶
type TickerRoutine struct {
// contains filtered or unexported fields
}
TickerRoutine define the infos of the scheduled task