Documentation ¶
Index ¶
Constants ¶
View Source
const ( SchedulerIdle = iota SchedulerRunning SchedulerShutdown SchedulerStopped )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ITimer ¶
type ITimer interface { Init(...Option) error // Start the scheduler manager and initialize it according to the preset configuration Start() error // IsRunning will return the status of scheduler IsRunning() bool // Tick main loop Tick() // AddTimer will add a scheduled task that is executed periodically and stops immediately if an error occurs during execution AddTimer(TimerFunc, time.Duration, ...TaskOption) (TimerHandler, error) // AddTimerOnce will add a scheduled task that triggers execution at a specified time. AddTimerOnce(TimerFunc, time.Duration, ...TaskOption) (TimerHandler, error) //AddTimerWithCount will add a scheduled task and execute it periodically at the specified interval. //When a specified number of times is reached or an error occurs, the task is stopped AddTimerWithCount(TimerFunc, time.Duration, int, ...TaskOption) (TimerHandler, error) // Corn will set a scheduled task to be automatically executed at a specified time // which follows https://en.wikipedia.org/wiki/Cron Corn(TimerFunc, string, ...TaskOption) (TimerHandler, error) // CancelTimer will stop a scheduled task CancelTimer(TimerHandler) error // Count will return the number of tasks on the timer Count() int // Shutdown will stop all tasks, and remove them from scheduler Shutdown() error }
func NewScheduler ¶
type Options ¶
type Options struct { Location *time.Location `yaml:"location"` // 定时器时区, MaxConcurrentJobs int `yaml:"max_concurrent_jobs"` // 最大定时任务数量 }
Options is the scheduler config
func NewOptions ¶
func NewOptions() *Options
type TaskOption ¶
type TaskOption func(options *TaskOptions)
TaskOption 定时任务配置修改函数原型
func WithCountTask ¶
func WithCountTask(count int) TaskOption
func WithImmediatelyTask ¶
func WithImmediatelyTask(immediately bool) TaskOption
func WithSingleModeTask ¶
func WithSingleModeTask(singleMode int) TaskOption
func WithTagTask ¶
func WithTagTask(tag string) TaskOption
type TaskOptions ¶
type TaskOptions struct {
// contains filtered or unexported fields
}
TaskOptions 定时任务配置
func NewTaskOptions ¶
func NewTaskOptions() *TaskOptions
type TimerHandleGenerator ¶
type TimerHandleGenerator struct {
// contains filtered or unexported fields
}
func (*TimerHandleGenerator) Init ¶
func (t *TimerHandleGenerator) Init() error
func (*TimerHandleGenerator) Next ¶
func (t *TimerHandleGenerator) Next() TimerHandler
Next 产生进程内唯一id, 算法:当前秒数的时间戳 + 一秒内调用次数
type TimerHandler ¶
type TimerHandler uint64 // 定时器句柄
Click to show internal directories.
Click to hide internal directories.