Documentation ¶
Overview ¶
Package workers for job worker managed by controller-runtime manager
Index ¶
- Variables
- type CronWorker
- func (cw *CronWorker) CheckSetup(ctx context.Context, manager manager.Manager, logger *zap.SugaredLogger) error
- func (cw *CronWorker) Name() string
- func (cw *CronWorker) NeedLeaderElection() bool
- func (cw *CronWorker) Setup(ctx context.Context, manager manager.Manager, logger *zap.SugaredLogger) error
- func (cw *CronWorker) Start(ctx context.Context) error
- type JobRunnable
Constants ¶
This section is empty.
Variables ¶
View Source
var ConfigWatcherFunc = func(cw *CronWorker) func(c *config.Config) { return func(c *config.Config) { for i, job := range cw.jobs { spec := metav1alpha1.DataMap(c.Data).MustStringVal(job.name, "0 0 * * *") newEntryID, err := cw.cron.AddJob(spec, job.funcJob) if err != nil { cw.Errorw("config watcher update cron job error", "err", err) return } if job.entryID > 0 { cw.cron.Remove(job.entryID) } cw.jobs[i].entryID = newEntryID cw.Debugf("ConfigWatcherFunc fallback: set job %s cron spec to %s", job.name, spec) } } }
ConfigWatcherFunc is the default watch func
Functions ¶
This section is empty.
Types ¶
type CronWorker ¶
type CronWorker struct { Runners []JobRunnable *zap.SugaredLogger // contains filtered or unexported fields }
CronWorker maintains a list of runners and dedicated to cron watched by configManager
func (*CronWorker) CheckSetup ¶
func (cw *CronWorker) CheckSetup(ctx context.Context, manager manager.Manager, logger *zap.SugaredLogger) error
func (*CronWorker) Name ¶
func (cw *CronWorker) Name() string
func (*CronWorker) NeedLeaderElection ¶
func (cw *CronWorker) NeedLeaderElection() bool
NeedLeaderElection indicates cron worker
func (*CronWorker) Setup ¶
func (cw *CronWorker) Setup(ctx context.Context, manager manager.Manager, logger *zap.SugaredLogger) error
type JobRunnable ¶
type JobRunnable interface { Setup(ctx context.Context, kclient client.Client, restClient *resty.Client) error // JobName is identical to config key name from configManager JobName() string // RunFunc returns the cron callback func to be invoked RunFunc(ctx context.Context) func() }
JobRunnable provides runnable methods to managed by worker
Click to show internal directories.
Click to hide internal directories.