mirror of
https://github.com/hibiken/asynq.git
synced 2025-10-24 10:36:12 +08:00
chore(): 从内存里面读取任务
This commit is contained in:
25
scheduler.go
25
scheduler.go
@@ -297,3 +297,28 @@ func (s *Scheduler) clearHistory() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Scheduler) GetEntries() ([]*SchedulerEntry, error) {
|
||||
var entries []*SchedulerEntry
|
||||
|
||||
for _, entry := range s.cron.Entries() {
|
||||
job := entry.Job.(*enqueueJob)
|
||||
var opts []Option
|
||||
opt := stringifyOptions(job.opts)
|
||||
for _, s := range opt {
|
||||
if o, err := parseOption(s); err == nil {
|
||||
// ignore bad data
|
||||
opts = append(opts, o)
|
||||
}
|
||||
}
|
||||
entries = append(entries, &SchedulerEntry{
|
||||
ID: job.id.String(),
|
||||
Spec: job.cronspec,
|
||||
Task: job.task,
|
||||
Opts: opts,
|
||||
Next: entry.Next,
|
||||
Prev: entry.Prev,
|
||||
})
|
||||
}
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user