Documentation ¶
Overview ¶
Package schedule is a golang job scheduling package
Schedule is a Golang job scheduling package which lets you run Go functions periodically at pre-determined interval using a simple, human-friendly syntax. Schedule can optionally use a mysql database to synchronize its jobscheduling across multiple server instances. Schedule is inspired by the Ruby module [clockwork](<https://github.com/tomykaira/clockwork>) and Python job scheduling package schedule(<https://github.com/dbader/schedule>). This package has been heavily inspired by the good, but rather buggy [goCron](https://github.com/jasonlvhit/gocron) package.
Index ¶
Constants ¶
const ( // Once happens one time only Once = IntervalType("once") // Years is set if `Interval.Years` is called Years = IntervalType("years") // Months is set if `Interval.Months` is called Months = IntervalType("months") // Weeks is set if `Interval.Weeks` is called Weeks = IntervalType("weeks") // Days is set if `Interval.Days` is called Days = IntervalType("days") // Hours is set if `Interval.Hours` is called Hours = IntervalType("hours") // Minutes is set if `Interval.MinutesDaily` is called Minutes = IntervalType("minutes") // Seconds is set if `Interval.Seconds` is called Seconds = IntervalType("seconds") )
Variables ¶
var DefaultScheduler = New(&Config{Name: "default"})
DefaultScheduler is the `Scheduler“ referenced by the `Add` and `List` funcs
Functions ¶
This section is empty.
Types ¶
type Amount ¶
Amount determines the amount of some interval of time that will elapse between executions
type Config ¶
type Config struct { // Name is the name of the scheduler Name string // Database is the name of the mysql database used to synchronize the scheduler // If a database is not passed in, the scheduler will not use database synchronicity Database string // Instancs is the address of the database instance used to synchronize the scheduler Instance string // Username is the username of the mysql user Username string // Password is the password of the mysql user Password string // LogDB when set to true, all sql transactions will be logged LogDB bool }
Config configures the scheduler
type Interval ¶
type Interval interface { Years() Month Months() Day Weeks() Day Days() Time Hours() Starting Minutes() Starting Seconds() Starting }
Interval determines the interval of time that will elapse between executions
type IntervalType ¶
type IntervalType string
IntervalType is a string representation of the interval chosen by the `Interval` interface
func (*IntervalType) Scan ¶
func (it *IntervalType) Scan(value interface{}) error
Scan implements `sql.Scanner`
type Job ¶
type Job interface { // Name is the name of the job. It is unique to the scheduler that it is added to Name() string // Amount is the amount of some interval of time that will elapse between executions. // If there is only 1 execution of this task, it will be set to zero Amount() int // Interval is the interval of time that will elapse between executions Interval() IntervalType // Description is a plain english sentence that describes when this job is executed Description() string // Scheduler is the `Scheduler` that this job belongs to Scheduler() Scheduler // contains filtered or unexported methods }
Job represents a task that is queued on the system at a certain time
type Scheduler ¶
type Scheduler interface { // Name is the unique name of the scheduler. Note: any scheduler with the same name will reference the same table name for synchronicity purposes Name() string // List returs a list of jobs added to this scheduler List() []Job // Add create a new job ascociated with the scheduler and returns its first builder method // Note: it will not be added to the scheduler until it is done being built (ie `Do` is called) Add(name string) Amount // Start starts the scheduler Start() // Stop stops the scheduler Stop() // contains filtered or unexported methods }
Scheduler executes a sets of `Jobs` at a given time