Documentation ¶
Index ¶
- func WrapForCron(r *Runner, job Job, cronID *cron.EntryID) cron.Job
- type Job
- type JobRun
- type Runner
- func (r *Runner) DeleteSchedule(ctx context.Context, id int64) error
- func (r *Runner) GetJob(name string) (Job, bool)
- func (r *Runner) GetJobRun(ctx context.Context, id int64) (JobRun, error)
- func (r *Runner) JobNames() []string
- func (r *Runner) JobRuns(ctx context.Context, limit int) ([]JobRun, error)
- func (r *Runner) ParseCron(s string) (cron.Schedule, error)
- func (r *Runner) Register(job Job)
- func (r *Runner) RunJob(ctx context.Context, jobName string) (int64, chan struct{}, error)
- func (r *Runner) ScheduleJob(ctx context.Context, jobName string, cronExpr string) error
- func (r *Runner) Schedules(ctx context.Context) ([]Schedule, error)
- func (r *Runner) Start(ctx context.Context) error
- func (r *Runner) Stop() context.Context
- type Schedule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WrapForCron ¶
Types ¶
type Job ¶
type Job interface { // Name of the job. Name() string // Run runs the job. // Any logging or other relevant output produced should be written to the given writer. Run(ctx context.Context, w io.Writer) error }
Job represents a runnable job, typically set up to perform some side effect or interacting with sirkulator data.
type JobRun ¶
type JobRun struct { ID int64 Name string StartAt time.Time StopAt time.Time Status string // running|ok|failed|cancelled Output string // The following fields are only present in active jobs (scheduled or currently running) CronID cron.EntryID // id needed for removing scheduled job from cron Cancel context.CancelFunc // to cancel a job Done chan struct{} // if you need to wait until job is done }
JobRun represents a run of a job that has been started. It corresponds to a row in the job_run table.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner executes jobs, either ad-hoc or by cron-schedule.
func (*Runner) DeleteSchedule ¶
func (*Runner) Register ¶
Register the given job. If a Job exists with the same name, it will be overwritten
func (*Runner) RunJob ¶
RunJob runs a job immedeatly. Returns the job run ID and a channel which will send when the job is completed. TODO return JobRun instead, align with cron scheduled jobs (running map etc)
func (*Runner) ScheduleJob ¶
Click to show internal directories.
Click to hide internal directories.