Documentation
¶
Overview ¶
Package cron_parser implements a subset of the standard five-fields cron syntax.
It does not support special times like '@yearly", user names, seconds, or the "H" Jenkins notation.
It only handles Sunday == 0, not Sunday == 7.
Index ¶
Constants ¶
View Source
const ( ErrEmptySpec = ErrorString("empty spec string") ErrFiveFields = ErrorString("expected 5 fields") ErrIntParsing = ErrorString("failed to parse int from") ErrInvalidString = ErrorString("invalid UTF-8 string") ErrMultipleHyphens = ErrorString("too many hyphens") ErrMultipleSlashes = ErrorString("too many slashes") ErrNeedsPositive = ErrorString("should be a positive number") ErrRangeAboveMax = ErrorString("above maximum") ErrRangeBelowMin = ErrorString("below minimum") ErrRangeBeyond = ErrorString("beyond end of range") Wildcard = "*" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicSelector ¶
type BasicSelector struct { Len int // The number of elements in the range Label string // The string describing the selector role Start byte // The first element // contains filtered or unexported fields }
BasicSelector is a struct implementation of Selector.
func (*BasicSelector) ApplySource ¶
func (bs *BasicSelector) ApplySource(src string) error
func (*BasicSelector) Enumerate ¶
func (bs *BasicSelector) Enumerate() []byte
func (*BasicSelector) String ¶
func (bs *BasicSelector) String() string
type CronExpression ¶
type CronExpression struct { Minute Selector Hour Selector Day Selector Month Selector Weekday Selector Command string }
func ParseCron ¶
func ParseCron(expr string) (*CronExpression, error)
func (*CronExpression) String ¶
func (c *CronExpression) String() string
type ErrorString ¶
type ErrorString string
ErrorString is a string used as an error.
func (ErrorString) Error ¶
func (e ErrorString) Error() string
Error implements the builtin error interface.
type Selector ¶
type Selector interface { // ApplySource completes the selector by applying a source expression to it and parsing. // // It assumes the argument to be a valid UTF-8 string. ApplySource(string) error // Enumerate emits the list of integers designated by the Selector Enumerate() []byte fmt.Stringer }
Selector describes one of the 5 time-related fields at the beginning of crontab line.
type SelectorBuilder ¶
type SelectorBuilder func() Selector
var ( MinuteSelector SelectorBuilder = func() Selector { return &BasicSelector{Len: 60, Start: 0, Label: "minute"} } HourSelector SelectorBuilder = func() Selector { return &BasicSelector{Len: 24, Start: 0, Label: "hour"} } DaySelector SelectorBuilder = func() Selector { return &BasicSelector{Len: 31, Start: 1, Label: "day of month"} } MonthSelector SelectorBuilder = func() Selector { return &BasicSelector{Len: 12, Start: 1, Label: "month"} } WeekDaySelector SelectorBuilder = func() Selector { return &BasicSelector{Len: 7, Start: 0, Label: "day of week"} } )
Click to show internal directories.
Click to hide internal directories.