Commit 70788e57 authored by Kyle Clarke's avatar Kyle Clarke 💬

Additional comments around the runner methods.

parent 9f6e7428
......@@ -78,14 +78,18 @@ func (r *JobRunner) Run() {
go do(r)
}
// Stop will set this runners stop flag. This does not ensure that the runner job will
// stop when called. It does guarantee that the next "every" invocation will stop.
func (r *JobRunner) Stop() {
r.stop = true
}
// Stopped returns this runners current stop flag value.
func (r *JobRunner) Stopped() bool {
return r.stop
}
// do is called via Run in a go routine.
func do(r *JobRunner) {
safety := uint64(0)
every := time.NewTicker(r.job.every)
......@@ -150,6 +154,7 @@ func do(r *JobRunner) {
}
}
// JobRunnerInfo is a struct that contains runner instance information.
type JobRunnerInfo struct {
status string
runningCount uint64
......@@ -158,6 +163,7 @@ type JobRunnerInfo struct {
stopped bool
}
// Info will return a new populated JobRunnerInfo struct. Reference, not a pointer.
func (r *JobRunner) Info() JobRunnerInfo {
return JobRunnerInfo{
status: r.status,
......@@ -173,14 +179,17 @@ func (i JobRunnerInfo) IsCompleted() bool {
return !i.completedAt.IsZero()
}
// IsPending will return true if not complete and not started.
func (i JobRunnerInfo) IsPending() bool {
return (!i.IsCompleted() && i.startedAt.IsZero())
}
// IsRunning will return true if not complete and started.
func (i JobRunnerInfo) IsRunning() bool {
return (!i.IsCompleted() && !i.startedAt.IsZero())
}
// RunningCount will return the number of times the Every has executed.
func (i JobRunnerInfo) RunningCount() uint64 {
return i.runningCount
}
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