gron: Index | Files | Directories

package gron

import ""


Package Files

cron.go schedule.go

type AtSchedule Uses

type AtSchedule interface {
    At(t string) Schedule

AtSchedule extends Schedule by enabling periodic-interval & time-specific setup

func Every Uses

func Every(p time.Duration) AtSchedule

Every returns a Schedule reoccurs every period p, p must be at least time.Second.

type Cron Uses

type Cron struct {
    // contains filtered or unexported fields

Cron provides a convenient interface for scheduling job such as to clean-up database entry every month.

Cron keeps track of any number of entries, invoking the associated func as specified by the schedule. It may also be started, stopped and the entries may be inspected.

func New Uses

func New() *Cron

New instantiates new Cron instant c.

func (*Cron) Add Uses

func (c *Cron) Add(s Schedule, j Job)

Add appends schedule, job to entries.

if cron instant is not running, adding to entries is trivial. otherwise, to prevent data-race, adds through channel.

func (*Cron) AddFunc Uses

func (c *Cron) AddFunc(s Schedule, j func())

AddFunc registers the Job function for the given Schedule.

func (Cron) Entries Uses

func (c Cron) Entries() []*Entry

Entries returns cron etn

func (*Cron) Start Uses

func (c *Cron) Start()

Start signals cron instant c to get up and running.

func (*Cron) Stop Uses

func (c *Cron) Stop()

Stop halts cron instant c from running.

type Entry Uses

type Entry struct {
    Schedule Schedule
    Job      Job

    // the next time the job will run. This is zero time if Cron has not been
    // started or invalid schedule.
    Next time.Time

    // the last time the job was run. This is zero time if the job has not been
    // run.
    Prev time.Time

Entry consists of a schedule and the job to be executed on that schedule.

type Job Uses

type Job interface {

Job is the interface that wraps the basic Run method.

Run executes the underlying func.

type JobFunc Uses

type JobFunc func()

JobFunc is an adapter to allow the use of ordinary functions as gron.Job If f is a function with the appropriate signature, JobFunc(f) is a handler that calls f.

todo: possibly func with params? maybe not needed.

func (JobFunc) Run Uses

func (j JobFunc) Run()

Run calls j()

type Schedule Uses

type Schedule interface {
    Next(t time.Time) time.Time

Schedule is the interface that wraps the basic Next method.

Next deduces next occurring time based on t and underlying states.



Package gron imports 4 packages (graph) and is imported by 6 packages. Updated 2016-08-01. Refresh now. Tools for package owners.