Documentation ¶
Index ¶
- type TimerService
- func (t *TimerService) AddOneshotTimer(datatime time.Time, handlerName string, args interface{}) (int, error)
- func (t *TimerService) AddTimer(interval time.Duration, isRepeate bool, handlerName string, args interface{}) (int, error)
- func (t *TimerService) AsyncRun()
- func (t *TimerService) DelTimer(seq int)
- func (t *TimerService) Register(svr interface{}) error
- func (t *TimerService) Run()
- func (t *TimerService) SetAccuracy(accuracy time.Duration) error
- func (t *TimerService) StopTimerService()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TimerService ¶
type TimerService struct {
// contains filtered or unexported fields
}
TimerService is timer manager, It can be used independently or as a module of the service
func (*TimerService) AddOneshotTimer ¶
func (t *TimerService) AddOneshotTimer(datatime time.Time, handlerName string, args interface{}) (int, error)
AddOneshotTimer will add a timer that trigger once at specified time. It wrap AddTimer.
func (*TimerService) AddTimer ¶
func (t *TimerService) AddTimer(interval time.Duration, isRepeate bool, handlerName string, args interface{}) (int, error)
AddTimer can add a timer that trigger from now until interval. If you want the timer trigger repeate, you could set isRepeate true. It is a blocking function that waiting timer's sequence
func (*TimerService) AsyncRun ¶
func (t *TimerService) AsyncRun()
AsyncRun function asynchronous execution timer service.
func (*TimerService) DelTimer ¶
func (t *TimerService) DelTimer(seq int)
DelTimer send a sequence of deleting timer to timer goroutine. The seq will push to a slice waiting for delete.
func (*TimerService) Register ¶
func (t *TimerService) Register(svr interface{}) error
Register add handler from type method to timer. The name of the handler must be unique
func (*TimerService) Run ¶
func (t *TimerService) Run()
Run function synchronous execution timer service.
func (*TimerService) SetAccuracy ¶
func (t *TimerService) SetAccuracy(accuracy time.Duration) error
SetAccuracy can change the accuracy of the timer. default accuracy is 100 Millisecond. It is only valid before run timer.
func (*TimerService) StopTimerService ¶
func (t *TimerService) StopTimerService()
You can stop the timer service.