Documentation ¶
Overview ¶
A job runner for executing scheduled or ad-hoc tasks asynchronously from HTTP requests.
It adds a couple of features on top of the Robfig cron package:
- Protection against job panics. (They print to ERROR instead of take down the process)
- (Optional) Limit on the number of jobs that may run simulatenously, to limit resource consumption.
- (Optional) Protection against multiple instances of a single job running concurrently. If one execution runs into the next, the next will be queued.
- Cron expressions may be defined in app.conf and are reusable across jobs.
- Job status reporting. [WIP]
Index ¶
- Constants
- Variables
- func Entries() []cron.Entry
- func Every(duration time.Duration, job cron.Job, n ...string)
- func In(duration time.Duration, job cron.Job)
- func Now(job cron.Job)
- func Remove(id cron.EntryID)
- func Schedule(spec string, job cron.Job, n ...string) error
- func Start(v ...int)
- func StatusJson() map[string]interface{}
- func Stop()
- type Func
- type Job
- type StatusData
Constants ¶
const DEFAULT_JOB_POOL_SIZE = 10
const UNNAMED = "(unnamed)"
Variables ¶
var (
// Singleton instance of the underlying job scheduler.
MainCron *cron.Cron
)
Functions ¶
func Entries ¶
func Entries() []cron.Entry
Return detailed list of currently running recurring jobs to remove an entry, first retrieve the ID of entry
func Every ¶
Run the given job at a fixed interval. The interval provided is the time between the job ending and the job being run again. The time that the job takes to run is not included in the interval.
func Remove ¶
func Remove(id cron.EntryID)
Remove a specific job from running Get EntryID from the list job entries gojobrunner.Entries() If job is in the middle of running, once the process is finished it will be removed
func Schedule ¶
You can add a job using user-defined job name. For example:
gojobrunner.Schedule("cron.frequent", jobs.Func(myFunc), "my-job")
func StatusJson ¶
func StatusJson() map[string]interface{}
Types ¶
type Func ¶
type Func func()
Callers can use jobs.Func to wrap a raw func. (Copying the type to this package makes it more visible)
For example:
gojobrunner.Schedule("cron.frequent", jobs.Func(myFunc))
type Job ¶
type Job struct { Name string Status string Latency string // contains filtered or unexported fields }
func (*Job) StatusUpdate ¶
type StatusData ¶
type StatusData struct { Id cron.EntryID Next time.Time Prev time.Time // contains filtered or unexported fields }
func StatusPage ¶
func StatusPage() []StatusData