Categorygithub.com/ringtail/go-cron
modulepackage
1.0.0
Repository: https://github.com/ringtail/go-cron.git
Documentation: pkg.go.dev

# README

go-cron

Build Status Codecov

a cron library for go.

Why create another cron lib

robfig/cron is a very great library for go. But it does have some missing parts.For example:

c := cron.New()
c.AddFunc("0 30 * * * *", func() { fmt.Println("Every hour on the half hour") })
c.AddFunc("@hourly",      func() { fmt.Println("Every hour") })
c.AddFunc("@every 1h30m", func() { fmt.Println("Every hour thirty") })
c.Start()
..
// Funcs are invoked in their own goroutine, asynchronously.
...
// Funcs may also be added to a running Cron
c.AddFunc("@daily", func() { fmt.Println("Every day") })
..
// Inspect the cron job entries' next and previous run times.
inspect(c.Entries())
..
c.Stop()  // Stop the scheduler (does not stop any jobs already running).

The code above is how robfig/cron works. But it's impossible if you want to update a spec of job or remove a specific job. So for these reasons, I decided to create another cron lib based on robfig/cron.

License

This software is released under the Apache 2.0 license.

# Functions

Every returns a crontab Schedule that activates once every duration.
New returns a new Cron job runner, in the Local time zone.
Creates a custom Parser with custom options.
NewWithLocation returns a new Cron job runner.
Parse returns a new crontab schedule representing the given spec.
ParseStandard returns a new crontab schedule representing the given standardSpec (https://en.wikipedia.org/wiki/Cron).

# Constants

Allow descriptors such as @monthly, @weekly, etc.
Day of month field, default *.
Day of week field, default *.
Optional day of week field, default *.
Hours field, default 0.
Minutes field, default 0.
Month field, default *.
Seconds field, default 0.

# Structs

ConstantDelaySchedule represents a simple recurring duty cycle, e.g.
Cron keeps track of any number of entries, invoking the associated func as specified by the schedule.
Entry
Entry consists of a schedule and the func to execute on that schedule.
No description provided by the author
A custom Parser that can be configured.
SpecSchedule specifies a duty cycle (to the second granularity), based on a traditional crontab specification.

# Interfaces

Job is an interface for submitted cron jobs.
The Schedule describes a job's duty cycle.

# Type aliases

A wrapper that turns a func() into a cron.Job.
Configuration options for creating a parser.