Skip to content

Commit

Permalink
replace all internal uses of RemoveByReference
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRoesler committed Oct 9, 2023
1 parent 6adea53 commit ebd20b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (s *Scheduler) scheduleNextRun(job *Job) (bool, nextRun) {
}

if !job.shouldRun() {
s.RemoveByReference(job)
_ = s.RemoveByID(job)
return false, nextRun{}
}

Expand Down Expand Up @@ -750,7 +750,7 @@ func (s *Scheduler) RemoveByTags(tags ...string) error {
}

for _, job := range jobs {
s.RemoveByReference(job)
_ = s.RemoveByID(job)
}
return nil
}
Expand All @@ -770,7 +770,7 @@ func (s *Scheduler) RemoveByTagsAny(tags ...string) error {
}

for job := range mJob {
s.RemoveByReference(job)
_ = s.RemoveByID(job)
}

return errs
Expand Down Expand Up @@ -947,7 +947,7 @@ func (s *Scheduler) doCommon(jobFun interface{}, params ...interface{}) (*Job, e
if job.error != nil {
// delete the job from the scheduler as this job
// cannot be executed
s.RemoveByReference(job)
_ = s.RemoveByID(job)
return nil, job.error
}

Expand All @@ -958,7 +958,7 @@ func (s *Scheduler) doCommon(jobFun interface{}, params ...interface{}) (*Job, e

if val.Kind() != reflect.Func {
// delete the job for the same reason as above
s.RemoveByReference(job)
_ = s.RemoveByID(job)
return nil, ErrNotAFunction
}

Expand All @@ -985,13 +985,13 @@ func (s *Scheduler) doCommon(jobFun interface{}, params ...interface{}) (*Job, e
}

if len(params) != expectedParamLength {
s.RemoveByReference(job)
_ = s.RemoveByID(job)
job.error = wrapOrError(job.error, ErrWrongParams)
return nil, job.error
}

if job.runWithDetails && val.Type().In(len(params)).Kind() != reflect.ValueOf(*job).Kind() {
s.RemoveByReference(job)
_ = s.RemoveByID(job)
job.error = wrapOrError(job.error, ErrDoWithJobDetails)
return nil, job.error
}
Expand Down
12 changes: 6 additions & 6 deletions scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ func TestScheduler_RemoveByReference(t *testing.T) {

assert.Equal(t, 2, s.Len(), "Incorrect number of jobs")

s.RemoveByReference(job1)
_ = s.RemoveByID(job1)
s.jobsMutex.RLock()
defer s.jobsMutex.RUnlock()
assert.NotContains(t, s.jobs, job1.id)
Expand All @@ -607,7 +607,7 @@ func TestScheduler_RemoveByReference(t *testing.T) {

s.StartAsync()

s.RemoveByReference(j)
_ = s.RemoveByID(j)

select {
case <-time.After(200 * time.Millisecond):
Expand Down Expand Up @@ -1693,9 +1693,9 @@ func TestScheduler_SetMaxConcurrentJobs(t *testing.T) {
}

if tc.removeJobs {
s.RemoveByReference(j1)
s.RemoveByReference(j2)
s.RemoveByReference(j3)
_ = s.RemoveByID(j1)
_ = s.RemoveByID(j2)
_ = s.RemoveByID(j3)
} else {
s.Stop()
}
Expand Down Expand Up @@ -1912,7 +1912,7 @@ func TestScheduler_Update(t *testing.T) {
require.NoError(t, err)

time.Sleep(550 * time.Millisecond)
s.RemoveByReference(j)
_ = s.RemoveByID(j)

j, err = s.Every("750ms").WaitForSchedule().Do(func() { counterMutex.Lock(); defer counterMutex.Unlock(); counter++ })
require.NoError(t, err)
Expand Down

0 comments on commit ebd20b9

Please sign in to comment.