gocron

package module
v0.0.0-...-f3afa3b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2018 License: BSD-2-Clause Imports: 6 Imported by: 2

README

goCron: A Golang Job Scheduling Package.

Documentation

Overview

Package gocron : A Golang Job Scheduling Package.

An in-process scheduler for periodic jobs that uses the builder pattern for configuration. Schedule lets you run Golang functions periodically at pre-determined intervals using a simple, human-friendly syntax.

Inspired by the Ruby module clockwork <https://github.com/tomykaira/clockwork> and Python package schedule <https://github.com/dbader/schedule>

See also http://adam.heroku.com/past/2010/4/13/rethinking_cron/ http://adam.heroku.com/past/2010/6/30/replace_cron_with_clockwork/

Copyright 2014 Jason Lyu. jasonlvhit@gmail.com . Copyright 2018 National library of Norway All rights reserved. Use of this source code is governed by a BSD-style . license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByTime

type ByTime []*Job

func (ByTime) Len

func (s ByTime) Len() int

func (ByTime) Less

func (s ByTime) Less(i, j int) bool

func (ByTime) Swap

func (s ByTime) Swap(i, j int)

type Collector

type Collector interface {
	GetJobs() []*Job
}

type Job

type Job struct {
	// schedule based on cron expression determines runtime
	Schedule Schedule
	// contains filtered or unexported fields
}

func NewCronJob

func NewCronJob(expression string) (*Job, error)

NewCronJob creates a new job based on a cron expression.

func NewJob

func NewJob(schedule Schedule) *Job

NewJob creates a new job based on a schedule.

func (*Job) AddTask

func (j *Job) AddTask(task interface{}, params ...interface{}) *Job

Add a task function including it's parameters to the job.

type Schedule

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

func Every

func Every(interval time.Duration) Schedule

type Scheduler

type Scheduler struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Scheduler contains jobs and a loop to run the jobs

func NewScheduler

func NewScheduler() *Scheduler

NewScheduler create a new scheduler.

func (*Scheduler) AddCollector

func (s *Scheduler) AddCollector(collector Collector) *Scheduler

func (*Scheduler) AddJob

func (s *Scheduler) AddJob(job *Job)

func (*Scheduler) Interval

func (s *Scheduler) Interval(d time.Duration) *Scheduler

Interval sets the interval between the check for pending jobs.

func (*Scheduler) Location

func (s *Scheduler) Location(location *time.Location) *Scheduler

Location sets the location of the scheduler.

func (*Scheduler) Start

func (s *Scheduler) Start()

Start scheduler.

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop scheduler.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL