croncontroller

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2022 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Clock clock.Clock = &clock.RealClock{}
)

Functions

func ClockTickUntil added in v0.1.0

func ClockTickUntil(work func(), timestep time.Duration, stopCh <-chan struct{})

ClockTickUntil 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

func JobConfigKeyFunc(config *execution.JobConfig, scheduleTime time.Time) (string, error)

JobConfigKeyFunc returns a key to return the key for a JobConfig with the scheduled timestamp.

func JoinJobConfigKeyName added in v0.1.0

func JoinJobConfigKeyName(key string, ts time.Time) string

JoinJobConfigKeyName joins a key with a scheduled timestamp for a JobConfig. Performs the reverse of SplitJobConfigKeyName.

func ParseUnix

func ParseUnix(unixString string) (time.Time, error)

ParseUnix parses a Unix timestamp (in seconds) from a string.

func SplitJobConfigKeyName

func SplitJobConfigKeyName(key string) (name string, ts time.Time, err error)

SplitJobConfigKeyName splits a key into name and scheduled timestamp for a JobConfig.

Types

type Context

type Context struct {
	controllercontext.Context

	HasSynced []cache.InformerSynced
	// contains filtered or unexported fields
}

Context extends the common controllercontext.Context.

func NewContext

func NewContext(context controllercontext.Context) *Context

NewContext returns a new 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.Context,
	concurrency *configv1alpha1.Concurrency,
) (*Controller, error)

func (*Controller) GetHealth

func (c *Controller) GetHealth() controllermanager.HealthStatus

func (*Controller) Run

func (c *Controller) Run(ctx context.Context) error

func (*Controller) Shutdown

func (c *Controller) Shutdown(ctx context.Context)

type CronWorker

type CronWorker struct {
	*Context
	// contains filtered or unexported fields
}

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, handler EnqueueHandler) *CronWorker

func (*CronWorker) Init added in v0.2.1

func (w *CronWorker) Init() error

Init is called before we start the worker. We will initialize all JobConfigs into the Schedule.

func (*CronWorker) Start

func (w *CronWorker) Start(ctx context.Context)

func (*CronWorker) Work added in v0.1.0

func (w *CronWorker) Work()

Work runs a single iteration of synchronizing all JobConfigs.

func (*CronWorker) WorkerName

func (w *CronWorker) WorkerName() string

type EnqueueHandler added in v0.1.0

type EnqueueHandler interface {
	EnqueueJobConfig(jobConfig *execution.JobConfig, scheduleTime time.Time) error
}

EnqueueHandler knows how to enqueue a JobConfig to be created.

type ExecutionControl added in v0.1.0

type ExecutionControl struct {
	// contains filtered or unexported fields
}

ExecutionControl is a wrapper around the Execution clientset.

func NewExecutionControl added in v0.1.0

func NewExecutionControl(
	name string,
	client executionv1alpha1.ExecutionV1alpha1Interface,
	recorder Recorder,
) *ExecutionControl

func (*ExecutionControl) CreateJob added in v0.1.0

func (c *ExecutionControl) CreateJob(ctx context.Context, rjc *execution.JobConfig, rj *execution.Job) error

type ExecutionControlInterface added in v0.1.0

type ExecutionControlInterface interface {
	CreateJob(ctx context.Context, rjc *execution.JobConfig, rj *execution.Job) error
}

type Factory

type Factory struct{}

func NewFactory

func NewFactory() *Factory

func (*Factory) Name

func (f *Factory) Name() string

func (*Factory) New

type InformerWorker

type InformerWorker struct {
	*Context
	// contains filtered or unexported fields
}

InformerWorker receives events from the informer and enqueues work to be done for the controller.

func NewInformerWorker

func NewInformerWorker(ctrlContext *Context, handler UpdateHandler) *InformerWorker

func (*InformerWorker) Init added in v0.1.0

func (w *InformerWorker) Init()

func (*InformerWorker) WorkerName

func (w *InformerWorker) WorkerName() string

type Reconciler

type Reconciler struct {
	*Context
	// contains filtered or unexported fields
}

Reconciler creates Jobs that are queued to be started from the workqueue, with a schedule time and JobConfig, unless forbidden by the ConcurrencyPolicy. It may be possible for multiple workers to process the same JobConfig concurrently.

func NewReconciler

func NewReconciler(
	ctrlContext *Context,
	client ExecutionControlInterface,
	recorder Recorder,
	store controllercontext.ActiveJobStore,
	concurrency *configv1alpha1.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

func (*Reconciler) SyncOne

func (w *Reconciler) SyncOne(ctx context.Context, namespace, name string, _ int) error

type Recorder added in v0.1.0

type Recorder interface {
	// CreatedJob creates an event when a JobConfig created a new Job.
	CreatedJob(ctx context.Context, jobConfig *execution.JobConfig, job *execution.Job)

	// CreateJobFailed creates an event when a JobConfig failed to create a new Job.
	CreateJobFailed(ctx context.Context, jobConfig *execution.JobConfig, job *execution.Job, message string)

	// SkippedJobSchedule creates an event whenever a JobConfig's schedule was skipped for whatever reason.
	SkippedJobSchedule(ctx context.Context, jobConfig *execution.JobConfig, scheduleTime time.Time, message string)
}

Recorder knows how to record events for the CronController.

type UpdateHandler added in v0.1.0

type UpdateHandler interface {
	OnUpdate(*execution.JobConfig)
}

UpdateHandler knows how to handle updates for a JobConfig.

func NewUpdateHandler added in v0.1.0

func NewUpdateHandler(ctrlContext *Context) UpdateHandler

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL