Documentation ¶
Overview ¶
Package service provides top level scheduler. Combined all elements (cron, resumer and crontab updater) together
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cron ¶
type Cron interface { Start() Stop() context.Context Entries() []cron.Entry Schedule(schedule cron.Schedule, cmd cron.Job) cron.EntryID Remove(id cron.EntryID) }
Cron interface defines basic robfig/cron methods used by service
type CrontabParser ¶
type CrontabParser interface { String() string List() (result []crontab.JobSpec, err error) Changes(ctx context.Context) (<-chan []crontab.JobSpec, error) }
CrontabParser interface loads the list of jobs and provides updates channel if the corresponding crontab file updated
type DayParser ¶
type DayParser struct {
// contains filtered or unexported fields
}
DayParser for command line containing template elements from tmpl, like {{.YYYYMMDD}} replaces all occurrences of such templates. Handles business day detection for templates including "EOD" (i.e. YYYYMMDDEOD).
func NewDayTemplate ¶
NewDayTemplate makes day parser for given date
type DeDup ¶ added in v0.2.0
type DeDup struct {
// contains filtered or unexported fields
}
DeDup implements thread safe map to register/unregister command in order to prevent dbl registration
func NewDeDup ¶ added in v0.2.0
NewDeDup creates DeDup. Object safe to use with default params (disabled)
type Dedupper ¶ added in v0.4.0
Dedupper defines a locking primitive to register/unregister command in order to prevent dbl registration
type ErrorWriter ¶
type ErrorWriter struct {
// contains filtered or unexported fields
}
ErrorWriter implements error and collect log messages. Not thread safe
func NewErrorWriter ¶
func NewErrorWriter(maximum int) *ErrorWriter
NewErrorWriter makes io.Writer and error capturing data in and limit to last max lines
func (*ErrorWriter) Error ¶
func (e *ErrorWriter) Error() string
Error returns string combining the error and log
type HolidayChecker ¶
HolidayChecker is a single-method interface returning status of the day
type HolidayCheckerFunc ¶
HolidayCheckerFunc is an adapter to allow the use of ordinary functions as HolidayChecker.
type LogPrefixer ¶ added in v0.2.0
type LogPrefixer struct {
// contains filtered or unexported fields
}
LogPrefixer implements `io.writer` interface and adds prefix to each output line.
func NewLogPrefixer ¶ added in v0.2.0
func NewLogPrefixer(writer io.Writer, command string) *LogPrefixer
NewLogPrefixer initializes log prefixer.
type Notifier ¶
type Notifier interface { Send(ctx context.Context, subj, text string) error IsOnError() bool IsOnCompletion() bool MakeErrorHTML(spec, command, errorLog string) (string, error) MakeCompletionHTML(spec, command string) (string, error) }
Notifier interface defines notification delivery on failed executions
type Option ¶
type Option func(l *DayParser)
Option func type
func Holiday ¶
func Holiday(checker HolidayChecker) Option
Holiday sets a checker detecting if the current day is a holiday. Used for business days related logic.
func SkipWeekDays ¶
SkipWeekDays sets a list of weekdays to skip in detection of the current, next and prev. business days
type Resumer ¶
type Resumer interface { OnStart(cmd string) (string, error) OnFinish(fname string) error List() (res []resumer.Cmd) String() string }
Resumer defines interface for resumer.Resumer providing auto-restart for failed jobs
type Scheduler ¶
type Scheduler struct { Cron Resumer Resumer ResumeConcurrency int CrontabParser CrontabParser UpdatesEnabled bool Jitter time.Duration Notifier Notifier DeDup Dedupper HostName string MaxLogLines int EnableLogPrefix bool Repeater Repeater Stdout io.Writer NotifyTimeout time.Duration }
Scheduler is a top-level service wiring cron, resumer ans parser and provifing the main entry point (blocking) to start the process