Documentation
¶
Index ¶
- Constants
- Variables
- func Entries() []cron.Entry
- func Every(duration time.Duration, job cron.Job)
- func In(duration time.Duration, job cron.Job)
- func Now(job cron.Job)
- func Remove(id cron.EntryID)
- func RemoveJobByName(jobName string) error
- func Schedule(spec string, job cron.Job) error
- func Start(options ...int)
- func StatusJson() map[string]interface{}
- func Stop()
- func UpdateJobIntervalByName(jobName string, newInterval time.Duration) error
- func UpdateJobScheduleByName(jobName, newSpec string) error
- type Func
- type Job
- type StatusData
Constants ¶
const ( UNNAMED_JOB = "(unnamed)" // Default name for unnamed jobs JOB_RUNNING_STATUS = "RUNNING" // Job status constants JOB_IDLE_STATUS = "IDLE" // Job status constants )
const DEFAULT_JOB_POOL_SIZE = 10 // Default number of concurrent jobs
Variables ¶
var ( MainCron *cron.Cron // Job scheduler singleton instance HideBanner bool = false // Flag to control banner display )
Functions ¶
func RemoveJobByName ¶
RemoveJobByName removes a scheduled job by its name.
func StatusJson ¶
func StatusJson() map[string]interface{}
StatusJson returns a list of all cron job entries in a JSON format
func UpdateJobIntervalByName ¶
UpdateJobIntervalByName updates an existing job's execution interval by its name.
func UpdateJobScheduleByName ¶
UpdateJobScheduleByName updates an existing job's schedule by its name.
Types ¶
type Job ¶
type Job struct { Name string `json:"name"` Status string `json:"status"` Latency string `json:"latency"` // contains filtered or unexported fields }
Job represents a scheduled task within the JobRunner system. It wraps an inner cron.Job and maintains execution metadata such as name, status, and execution latency.
Fields: - Name: The name of the job. - inner: The actual job implementation that executes. - status: Atomic status flag to indicate if the job is running. - Status: A human-readable representation of the job status ("RUNNING" or "IDLE"). - Latency: The time taken for the last execution of the job. - running: A mutex to prevent concurrent execution if self-concurrency is disabled.
func (*Job) StatusUpdate ¶
StatusUpdate updates the job status based on the atomic status flag
type StatusData ¶
type StatusData struct { Id cron.EntryID `json:"id"` JobRunner *Job `json:"jobRunner"` Next time.Time `json:"next"` Prev time.Time `json:"prev"` }
func StatusPage ¶
func StatusPage() []StatusData
StatusPage returns a list of all cron job entries in a human-readable format