Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
SaveAllJobsWaitTime = 5 * time.Second
)
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct { Name string `json:"name"` Id string `json:"id"` // Command to run // e.g. "bash /path/to/my/script.sh" Command string `json:"command"` // Email of the owner of this job // e.g. "admin@example.com" Owner string `json:"owner"` // Is this job disabled? Disabled bool `json:"disabled"` // Jobs that are dependent upon this one will be run after this job runs. DependentJobs []string `json:"dependent_jobs"` // List of ids of jobs that this job is dependent upon. ParentJobs []string `json:"parent_jobs"` // ISO 8601 String // e.g. "R/2014-03-08T20:00:00.000Z/PT2H" Schedule string `json:"schedule"` // Number of times to retry on failed attempt for each run. Retries uint `json:"retries"` // Duration in which it is safe to retry the Job. Epsilon string `json:"epsilon"` // Meta data about successful and failed runs. SuccessCount uint `json:"success_count"` LastSuccess time.Time `json:"last_success"` ErrorCount uint `json:"error_count"` LastError time.Time `json:"last_error"` LastAttemptedRun time.Time `json:"last_attempted_run"` NextRunAt time.Time `json:"next_run_at"` Stats []*JobStat `json:"-"` // contains filtered or unexported fields }
func GetAllJobs ¶
func (*Job) Disable ¶
func (j *Job) Disable()
Disable stops the job from running by stopping its jobTimer. It also sets Job.Disabled to true, which is reflected in the UI.
func (*Job) InitDelayDuration ¶
InitDelayDuration is used to parsed the iso8601 Schedule notation into its relevent fields in the Job struct. If checkTime is true, then it will return an error if the Scheduled time has passed.
func (*Job) Run ¶
func (j *Job) Run()
Run executes the Job's command, collects metadata around the success or failure of the Job's execution, and schedules the next run.
func (*Job) StartWaiting ¶
func (j *Job) StartWaiting()
StartWaiting begins a timer for when it should execute the Jobs .Run() method.
type JobCache ¶
func (*JobCache) PersistEvery ¶
type JobStat ¶
type JobStat struct { JobId string RanAt time.Time NumberOfRetries uint Success bool ExecutionDuration time.Duration }
JobStat is used to store metrics about a specific Job .Run()
func NewJobStat ¶
type KalaStats ¶
type KalaStats struct { ActiveJobs int DisabledJobs int Jobs int ErrorCount uint SuccessCount uint NextRunAt time.Time LastAttemptedRun time.Time CreatedAt time.Time }
KalaStats is the struct for storing app-level metrics
func NewKalaStats ¶
func NewKalaStats() *KalaStats
NewKalaStats is used to easily generate a current app-level metrics report.