Commit a0d7f361 authored by ale's avatar ale
Browse files

Rename scheduler JobStatus to CronJobStatus

To avoid conflicts with the job manager status type.
parent 461b441a
......@@ -121,13 +121,12 @@ func (s *Scheduler) Stop() {
// CronJobStatus represents the status of a job, either scheduled,
// running, or terminated in the past.
type CronJobStatus struct {
Name string `json:"name"`
Running bool `json:"running"`
Schedule string `json:"schedule"`
Prev time.Time `json:"prev,omitempty"`
Next time.Time `json:"next,omitempty"`
RunAt time.Time `json:"run_at,omitempty"`
Error string `json:"error,omitempty"`
Spec SourceSpec
Prev time.Time
Next time.Time
//RunAt time.Time
//Running bool
//Error string
}
type cronJobStatusList struct {
......@@ -143,7 +142,7 @@ func cronJobStatusListOrderByName(list []CronJobStatus) *cronJobStatusList {
return &cronJobStatusList{
list: list,
lessFn: func(i, j int) bool {
return list[i].Name < list[j].Name
return list[i].Spec.Name < list[j].Spec.Name
},
}
}
......@@ -154,27 +153,24 @@ type SchedulerStatus struct {
Scheduled []CronJobStatus `json:"scheduled"`
}
// GetStatus returns the current status of the scheduled jobs.
func (s *Scheduler) GetStatus() *SchedulerStatus {
status := new(SchedulerStatus)
// Get status of scheduled jobs.
// getStatus returns the current status of the scheduled jobs.
func (s *Scheduler) getStatus() []CronJobStatus {
var jobs []CronJobStatus
for _, entry := range s.c.Entries() {
// Get the startBackupCronJob behind the cron.Job interface.
if job, ok := entry.Job.(*startBackupCronJob); ok {
status.Scheduled = append(status.Scheduled, CronJobStatus{
Name: job.spec.Name,
//Running: job.isRunning(),
Schedule: job.spec.Schedule,
Prev: entry.Prev,
Next: entry.Next,
jobs = append(jobs, CronJobStatus{
Spec: job.spec,
Prev: entry.Prev,
Next: entry.Next,
})
}
}
// Sort everything.
sort.Sort(cronJobStatusListOrderByName(status.Scheduled))
sort.Sort(cronJobStatusListOrderByName(jobs))
return status
return jobs
}
func parseSchedule(s string, hostSeed int64) (cron.Schedule, error) {
......
......@@ -95,7 +95,7 @@ func TestScheduler(t *testing.T) {
time.Sleep(4 * time.Second)
status := s.GetStatus()
status := s.getStatus()
s.Stop()
src1n := m.counts["source1"]
......@@ -113,8 +113,8 @@ func TestScheduler(t *testing.T) {
t.Errorf("source2 ran too many times (%d)", src2n)
}
if len(status.Scheduled) != 2 {
t.Errorf("bad status.Scheduled (expected 2 values): %+v", status.Scheduled)
if len(status) != 2 {
t.Errorf("bad status.Scheduled (expected 2 values): %+v", status)
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment