Commit 2dde5423 authored by Kyle Clarke's avatar Kyle Clarke 💬

New Syop method on a runner instance. Method name change, shorter, better =]

parent 81359cac
......@@ -78,6 +78,10 @@ func (r *JobRunner) Run() {
go do(r)
}
func (r *JobRunner) Stop() {
r.stop = true
}
func (r *JobRunner) Stopped() bool {
return r.stop
}
......
......@@ -115,7 +115,7 @@ func (s *Schedule) AddJob(j *Job) (JobID, error) {
return j.id, nil
}
func (s *Schedule) AddJobAndRun(j *Job) (JobID, error) {
func (s *Schedule) RunJob(j *Job) (JobID, error) {
id, err := s.AddJob(j)
if err != nil {
return id, err
......@@ -229,6 +229,6 @@ func (s *Schedule) StopJob(ID JobID) error {
return err
}
r.stop = true
r.Stop()
return nil
}
......@@ -153,7 +153,7 @@ func TestSchedule_AutoPurge(t *testing.T) {
j := newSimpleJob()
j.cap = 1
j.every = time.Duration(100 * time.Millisecond)
s.AddJobAndRun(j)
s.RunJob(j)
i := s.Info()
if i.count != 1 {
......@@ -277,7 +277,7 @@ func TestSchedule_Purge(t *testing.T) {
j.cap = 1
j.every = time.Duration(100 * time.Millisecond)
s.AddJobAndRun(j)
s.RunJob(j)
i := s.Info()
if i.count != 1 {
t.Error("Expecting one job as auto purge is off.")
......@@ -366,7 +366,7 @@ func TestSchedule_StopJob(t *testing.T) {
j := newSimpleJob()
j.every = 200 * time.Millisecond
id, _ := s.AddJobAndRun(j)
id, _ := s.RunJob(j)
r, _ := s.FindJob(id)
if r.Info().IsRunning() {
t.Error("Execution path should beat the job and therefore not be running.")
......
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