type Cron … type ScheduleParser … type Job … type Schedule … type EntryID … type Entry … // Valid returns true if this is not the zero entry. func (e Entry) Valid() bool { … } type byTime … func (s byTime) Len() int { … } func (s byTime) Swap(i, j int) { … } func (s byTime) Less(i, j int) bool { … } // New returns a new Cron job runner, modified by the given options. // // Available Settings // // Time Zone // Description: The time zone in which schedules are interpreted // Default: time.Local // // Parser // Description: Parser converts cron spec strings into cron.Schedules. // Default: Accepts this spec: https://en.wikipedia.org/wiki/Cron // // Chain // Description: Wrap submitted jobs to customize behavior. // Default: A chain that recovers panics and logs them to stderr. // // See "cron.With*" to modify the default behavior. func New(opts ...Option) *Cron { … } type FuncJob … func (f FuncJob) Run() { … } // AddFunc adds a func to the Cron to be run on the given schedule. // The spec is parsed using the time zone of this Cron instance as the default. // An opaque ID is returned that can be used to later remove it. func (c *Cron) AddFunc(spec string, cmd func()) (EntryID, error) { … } // AddJob adds a Job to the Cron to be run on the given schedule. // The spec is parsed using the time zone of this Cron instance as the default. // An opaque ID is returned that can be used to later remove it. func (c *Cron) AddJob(spec string, cmd Job) (EntryID, error) { … } // Schedule adds a Job to the Cron to be run on the given schedule. // The job is wrapped with the configured Chain. func (c *Cron) Schedule(schedule Schedule, cmd Job) EntryID { … } // Entries returns a snapshot of the cron entries. func (c *Cron) Entries() []Entry { … } // Location gets the time zone location func (c *Cron) Location() *time.Location { … } // Entry returns a snapshot of the given entry, or nil if it couldn't be found. func (c *Cron) Entry(id EntryID) Entry { … } // Remove an entry from being run in the future. func (c *Cron) Remove(id EntryID) { … } // Start the cron scheduler in its own goroutine, or no-op if already started. func (c *Cron) Start() { … } // Run the cron scheduler, or no-op if already running. func (c *Cron) Run() { … } // run the scheduler.. this is private just due to the need to synchronize // access to the 'running' state variable. func (c *Cron) run() { … } // startJob runs the given job in a new goroutine. func (c *Cron) startJob(j Job) { … } // now returns current time in c location func (c *Cron) now() time.Time { … } // Stop stops the cron scheduler if it is running; otherwise it does nothing. // A context is returned so the caller can wait for running jobs to complete. func (c *Cron) Stop() context.Context { … } // entrySnapshot returns a copy of the current cron entry list. func (c *Cron) entrySnapshot() []Entry { … } func (c *Cron) removeEntry(id EntryID) { … }