Documentation
¶
Overview ¶
Package cron is an implementation of a job scheduler to run within a worker or a server. It allows developers to configure flexible schedules to run jobs, and trigger retries on failure.
Index ¶
- Constants
- Variables
- func Deref(t *time.Time) time.Time
- func FormatTime(t time.Time) string
- func IsContextCancelled(ctx context.Context) bool
- func IsJobAlreadyLoaded(err error) bool
- func IsJobCancelled(err error) bool
- func IsJobNotFound(err error) bool
- func IsJobNotLoaded(err error) bool
- func IsWeekDay(day time.Weekday) bool
- func IsWeekendDay(day time.Weekday) bool
- func Max(t1, t2 time.Time) time.Time
- func Min(t1, t2 time.Time) time.Time
- func NewEventListener(listener func(e *Event)) logger.Listener
- func NewJobInvocationID() string
- func Now() time.Time
- func Optional(t time.Time) *time.Time
- func SetDefault(jm *JobManager)
- func Since(t time.Time) time.Duration
- func WithJobInvocation(ctx context.Context, ji *JobInvocation) context.Context
- type Action
- type Config
- type DailySchedule
- type EnabledProvider
- type Event
- func (e Event) Complete() bool
- func (e Event) Elapsed() time.Duration
- func (e Event) Err() error
- func (e Event) IsEnabled() bool
- func (e Event) IsWritable() bool
- func (e Event) JobName() string
- func (e *Event) WithAnnotation(key, value string) *Event
- func (e *Event) WithElapsed(d time.Duration) *Event
- func (e *Event) WithErr(err error) *Event
- func (e *Event) WithFlag(f logger.Flag) *Event
- func (e *Event) WithHeadings(headings ...string) *Event
- func (e *Event) WithIsEnabled(isEnabled bool) *Event
- func (e *Event) WithIsWritable(isWritable bool) *Event
- func (e *Event) WithJobName(jobName string) *Event
- func (e *Event) WithLabel(key, value string) *Event
- func (e *Event) WithTimestamp(ts time.Time) *Event
- func (e Event) WriteJSON() logger.JSONObj
- func (e Event) WriteText(tf logger.TextFormatter, buf *bytes.Buffer)
- type ImmediateSchedule
- type IntervalSchedule
- type Job
- type JobBuilder
- func (jb *JobBuilder) Enabled() bool
- func (jb *JobBuilder) Execute(ctx context.Context) error
- func (jb *JobBuilder) Name() string
- func (jb *JobBuilder) OnBroken(ctx context.Context)
- func (jb *JobBuilder) OnCancellation(ctx context.Context)
- func (jb *JobBuilder) OnComplete(ctx context.Context)
- func (jb *JobBuilder) OnFailure(ctx context.Context)
- func (jb *JobBuilder) OnFixed(ctx context.Context)
- func (jb *JobBuilder) OnStart(ctx context.Context)
- func (jb *JobBuilder) Schedule() Schedule
- func (jb *JobBuilder) ShouldTriggerListeners() bool
- func (jb *JobBuilder) ShouldWriteOutput() bool
- func (jb *JobBuilder) Timeout() (timeout time.Duration)
- func (jb *JobBuilder) WithAction(action Action) *JobBuilder
- func (jb *JobBuilder) WithEnabledProvider(enabledProvider func() bool) *JobBuilder
- func (jb *JobBuilder) WithName(name string) *JobBuilder
- func (jb *JobBuilder) WithOnBroken(receiver func(*JobInvocation)) *JobBuilder
- func (jb *JobBuilder) WithOnCancellation(receiver func(*JobInvocation)) *JobBuilder
- func (jb *JobBuilder) WithOnComplete(receiver func(*JobInvocation)) *JobBuilder
- func (jb *JobBuilder) WithOnFailure(receiver func(*JobInvocation)) *JobBuilder
- func (jb *JobBuilder) WithOnFixed(receiver func(*JobInvocation)) *JobBuilder
- func (jb *JobBuilder) WithOnStart(receiver func(*JobInvocation)) *JobBuilder
- func (jb *JobBuilder) WithSchedule(schedule Schedule) *JobBuilder
- func (jb *JobBuilder) WithShouldTriggerListenersProvider(provider func() bool) *JobBuilder
- func (jb *JobBuilder) WithShouldWriteOutputProvider(provider func() bool) *JobBuilder
- func (jb *JobBuilder) WithTimeoutProvider(timeoutProvider func() time.Duration) *JobBuilder
- type JobInvocation
- type JobManager
- func (jm *JobManager) CancelJob(jobName string) (err error)
- func (jm *JobManager) DisableJob(jobName string) error
- func (jm *JobManager) DisableJobs(jobNames ...string) error
- func (jm *JobManager) EnableJob(jobName string) error
- func (jm *JobManager) EnableJobs(jobNames ...string) error
- func (jm *JobManager) HasJob(jobName string) (hasJob bool)
- func (jm *JobManager) IsJobDisabled(jobName string) (value bool)
- func (jm *JobManager) IsJobRunning(jobName string) (isRunning bool)
- func (jm *JobManager) IsRunning() bool
- func (jm *JobManager) Job(jobName string) (job *JobMeta, err error)
- func (jm *JobManager) Latch() *async.Latch
- func (jm *JobManager) LoadJob(job Job) error
- func (jm *JobManager) LoadJobs(jobs ...Job) error
- func (jm *JobManager) Logger() *logger.Logger
- func (jm *JobManager) NotifyStarted() <-chan struct{}
- func (jm *JobManager) NotifyStopped() <-chan struct{}
- func (jm *JobManager) RunAllJobs()
- func (jm *JobManager) RunJob(jobName string) error
- func (jm *JobManager) RunJobs(jobNames ...string) error
- func (jm *JobManager) Start() error
- func (jm *JobManager) Status() *Status
- func (jm *JobManager) Stop() error
- func (jm *JobManager) Tracer() Tracer
- func (jm *JobManager) WithLogger(log *logger.Logger) *JobManager
- func (jm *JobManager) WithTracer(tracer Tracer) *JobManager
- type JobMeta
- type OnBrokenReceiver
- type OnCancellationReceiver
- type OnCompleteReceiver
- type OnFailureReceiver
- type OnFixedReceiver
- type OnStartReceiver
- type OnTheHourAt
- type OnceAtUTCSchedule
- type Schedule
- func DailyAtUTC(hour, minute, second int) Schedule
- func Every(interval time.Duration) Schedule
- func EveryHour() Schedule
- func EveryHourAt(minute, second int) Schedule
- func EveryHourOnTheHour() Schedule
- func EveryMinute() Schedule
- func EverySecond() Schedule
- func OnceAtUTC(t time.Time) Schedule
- func WeekdaysAtUTC(hour, minute, second int) Schedule
- func WeekendsAtUTC(hour, minute, second int) Schedule
- func WeeklyAtUTC(hour, minute, second int, days ...time.Weekday) Schedule
- type ScheduleProvider
- type SerialProvider
- type ShouldTriggerListenersProvider
- type ShouldWriteOutputProvider
- type State
- type Status
- type StatusProvider
- type TimeoutProvider
- type TraceFinisher
- type Tracer
Constants ¶
const ( // DefaultEnabled is a default. DefaultEnabled = true // DefaultSerial is a default. DefaultSerial = false // DefaultShouldWriteOutput is a default. DefaultShouldWriteOutput = true // DefaultShouldTriggerListeners is a default. DefaultShouldTriggerListeners = true )
const ( // FlagStarted is an event flag. FlagStarted logger.Flag = "cron.started" // FlagFailed is an event flag. FlagFailed logger.Flag = "cron.failed" // FlagCancelled is an event flag. FlagCancelled logger.Flag = "cron.cancelled" // FlagComplete is an event flag. FlagComplete logger.Flag = "cron.complete" // FlagBroken is an event flag. FlagBroken logger.Flag = "cron.broken" // FlagFixed is an event flag. FlagFixed logger.Flag = "cron.fixed" )
const ( // ErrJobNotLoaded is a common error. ErrJobNotLoaded exception.Class = "job not loaded" // ErrJobAlreadyLoaded is a common error. ErrJobAlreadyLoaded exception.Class = "job already loaded" // ErrJobNotFound is a common error. ErrJobNotFound exception.Class = "job not found" // ErrJobCancelled is a common error. ErrJobCancelled exception.Class = "job cancelled" )
const ( // AllDaysMask is a bitmask of all the days of the week. AllDaysMask = 1<<uint(time.Sunday) | 1<<uint(time.Monday) | 1<<uint(time.Tuesday) | 1<<uint(time.Wednesday) | 1<<uint(time.Thursday) | 1<<uint(time.Friday) | 1<<uint(time.Saturday) // WeekDaysMask is a bitmask of all the weekdays of the week. WeekDaysMask = 1<<uint(time.Monday) | 1<<uint(time.Tuesday) | 1<<uint(time.Wednesday) | 1<<uint(time.Thursday) | 1<<uint(time.Friday) //WeekendDaysMask is a bitmask of the weekend days of the week. WeekendDaysMask = 1<<uint(time.Sunday) | 1<<uint(time.Saturday) )
NOTE: we have to use shifts here because in their infinite wisdom google didn't make these values powers of two for masking
const ( // DefaultHeartbeatInterval is the interval between schedule next run checks. DefaultHeartbeatInterval = 50 * time.Millisecond )
const (
// EnvVarHeartbeatInterval is an environment variable name.
EnvVarHeartbeatInterval = "CRON_HEARTBEAT_INTERVAL"
)
Variables ¶
var ( // DaysOfWeek are all the time.Weekday in an array for utility purposes. DaysOfWeek = []time.Weekday{ time.Sunday, time.Monday, time.Tuesday, time.Wednesday, time.Thursday, time.Friday, time.Saturday, } // WeekDays are the business time.Weekday in an array. WeekDays = []time.Weekday{ time.Monday, time.Tuesday, time.Wednesday, time.Thursday, time.Friday, } // WeekWeekEndDaysDays are the weekend time.Weekday in an array. WeekendDays = []time.Weekday{ time.Sunday, time.Saturday, } // Epoch is unix epoch saved for utility purposes. Epoch = time.Unix(0, 0) )
NOTE: time.Zero()? what's that?
Functions ¶
func IsContextCancelled ¶ added in v0.3.2
IsContextCancelled check if a job is cancelled
func IsJobAlreadyLoaded ¶
IsJobAlreadyLoaded returns if the error is a job already loaded error.
func IsJobCancelled ¶
IsJobCancelled returns if the error is a task not found error.
func IsJobNotFound ¶ added in v0.3.2
IsJobNotFound returns if the error is a task not found error.
func IsJobNotLoaded ¶
IsJobNotLoaded returns if the error is a job not loaded error.
func IsWeekendDay ¶
IsWeekendDay returns if the day is a monday->friday.
func NewEventListener ¶
NewEventListener returns a new event listener.
func NewJobInvocationID ¶ added in v0.3.2
func NewJobInvocationID() string
NewJobInvocationID returns a new pseudo-unique job invocation identifier.
func WithJobInvocation ¶ added in v0.3.2
func WithJobInvocation(ctx context.Context, ji *JobInvocation) context.Context
WithJobInvocation adds a job invocation to a context as a value.
Types ¶
type Config ¶
type Config struct{}
Config is the config object.
func MustNewConfigFromEnv ¶
func MustNewConfigFromEnv() *Config
MustNewConfigFromEnv returns a new config set from environment variables, it will panic if there is an error.
func NewConfigFromEnv ¶
NewConfigFromEnv creates a new config from the environment.
type DailySchedule ¶
DailySchedule is a schedule that fires every day that satisfies the DayOfWeekMask at the given TimeOfDayUTC.
func (DailySchedule) GetNextRunTime ¶
func (ds DailySchedule) GetNextRunTime(after *time.Time) *time.Time
GetNextRunTime implements Schedule.
type EnabledProvider ¶
type EnabledProvider interface {
Enabled() bool
}
EnabledProvider is an optional interface that will allow jobs to control if they're enabled.
type Event ¶
Event is an event.
func (Event) IsWritable ¶
IsWritable determines if the event is written to the logger output.
func (*Event) WithAnnotation ¶
WithAnnotation adds an annotation to the event.
func (*Event) WithElapsed ¶
WithElapsed sets the elapsed time.
func (*Event) WithHeadings ¶
WithHeadings sets the headings.
func (*Event) WithIsEnabled ¶
WithIsEnabled sets if the event is enabled
func (*Event) WithIsWritable ¶
WithIsWritable sets if the event is writable.
func (*Event) WithJobName ¶ added in v0.3.2
WithJobName sets the job name.
func (*Event) WithTimestamp ¶
WithTimestamp sets the message timestamp.
type ImmediateSchedule ¶
ImmediateSchedule fires immediately with an optional continuation schedule.
func Immediately ¶
func Immediately() *ImmediateSchedule
Immediately Returns a schedule that casues a job to run immediately on start, with an optional subsequent schedule.
func (*ImmediateSchedule) GetNextRunTime ¶
func (i *ImmediateSchedule) GetNextRunTime(after *time.Time) *time.Time
GetNextRunTime implements Schedule.
func (*ImmediateSchedule) Then ¶
func (i *ImmediateSchedule) Then(then Schedule) Schedule
Then allows you to specify a subsequent schedule after the first run.
type IntervalSchedule ¶
IntervalSchedule is as chedule that fires every given interval with an optional start delay.
func (IntervalSchedule) GetNextRunTime ¶
func (i IntervalSchedule) GetNextRunTime(after *time.Time) *time.Time
GetNextRunTime implements Schedule.
type JobBuilder ¶ added in v0.3.2
type JobBuilder struct {
// contains filtered or unexported fields
}
JobBuilder allows for job creation w/o a fully formed struct.
func (*JobBuilder) Enabled ¶ added in v0.3.2
func (jb *JobBuilder) Enabled() bool
Enabled returns if the job is enabled.
func (*JobBuilder) Execute ¶ added in v0.3.2
func (jb *JobBuilder) Execute(ctx context.Context) error
Execute runs the job action if it's set.
func (*JobBuilder) Name ¶ added in v0.3.2
func (jb *JobBuilder) Name() string
Name returns the job name.
func (*JobBuilder) OnBroken ¶ added in v0.3.2
func (jb *JobBuilder) OnBroken(ctx context.Context)
OnBroken is a lifecycle hook.
func (*JobBuilder) OnCancellation ¶ added in v0.3.2
func (jb *JobBuilder) OnCancellation(ctx context.Context)
OnCancellation is a lifecycle hook.
func (*JobBuilder) OnComplete ¶ added in v0.3.2
func (jb *JobBuilder) OnComplete(ctx context.Context)
OnComplete is a lifecycle hook.
func (*JobBuilder) OnFailure ¶ added in v0.3.2
func (jb *JobBuilder) OnFailure(ctx context.Context)
OnFailure is a lifecycle hook.
func (*JobBuilder) OnFixed ¶ added in v0.3.2
func (jb *JobBuilder) OnFixed(ctx context.Context)
OnFixed is a lifecycle hook.
func (*JobBuilder) OnStart ¶ added in v0.3.2
func (jb *JobBuilder) OnStart(ctx context.Context)
OnStart is a lifecycle hook.
func (*JobBuilder) Schedule ¶ added in v0.3.2
func (jb *JobBuilder) Schedule() Schedule
Schedule returns the job schedule.
func (*JobBuilder) ShouldTriggerListeners ¶ added in v0.3.2
func (jb *JobBuilder) ShouldTriggerListeners() bool
ShouldTriggerListeners implements the should trigger listeners provider.
func (*JobBuilder) ShouldWriteOutput ¶ added in v0.3.2
func (jb *JobBuilder) ShouldWriteOutput() bool
ShouldWriteOutput implements the should write output provider.
func (*JobBuilder) Timeout ¶ added in v0.3.2
func (jb *JobBuilder) Timeout() (timeout time.Duration)
Timeout returns the job timeout.
func (*JobBuilder) WithAction ¶ added in v0.3.2
func (jb *JobBuilder) WithAction(action Action) *JobBuilder
WithAction sets the job action.
func (*JobBuilder) WithEnabledProvider ¶ added in v0.3.2
func (jb *JobBuilder) WithEnabledProvider(enabledProvider func() bool) *JobBuilder
WithEnabledProvider sets the enabled provider for the job.
func (*JobBuilder) WithName ¶ added in v0.3.2
func (jb *JobBuilder) WithName(name string) *JobBuilder
WithName sets the job name.
func (*JobBuilder) WithOnBroken ¶ added in v0.3.2
func (jb *JobBuilder) WithOnBroken(receiver func(*JobInvocation)) *JobBuilder
WithOnBroken sets a lifecycle handler.
func (*JobBuilder) WithOnCancellation ¶ added in v0.3.2
func (jb *JobBuilder) WithOnCancellation(receiver func(*JobInvocation)) *JobBuilder
WithOnCancellation sets a lifecycle handler.
func (*JobBuilder) WithOnComplete ¶ added in v0.3.2
func (jb *JobBuilder) WithOnComplete(receiver func(*JobInvocation)) *JobBuilder
WithOnComplete sets a lifecycle handler.
func (*JobBuilder) WithOnFailure ¶ added in v0.3.2
func (jb *JobBuilder) WithOnFailure(receiver func(*JobInvocation)) *JobBuilder
WithOnFailure sets a lifecycle handler.
func (*JobBuilder) WithOnFixed ¶ added in v0.3.2
func (jb *JobBuilder) WithOnFixed(receiver func(*JobInvocation)) *JobBuilder
WithOnFixed sets a lifecycle handler.
func (*JobBuilder) WithOnStart ¶ added in v0.3.2
func (jb *JobBuilder) WithOnStart(receiver func(*JobInvocation)) *JobBuilder
WithOnStart sets a lifecycle handler.
func (*JobBuilder) WithSchedule ¶ added in v0.3.2
func (jb *JobBuilder) WithSchedule(schedule Schedule) *JobBuilder
WithSchedule sets the schedule for the job.
func (*JobBuilder) WithShouldTriggerListenersProvider ¶ added in v0.3.2
func (jb *JobBuilder) WithShouldTriggerListenersProvider(provider func() bool) *JobBuilder
WithShouldTriggerListenersProvider sets the enabled provider for the job.
func (*JobBuilder) WithShouldWriteOutputProvider ¶ added in v0.3.2
func (jb *JobBuilder) WithShouldWriteOutputProvider(provider func() bool) *JobBuilder
WithShouldWriteOutputProvider sets the enabled provider for the job.
func (*JobBuilder) WithTimeoutProvider ¶ added in v0.3.2
func (jb *JobBuilder) WithTimeoutProvider(timeoutProvider func() time.Duration) *JobBuilder
WithTimeoutProvider sets the timeout provider.
type JobInvocation ¶ added in v0.3.2
type JobInvocation struct {
ID string `json:"id"`
Name string `json:"name"`
JobMeta *JobMeta `json:"-"`
StartTime time.Time `json:"startTime"`
Timeout time.Time `json:"timeout"`
Err error `json:"err"`
Elapsed time.Duration `json:"elapsed"`
Context context.Context `json:"-"`
Cancel context.CancelFunc `json:"-"`
}
JobInvocation is metadata for a job invocation (or instance of a job running).
func GetJobInvocation ¶ added in v0.3.2
func GetJobInvocation(ctx context.Context) *JobInvocation
GetJobInvocation returns the job invocation ID from a context.
type JobManager ¶
JobManager is the main orchestration and job management object.
func Default ¶
func Default() *JobManager
Default returns a shared instance of a JobManager. If unset, it will initialize it with `New()`.
func MustNewFromEnv ¶
func MustNewFromEnv() *JobManager
MustNewFromEnv returns a new job manager from the environment.
func NewFromConfig ¶
func NewFromConfig(cfg *Config) *JobManager
NewFromConfig returns a new job manager from a given config.
func NewFromEnv ¶
func NewFromEnv() (*JobManager, error)
NewFromEnv returns a new job manager from the environment.
func (*JobManager) CancelJob ¶ added in v0.3.2
func (jm *JobManager) CancelJob(jobName string) (err error)
CancelJob cancels (sends the cancellation signal) to a running job.
func (*JobManager) DisableJob ¶
func (jm *JobManager) DisableJob(jobName string) error
DisableJob stops a job from running but does not unload it.
func (*JobManager) DisableJobs ¶
func (jm *JobManager) DisableJobs(jobNames ...string) error
DisableJobs disables a variadic list of job names.
func (*JobManager) EnableJob ¶
func (jm *JobManager) EnableJob(jobName string) error
EnableJob enables a job that has been disabled.
func (*JobManager) EnableJobs ¶
func (jm *JobManager) EnableJobs(jobNames ...string) error
EnableJobs enables a variadic list of job names.
func (*JobManager) HasJob ¶
func (jm *JobManager) HasJob(jobName string) (hasJob bool)
HasJob returns if a jobName is loaded or not.
func (*JobManager) IsJobDisabled ¶ added in v0.3.2
func (jm *JobManager) IsJobDisabled(jobName string) (value bool)
IsJobDisabled returns if a job is disabled.
func (*JobManager) IsJobRunning ¶ added in v0.3.2
func (jm *JobManager) IsJobRunning(jobName string) (isRunning bool)
IsJobRunning returns if a task is currently running.
func (*JobManager) IsRunning ¶
func (jm *JobManager) IsRunning() bool
IsRunning returns if the job manager is running. It serves as an authoritative healthcheck.
func (*JobManager) Job ¶
func (jm *JobManager) Job(jobName string) (job *JobMeta, err error)
Job returns a job metadata by name.
func (*JobManager) Latch ¶ added in v0.3.2
func (jm *JobManager) Latch() *async.Latch
Latch returns the internal latch.
func (*JobManager) LoadJobs ¶
func (jm *JobManager) LoadJobs(jobs ...Job) error
LoadJobs loads a variadic list of jobs.
func (*JobManager) Logger ¶
func (jm *JobManager) Logger() *logger.Logger
Logger returns the diagnostics agent.
func (*JobManager) NotifyStarted ¶ added in v0.3.1
func (jm *JobManager) NotifyStarted() <-chan struct{}
NotifyStarted returns the started notification channel.
func (*JobManager) NotifyStopped ¶ added in v0.3.1
func (jm *JobManager) NotifyStopped() <-chan struct{}
NotifyStopped returns the stopped notification channel.
func (*JobManager) RunAllJobs ¶
func (jm *JobManager) RunAllJobs()
RunAllJobs runs every job that has been loaded in the JobManager at once.
func (*JobManager) RunJob ¶
func (jm *JobManager) RunJob(jobName string) error
RunJob runs a job by jobName on demand.
func (*JobManager) RunJobs ¶
func (jm *JobManager) RunJobs(jobNames ...string) error
RunJobs runs a variadic list of job names.
func (*JobManager) Start ¶
func (jm *JobManager) Start() error
Start begins the schedule runner for a JobManager.
func (*JobManager) Stop ¶
func (jm *JobManager) Stop() error
Stop stops the schedule runner for a JobManager.
func (*JobManager) Tracer ¶
func (jm *JobManager) Tracer() Tracer
Tracer returns the manager's tracer.
func (*JobManager) WithLogger ¶
func (jm *JobManager) WithLogger(log *logger.Logger) *JobManager
WithLogger sets the logger and returns a reference to the job manager.
func (*JobManager) WithTracer ¶
func (jm *JobManager) WithTracer(tracer Tracer) *JobManager
WithTracer sets the manager's tracer.
type JobMeta ¶
type JobMeta struct {
Name string `json:"name"`
Job Job `json:"-"`
Disabled bool `json:"disabled"`
NextRunTime time.Time `json:"nextRunTime"`
Last *JobInvocation `json:"last"`
// these are used at runtime and not serialized with the status.
Schedule Schedule `json:"-"`
EnabledProvider func() bool `json:"-"`
SerialProvider func() bool `json:"-"`
TimeoutProvider func() time.Duration `json:"-"`
ShouldTriggerListenersProvider func() bool `json:"-"`
ShouldWriteOutputProvider func() bool `json:"-"`
}
JobMeta is runtime metadata for a job.
type OnBrokenReceiver ¶ added in v0.3.2
OnBrokenReceiver is an interface that allows a job to be signaled when it is a failure that followed a previous success.
type OnCancellationReceiver ¶
OnCancellationReceiver is an interface that allows a task to be signaled when it has been canceled.
type OnCompleteReceiver ¶
OnCompleteReceiver is an interface that allows a task to be signaled when it has been completed.
type OnFailureReceiver ¶ added in v0.3.2
OnFailureReceiver is an interface that allows a task to be signaled when it has been completed.
type OnFixedReceiver ¶ added in v0.3.2
OnFixedReceiver is an interface that allows a jbo to be signaled when is a success that followed a previous failure.
type OnStartReceiver ¶
OnStartReceiver is an interface that allows a task to be signaled when it has started.
type OnTheHourAt ¶
OnTheHourAt is a schedule that fires every hour on the given minute.
func (OnTheHourAt) GetNextRunTime ¶
func (o OnTheHourAt) GetNextRunTime(after *time.Time) *time.Time
GetNextRunTime implements the chronometer Schedule api.
type OnceAtUTCSchedule ¶ added in v0.3.2
OnceAtUTCSchedule is a schedule.
func (OnceAtUTCSchedule) GetNextRunTime ¶ added in v0.3.2
func (oa OnceAtUTCSchedule) GetNextRunTime(after *time.Time) *time.Time
GetNextRunTime returns the next runtime.
type Schedule ¶
type Schedule interface {
// GetNextRuntime should return the next runtime after a given previous runtime. If `after` is <nil> it should be assumed
// the job hasn't run yet. If <nil> is returned by the schedule it is inferred that the job should not run again.
GetNextRunTime(*time.Time) *time.Time
}
Schedule is a type that provides a next runtime after a given previous runtime.
func DailyAtUTC ¶ added in v0.3.2
DailyAtUTC returns a schedule that fires every day at the given hour, minute and second in UTC.
func EveryHourAt ¶
EveryHourAt returns a schedule that fires every hour at a given minute.
func EveryHourOnTheHour ¶
func EveryHourOnTheHour() Schedule
EveryHourOnTheHour returns a schedule that fires every 60 minutes on the 00th minute.
func EveryMinute ¶
func EveryMinute() Schedule
EveryMinute returns a schedule that fires every minute.
func EverySecond ¶
func EverySecond() Schedule
EverySecond returns a schedule that fires every second.
func OnceAtUTC ¶ added in v0.3.2
OnceAtUTC returns a schedule that fires once at a given time. It will never fire again unless reloaded.
func WeekdaysAtUTC ¶ added in v0.3.2
WeekdaysAtUTC returns a schedule that fires every week day at the given hour, minute and second in UTC>
func WeekendsAtUTC ¶ added in v0.3.2
WeekendsAtUTC returns a schedule that fires every weekend day at the given hour, minut and second.
type ScheduleProvider ¶ added in v0.3.2
type ScheduleProvider interface {
Schedule() Schedule
}
ScheduleProvider returns a schedule for the job.
type SerialProvider ¶
type SerialProvider interface {
Serial() bool
}
SerialProvider is an optional interface that prohibits a task from running if another instance of the task is currently running.
type ShouldTriggerListenersProvider ¶ added in v0.3.2
type ShouldTriggerListenersProvider interface {
ShouldTriggerListeners() bool
}
ShouldTriggerListenersProvider is a type that enables or disables logger listeners.
type ShouldWriteOutputProvider ¶ added in v0.3.2
type ShouldWriteOutputProvider interface {
ShouldWriteOutput() bool
}
ShouldWriteOutputProvider is a type that enables or disables logger output for events.
type Status ¶
type Status struct {
Jobs []JobMeta
Running map[string]JobInvocation
}
Status is a status object
type StatusProvider ¶
type StatusProvider interface {
Status() string
}
StatusProvider is an interface that allows a task to report its status.
type TimeoutProvider ¶
TimeoutProvider is an interface that allows a task to be timed out.
type TraceFinisher ¶
TraceFinisher is a finisher for traces.