Documentation ¶
Overview ¶
定时任务,为了方便后续统一维护和二次扩展,故此将所有的方法重新二次封装一遍
Index ¶
- func DelayAdd(ctx context.Context, delay time.Duration, pattern string, job JobFunc, ...)
- func DelayAddOnce(ctx context.Context, delay time.Duration, pattern string, job JobFunc, ...)
- func DelayAddSingleton(ctx context.Context, delay time.Duration, pattern string, job JobFunc, ...)
- func DelayAddTimes(ctx context.Context, delay time.Duration, pattern string, times int, ...)
- func Remove(name string)
- func Size() int
- func Start(name ...string)
- func Stop(name ...string)
- type Entry
- func Add(ctx context.Context, pattern string, job JobFunc, name ...string) (Entry, error)
- func AddOnce(ctx context.Context, pattern string, job JobFunc, name ...string) (Entry, error)
- func AddSingleton(ctx context.Context, pattern string, job JobFunc, name ...string) (Entry, error)
- func AddTimes(ctx context.Context, pattern string, times int, job JobFunc, name ...string) (Entry, error)
- func Entries() []Entry
- func Search(name string) Entry
- type JobFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DelayAdd ¶
func DelayAdd(ctx context.Context, delay time.Duration, pattern string, job JobFunc, name ...string)
DelayAdd adds a timed task to default cron object after `delay` time.
func DelayAddOnce ¶
func DelayAddOnce(ctx context.Context, delay time.Duration, pattern string, job JobFunc, name ...string)
DelayAddOnce adds a timed task after `delay` time to default cron object. This timed task can be run only once.
func DelayAddSingleton ¶
func DelayAddSingleton(ctx context.Context, delay time.Duration, pattern string, job JobFunc, name ...string)
DelayAddSingleton adds a singleton timed task after `delay` time to default cron object.
func DelayAddTimes ¶
func DelayAddTimes(ctx context.Context, delay time.Duration, pattern string, times int, job JobFunc, name ...string)
DelayAddTimes adds a timed task after `delay` time to default cron object. This timed task can be run specified times.
Types ¶
type Entry ¶
func Add ¶
Add adds a timed task to default cron object. A unique `name` can be bound with the timed task. It returns and error if the `name` is already used.
func AddOnce ¶
AddOnce adds a timed task which can be run only once, to default cron object. A unique `name` can be bound with the timed task. It returns and error if the `name` is already used.
func AddSingleton ¶
AddSingleton adds a singleton timed task, to default cron object. A singleton timed task is that can only be running one single instance at the same time. A unique `name` can be bound with the timed task. It returns and error if the `name` is already used.
func AddTimes ¶
func AddTimes(ctx context.Context, pattern string, times int, job JobFunc, name ...string) (Entry, error)
AddTimes adds a timed task which can be run specified times, to default cron object. A unique `name` can be bound with the timed task. It returns and error if the `name` is already used.