Documentation
¶
Index ¶
- Constants
- Variables
- func CronTimerUntil(work func(), timestep time.Duration, stopCh <-chan struct{})
- func IsScheduleEqual(orig, updated *execution.ScheduleSpec) (bool, error)
- func JobConfigKeyFunc(config *execution.JobConfig, scheduleTime time.Time) (string, error)
- func ParseUnix(unixString string) (time.Time, error)
- func SplitJobConfigKeyName(key string) (name string, ts time.Time, err error)
- type Context
- type Controller
- type CronWorker
- type Factory
- type InformerWorker
- type Reconciler
- type Schedule
- func (w *Schedule) BumpNextScheduleTime(jobConfig *execution.JobConfig, fromTime time.Time, expr *cronexpr.Expression)
- func (w *Schedule) FlushNextScheduleTime(jobConfig *execution.JobConfig)
- func (w *Schedule) GetNextScheduleTime(jobConfig *execution.JobConfig, fromTime time.Time, expr *cronexpr.Expression) time.Time
Constants ¶
const ( // CronWorkerInterval is the interval between checking if JobConfigs should be // enqueued. We only really need this as small as once per second. CronWorkerInterval = time.Second )
Variables ¶
var ( // Clock is exposed for unit tests. Note that multiple components may share // references to the same clock in this package. Clock clock.Clock = clock.RealClock{} )
Functions ¶
func CronTimerUntil ¶
CronTimerUntil runs work every timestep until stopCh is signaled. The work function will first be called immediately on initial call, followed by rounding up to the nearest timestep for every subsequent step. The smallest timestep that is admissible is a second.
func IsScheduleEqual ¶
func IsScheduleEqual(orig, updated *execution.ScheduleSpec) (bool, error)
IsScheduleEqual returns true if the ScheduleSpec is not equal and should be updated. This equality check is only true in the context of the CronController.
func JobConfigKeyFunc ¶
JobConfigKeyFunc returns a key to return the key for a JobConfig with the scheduled timestamp.
Types ¶
type Context ¶
type Context struct { controllercontext.ContextInterface // contains filtered or unexported fields }
Context extends the common controllercontext.Context.
func NewContext ¶
func NewContext(context controllercontext.ContextInterface) *Context
type Controller ¶
type Controller struct { *Context // contains filtered or unexported fields }
Controller is responsible for creating new Jobs from JobConfigs based on their cron schedule.
func NewController ¶
func NewController( ctrlContext controllercontext.ContextInterface, concurrency *configv1.Concurrency, ) (*Controller, error)
func (*Controller) GetHealth ¶
func (c *Controller) GetHealth() controllermanager.HealthStatus
func (*Controller) Shutdown ¶
func (c *Controller) Shutdown(ctx context.Context)
type CronWorker ¶
CronWorker enqueues Job names to be scheduled, based on the cron schedule of the config. It will enqueue one item for each schedule interval, which is a 1:1 correspondence with a Job to be created.
func NewCronWorker ¶
func NewCronWorker(ctrlContext *Context) *CronWorker
func (*CronWorker) Start ¶
func (w *CronWorker) Start(stopCh <-chan struct{})
func (*CronWorker) WorkerName ¶
func (w *CronWorker) WorkerName() string
type Factory ¶
type Factory struct{}
func NewFactory ¶
func NewFactory() *Factory
func (*Factory) New ¶
func (f *Factory) New( ctrlContext controllercontext.ContextInterface, concurrencySpec *v1.ExecutionControllerConcurrencySpec, ) (controllermanager.Controller, error)
type InformerWorker ¶
type InformerWorker struct {
*Context
}
InformerWorker receives events from the informer and enqueues work to be done for the controller.
func NewInformerWorker ¶
func NewInformerWorker(ctrlContext *Context) *InformerWorker
func (*InformerWorker) WorkerName ¶
func (w *InformerWorker) WorkerName() string
type Reconciler ¶
type Reconciler struct { *Context // contains filtered or unexported fields }
func NewReconciler ¶
func NewReconciler(ctrlContext *Context, concurrency *configv1.Concurrency) *Reconciler
func (*Reconciler) Concurrency ¶
func (w *Reconciler) Concurrency() int
func (*Reconciler) MaxRequeues ¶
func (w *Reconciler) MaxRequeues() int
func (*Reconciler) Name ¶
func (w *Reconciler) Name() string
type Schedule ¶
type Schedule struct {
// contains filtered or unexported fields
}
Schedule is a thread-safe store for the next schedule time of JobConfigs.
func NewSchedule ¶
func NewSchedule(ctrlContext controllercontext.ContextInterface) *Schedule
func (*Schedule) BumpNextScheduleTime ¶
func (w *Schedule) BumpNextScheduleTime( jobConfig *execution.JobConfig, fromTime time.Time, expr *cronexpr.Expression, )
BumpNextScheduleTime updates the next schedule time of a JobConfig.
func (*Schedule) FlushNextScheduleTime ¶
FlushNextScheduleTime flushes the next schedule time for a JobConfig, causing it to be recomputed on the next time GetNextScheduleTime is called.
func (*Schedule) GetNextScheduleTime ¶
func (w *Schedule) GetNextScheduleTime( jobConfig *execution.JobConfig, fromTime time.Time, expr *cronexpr.Expression, ) time.Time
GetNextScheduleTime returns the next expected schedule time for a JobConfig. This encapsulates the core logic for deciding if a Job should be enqueued. Returns a zero-value time if the cron expression does not have any timestamp in the future. The cron expression is interpreted relative to the timezone of fromTime.