Documentation ¶
Index ¶
- func InitPersistence(redisHost string)
- type Job
- type JobModel
- type JobWrap
- type NewJobFunc
- type Scheduler
- func (p *Scheduler) AddJob(duration int64, job Job)
- func (p *Scheduler) DeleteJob(job Job) (ok bool)
- func (p *Scheduler) DeleteThenAddJob(duration int64, job Job) (deleted bool)
- func (p *Scheduler) GetCurrJobWraps() *[]*JobWrap
- func (p *Scheduler) Info() string
- func (p *Scheduler) LoadFormRedis() (err error)
- func (p *Scheduler) Work()
- type SchedulerConfig
- type Task
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitPersistence ¶
func InitPersistence(redisHost string)
Types ¶
type JobModel ¶
type JobModel struct { Id string `orm:"col(id)" json:"id"` RunTime int64 `orm:"col(run_time)" json:"run_time"` Data string `orm:"col(data)" json:"data"` SuccessTime int64 `orm:"col(success_time)" json:"success_time"` FailTime int64 `orm:"col(fail_time)" json:"fail_time"` Error string `orm:"col(error)" json:"error"` // contains filtered or unexported fields }
job mysql 结构体 用于保存成功失败记录
type JobWrap ¶
type JobWrap struct { IdDb string // 入库的ID,唯一标识 Deep int64 // 圈数,一圈1小时 Count int // 第几次运行 RunTime int64 // 运行时间戳,只在持久化时入库出库使用 // contains filtered or unexported fields }
包裹JOB
type NewJobFunc ¶
type NewJobFunc func() Job
type Scheduler ¶
type Scheduler struct { Tasks [3600]*Task `json:"tasks"` // 3600个task 每一秒需要执行一个 CurrIndex int32 `json:"curr_index"` // 当前正在执行哪个task sync.Mutex // 锁全部Task // contains filtered or unexported fields }
func NewScheduler ¶
func NewScheduler(c *SchedulerConfig, newJobFunc NewJobFunc) *Scheduler
func (*Scheduler) DeleteThenAddJob ¶
删除所有相同的job后添加一个新job
func (*Scheduler) GetCurrJobWraps ¶
type SchedulerConfig ¶
Click to show internal directories.
Click to hide internal directories.