代码拉取完成,页面将自动刷新
package scheduler
import "time"
type (
// Option 定时器配置修改函数原型
Option func(options *Options)
// TaskOption 定时任务配置修改函数原型
TaskOption func(options *TaskOptions)
// Options is the scheduler config
Options struct {
Location *time.Location `yaml:"location"` // 定时器时区,
MaxConcurrentJobs int `yaml:"max_concurrent_jobs"` // 最大定时任务数量
}
// TaskOptions 定时任务配置
TaskOptions struct {
// immediately 被设置会立刻执行一次task,而非等到任务被调度
immediately bool
// count 设置任务执行次数, 默认无限循环任务
count int
// singleMode 会等待前一个任务执行结束后才会执行,独占调度器, 默认关闭
singleMode int
// tag 任务标签,用于批量查找和批量删除一类任务
tag string
// interval 设置任务执行间隔,默认1s
interval time.Duration
}
)
func NewTaskOptions() *TaskOptions {
return &TaskOptions{
immediately: false,
count: -1,
singleMode: 0,
tag: "",
}
}
func NewOptions() *Options {
return &Options{
Location: time.UTC,
}
}
func WithMaxJobCount(count int) Option {
return func(options *Options) {
options.MaxConcurrentJobs = count
}
}
func WithImmediatelyTask(immediately bool) TaskOption {
return func(options *TaskOptions) {
options.immediately = immediately
}
}
func WithCountTask(count int) TaskOption {
return func(options *TaskOptions) {
options.count = count
}
}
func WithSingleModeTask(singleMode int) TaskOption {
return func(options *TaskOptions) {
options.singleMode = singleMode
}
}
func WithTagTask(tag string) TaskOption {
return func(options *TaskOptions) {
options.tag = tag
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。