Documentation
¶
Index ¶
- Constants
- type ExceptionHandleFunc
- type ExpressSet
- type Timer
- type TimerContext
- type TimerHandleFunc
- type TimerInfo
- type TimerService
- func (service *TimerService) AddTask(t Timer)
- func (ts *TimerService) NewTickTask(taskID string, isRun bool, dueTime int64, interval int64, ...) (Timer, error)
- func (service *TimerService) RemoveTask(taskID string)
- func (ts *TimerService) SetExceptionHandler(handler ExceptionHandleFunc)
- func (ts *TimerService) SetOnBeforeHandler(handler TimerHandleFunc)
- func (ts *TimerService) SetOnEndHandler(handler TimerHandleFunc)
- func (ts *TimerService) StartAllTask()
- func (ts *TimerService) StartTask(taskID string)
- func (ts *TimerService) Stop(name string) error
- func (ts *TimerService) StopAllTask()
- func (ts *TimerService) StopTask(taskID string)
- type TimerTask
Constants ¶
View Source
const ( Timer_state_init = "ts_init" Timer_state_run = "ts_run" Timer_state_stop = "ts_stop" )
View Source
const ( Timer_type_tick = "tt_tick" Timer_type_cron = "tt_cron" )
View Source
const ( Max_WeekDay = 7 //max weekday value Min_WeekDay = 0 //min weekday value Max_Month = 12 //max month value Min_Month = 1 //min month value Max_Day = 31 //max day value Min_Day = 1 //min day value Max_Hour = 23 //max hour value Min_Hour = 0 //min hour value Max_Minute = 59 //max minute value Min_Minute = 0 //min minute value Max_Second = 59 //max second value Min_Second = 0 //min second value )
View Source
const ( ExpressType_WeekDay = "weekday" ExpressType_Month = "month" ExpressType_Day = "day" ExpressType_Hour = "hour" ExpressType_Minute = "minute" ExpressType_Second = "second" )
View Source
const (
DefaultPeriod = time.Second //默认执行周期
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExceptionHandleFunc ¶
type ExceptionHandleFunc func(*TimerContext, error)
type ExpressSet ¶
type ExpressSet struct {
// contains filtered or unexported fields
}
type Timer ¶
type Timer interface { TimerID() string Context() *TimerContext SetTimerService(service *TimerService) // contains filtered or unexported methods }
func NewTickTimer ¶
type TimerContext ¶
type TimerHandleFunc ¶
type TimerHandleFunc func(*TimerContext) error
type TimerInfo ¶
type TimerInfo struct { TimeTicker *time.Ticker TaskType string State string DueTime int64 //开始任务的延迟时间(以毫秒为单位),如果<=0则不延迟 // contains filtered or unexported fields }
func (*TimerInfo) Context ¶
func (task *TimerInfo) Context() *TimerContext
func (*TimerInfo) SetTimerService ¶
func (task *TimerInfo) SetTimerService(service *TimerService)
type TimerService ¶
type TimerService struct { ExceptionHandler ExceptionHandleFunc OnBeforeHandler TimerHandleFunc OnEndHandler TimerHandleFunc // contains filtered or unexported fields }
func Init ¶
func Init() *TimerService
func (*TimerService) AddTask ¶
func (service *TimerService) AddTask(t Timer)
func (*TimerService) NewTickTask ¶
func (ts *TimerService) NewTickTask(taskID string, isRun bool, dueTime int64, interval int64, handler TimerHandleFunc, taskData interface{}) (Timer, error)
func (*TimerService) RemoveTask ¶
func (service *TimerService) RemoveTask(taskID string)
func (*TimerService) SetExceptionHandler ¶
func (ts *TimerService) SetExceptionHandler(handler ExceptionHandleFunc)
设置自定义异常处理方法
func (*TimerService) SetOnBeforeHandler ¶
func (ts *TimerService) SetOnBeforeHandler(handler TimerHandleFunc)
func (*TimerService) SetOnEndHandler ¶
func (ts *TimerService) SetOnEndHandler(handler TimerHandleFunc)
func (*TimerService) StartAllTask ¶
func (ts *TimerService) StartAllTask()
func (*TimerService) StartTask ¶
func (ts *TimerService) StartTask(taskID string)
func (*TimerService) Stop ¶
func (ts *TimerService) Stop(name string) error
func (*TimerService) StopAllTask ¶
func (ts *TimerService) StopAllTask()
func (*TimerService) StopTask ¶
func (ts *TimerService) StopTask(taskID string)
Click to show internal directories.
Click to hide internal directories.