Documentation ¶
Overview ¶
定时器,为了方便后续统一维护和二次扩展,故此将所有的方法重新二次封装一遍
Index ¶
- func DefaultOptions() gtimer.TimerOptions
- func DelayAdd(ctx context.Context, delay time.Duration, interval time.Duration, job JobFunc)
- func DelayAddEntry(ctx context.Context, delay time.Duration, interval time.Duration, job JobFunc, ...)
- func DelayAddOnce(ctx context.Context, delay time.Duration, interval time.Duration, job JobFunc)
- func DelayAddSingleton(ctx context.Context, delay time.Duration, interval time.Duration, job JobFunc)
- func DelayAddTimes(ctx context.Context, delay time.Duration, interval time.Duration, times int, ...)
- func SetInterval(ctx context.Context, interval time.Duration, job JobFunc)
- func SetTimeout(ctx context.Context, delay time.Duration, job JobFunc)
- type Entry
- func Add(ctx context.Context, interval time.Duration, job JobFunc) Entry
- func AddEntry(ctx context.Context, interval time.Duration, job JobFunc, isSingleton bool, ...) Entry
- func AddOnce(ctx context.Context, interval time.Duration, job JobFunc) Entry
- func AddSingleton(ctx context.Context, interval time.Duration, job JobFunc) Entry
- func AddTimes(ctx context.Context, interval time.Duration, times int, job JobFunc) Entry
- type JobFunc
- type Timer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultOptions ¶
func DefaultOptions() gtimer.TimerOptions
DefaultOptions creates and returns a default options object for Timer creation.
func DelayAddEntry ¶
func DelayAddEntry(ctx context.Context, delay time.Duration, interval time.Duration, job JobFunc, isSingleton bool, times int, status int)
DelayAddEntry adds a timing job after delay of `interval` duration. Also see AddEntry.
func DelayAddOnce ¶
DelayAddOnce adds a timing job after delay of `interval` duration. Also see AddOnce.
func DelayAddSingleton ¶
func DelayAddSingleton(ctx context.Context, delay time.Duration, interval time.Duration, job JobFunc)
DelayAddSingleton adds a timing job after delay of `interval` duration. Also see AddSingleton.
func DelayAddTimes ¶
func DelayAddTimes(ctx context.Context, delay time.Duration, interval time.Duration, times int, job JobFunc)
DelayAddTimes adds a timing job after delay of `interval` duration. Also see AddTimes.
func SetInterval ¶
SetInterval runs the job every duration of `delay`. It is like the one in javascript.
Types ¶
type Entry ¶
Entry is the timing job.
func AddEntry ¶
func AddEntry(ctx context.Context, interval time.Duration, job JobFunc, isSingleton bool, times int, status int) Entry
AddEntry adds a timing job to the default timer with detailed parameters.
The parameter `interval` specifies the running interval of the job.
The parameter `singleton` specifies whether the job running in singleton mode. There's only one of the same job is allowed running when its a singleton mode job.
The parameter `times` specifies limit for the job running times, which means the job exits if its run times exceeds the `times`.
The parameter `status` specifies the job status when it's firstly added to the timer.
func AddOnce ¶
AddOnce is a convenience function for adding a job which only runs once and then exits.
func AddSingleton ¶
AddSingleton is a convenience function for add singleton mode job.