Commit 087bb77f authored by Kyle Clarke's avatar Kyle Clarke 💬

Added new all method to return all schedule runners. Added new pending status...

Added new all method to return all schedule runners. Added new pending status and altered const strings to lowercase.
parent c1c569eb
Pipeline #4928215 passed with stage
in 31 seconds
......@@ -7,23 +7,26 @@ import (
)
const (
// StatusPending is a simple string representation of a pending status
StatusPending = "pending"
// StatusRunning is a simple string representation of a running status
StatusRunning = "Running"
StatusRunning = "running"
// StatusStopped is a simple string representation of a stopped status
StatusStopped = "Stopped"
StatusStopped = "stopped"
// StatusError is a simple string representation of an error status
StatusError = "Error"
StatusError = "error"
// StatusExpired is a simple string representation of an expired status
StatusExpired = "Expired"
StatusExpired = "expired"
// StatusCapBreached is a simple string representation of a cap breached status
StatusCapBreached = "Cap Breached"
StatusCapBreached = "cap breached"
// StatusCannotBegin is a simple string representation of a cannot begin status
StatusCannotBegin = "Cannot Begin"
StatusCannotBegin = "cannot begin"
)
// Runners are a map of all job runners key'd on JobID.
......@@ -174,8 +177,10 @@ func do(r *runner) {
// RunnerInfo is a struct that contains runner instance information.
type RunnerInfo struct {
ID string
Status string
Cap uint64
Every float64
RunningCount uint64
CompletedAt time.Time
StartedAt time.Time
......@@ -184,8 +189,15 @@ type RunnerInfo struct {
// Info will return a new populated RunnerInfo struct. Reference, not a pointer.
func (r *runner) Info() RunnerInfo {
status := r.status
if "" == status {
status = StatusPending
}
return RunnerInfo{
Status: r.status,
ID: string(r.job.ID),
Status: status,
Every: r.job.Every.Seconds(),
Cap: r.job.Cap,
RunningCount: r.runningCount,
CompletedAt: r.completed,
......
......@@ -176,6 +176,11 @@ func (s *schedule) doPurge(before time.Duration) {
}
}
// All will return all Job runners assigned to the schedule instance.
func (s *schedule) All() Runners {
return s.runners
}
// Find will attempt to find and return a Runner instance on this schedule by a common String.
// Internally Kevin uses a JobID type so this Find method is used as a convenience for your
// common string references. Returns error on not found.
......
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