Documentation ¶
Index ¶
- Constants
- func Next(spec string) (time.Time, error)
- func OnJobReturn(f func(runReturn *JobRunReturnWithEid), order ...int)
- func SetDefaultManager(manager *CronManager)
- func Validate(spec string) bool
- type CronHook
- type CronHooks
- type CronManager
- func (r *CronManager) Add(spec string, j JobInf, info interface{}) (int, error)
- func (r *CronManager) DisActive(id int)
- func (r *CronManager) Job(id int) (*WrappedJob, bool)
- func (r *CronManager) Remove(id int)
- func (r *CronManager) RemoveAll()
- func (r *CronManager) SetConfig(cfg CronManagerConfig)
- func (r *CronManager) Start()
- func (r *CronManager) Stop()
- type CronManagerConfig
- type JobInf
- type JobRunError
- type JobRunReturn
- type JobRunReturnWithEid
- type WrappedJob
Constants ¶
View Source
const ( IDLE = iota RUNNING FAIL STOP )
Variables ¶
This section is empty.
Functions ¶
func OnJobReturn ¶
func OnJobReturn(f func(runReturn *JobRunReturnWithEid), order ...int)
func SetDefaultManager ¶
func SetDefaultManager(manager *CronManager)
Types ¶
type CronHooks ¶
type CronHooks []CronHook
func (CronHooks) Add ¶
func (h CronHooks) Add(fn func(runReturn *JobRunReturnWithEid), order ...int) CronHooks
func (CronHooks) Run ¶
func (h CronHooks) Run(runReturn *JobRunReturnWithEid)
type CronManager ¶
type CronManager struct { JobMap map[int]*WrappedJob MainCron *cron.Cron // contains filtered or unexported fields }
var DefaultManager *CronManager
func NewCronManager ¶
func NewCronManager(c CronManagerConfig) *CronManager
func (*CronManager) Add ¶
func (r *CronManager) Add(spec string, j JobInf, info interface{}) (int, error)
func (*CronManager) DisActive ¶
func (r *CronManager) DisActive(id int)
func (*CronManager) Job ¶
func (r *CronManager) Job(id int) (*WrappedJob, bool)
func (*CronManager) Remove ¶
func (r *CronManager) Remove(id int)
func (*CronManager) RemoveAll ¶
func (r *CronManager) RemoveAll()
func (*CronManager) SetConfig ¶
func (r *CronManager) SetConfig(cfg CronManagerConfig)
func (*CronManager) Start ¶
func (r *CronManager) Start()
func (*CronManager) Stop ¶
func (r *CronManager) Stop()
type CronManagerConfig ¶
type JobInf ¶
type JobInf interface {
Run() JobRunReturn
}
type JobRunError ¶
type JobRunError struct {
Message string
}
func (JobRunError) Error ¶
func (err JobRunError) Error() string
type JobRunReturn ¶
type JobRunReturn struct { Value interface{} Error error }
type JobRunReturnWithEid ¶
type JobRunReturnWithEid struct { JobRunReturn Eid int }
type WrappedJob ¶
type WrappedJob struct { Id int Name string Inner JobInf SuccessCount uint32 TotalCount uint32 Info interface{} Next time.Time // contains filtered or unexported fields }
func NewWrappedJob ¶
func NewWrappedJob(job JobInf, r *CronManager) *WrappedJob
func (*WrappedJob) Now ¶
func (j *WrappedJob) Now()
func (*WrappedJob) Run ¶
func (j *WrappedJob) Run()
func (*WrappedJob) Status ¶
func (j *WrappedJob) Status() string
Click to show internal directories.
Click to hide internal directories.