scheduler: github.com/carlescere/scheduler Index | Files

package scheduler

import "github.com/carlescere/scheduler"

Package scheduler is a cron replacement based on:

http://adam.herokuapp.com/past/2010/4/13/rethinking_cron/

and

https://github.com/dbader/schedule

Uses include:

 func main() {
   job := func() {
	fmt.Println("Time's up!")
   }
   scheduler.Every(5).Seconds().Run(function)
   scheduler.Every().Day().Run(function)
   scheduler.Every().Sunday().At("08:30").Run(function)
 }

Index

Package Files

scheduler.go

type Job Uses

type Job struct {
    Quit     chan bool
    SkipWait chan bool

    sync.RWMutex
    // contains filtered or unexported fields
}

Job defines a running job and allows to stop a scheduled job or run it.

func Every Uses

func Every(times ...int) *Job

Every defines when to run a job. For a recurrent jobs (n seconds/minutes/hours) you should specify the unit and then call to the correspondent period method.

func (*Job) At Uses

func (j *Job) At(hourTime string) *Job

At lets you define a specific time when the job would be run. Does not work with recurrent jobs. Time should be defined as a string separated by a colon. Could be used as "08:35:30", "08:35" or "8" for only the hours.

func (*Job) Day Uses

func (j *Job) Day() *Job

Day sets the job to run every day.

func (*Job) Friday Uses

func (j *Job) Friday() *Job

Friday sets the job to run every Friday.

func (*Job) Hours Uses

func (j *Job) Hours() *Job

Hours sets the job to run every n Hours where n was defined in the Every function.

func (*Job) IsRunning Uses

func (j *Job) IsRunning() bool

IsRunning returns if the job is currently running

func (*Job) Minutes Uses

func (j *Job) Minutes() *Job

Minutes sets the job to run every n Minutes where n was defined in the Every function.

func (*Job) Monday Uses

func (j *Job) Monday() *Job

Monday sets the job to run every Monday.

func (*Job) NotImmediately Uses

func (j *Job) NotImmediately() *Job

NotImmediately allows recurrent jobs not to be executed immediatelly after definition. If a job is declared hourly won't start executing until the first hour passed.

func (*Job) Run Uses

func (j *Job) Run(f func()) (*Job, error)

Run sets the job to the schedule and returns the pointer to the job so it may be stopped or executed without waiting or an error.

func (*Job) Saturday Uses

func (j *Job) Saturday() *Job

Saturday sets the job to run every Saturday.

func (*Job) Seconds Uses

func (j *Job) Seconds() *Job

Seconds sets the job to run every n Seconds where n was defined in the Every function.

func (*Job) Sunday Uses

func (j *Job) Sunday() *Job

Sunday sets the job to run every Sunday.

func (*Job) Thursday Uses

func (j *Job) Thursday() *Job

Thursday sets the job to run every Thursday.

func (*Job) Tuesday Uses

func (j *Job) Tuesday() *Job

Tuesday sets the job to run every Tuesday.

func (*Job) Wednesday Uses

func (j *Job) Wednesday() *Job

Wednesday sets the job to run every Wednesday.

Package scheduler imports 5 packages (graph) and is imported by 27 packages. Updated 2019-05-10. Refresh now. Tools for package owners.