package task import ( "sync" "time" cron "github.com/robfig/cron/v3" ) var Reporter chan *Report var started chan struct{} var wg sync.WaitGroup var quit chan struct{} func init() { Reporter = make(chan *Report) started = make(chan struct{}, 1) quit = make(chan struct{}, 1) } type Receiver func(*Report) var ReportReceiver Receiver = func(r *Report) {} type Report struct { // Entry Next time.Time Prev time.Time Entry cron.EntryID // Task ID string Description string Group string // _task Name string Spec string Once bool Args []interface{} Carry interface{} // Report Error error } type Profile struct { Scheduled []*Report } func GetProfile() *Profile { p := &Profile{} entries := c.Entries() for i := 0; i < len(entries); i++ { t, ok := entries[i].Job.(*_task) if !ok { continue } r := &Report{ Next: entries[i].Next, Prev: entries[i].Prev, Entry: entries[i].ID, ID: t.Task.ID, Description: t.Task.Description, Group: t.Task.Group, Name: t.name, Spec: t.spec, Once: t.once, Args: t.args, Carry: t.carry, } p.Scheduled = append(p.Scheduled, r) } return p }