workers

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package workers for job worker managed by controller-runtime manager

Index

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

func (*CronWorker) Start

func (cw *CronWorker) Start(ctx context.Context) error

Start starts cron and waits for context cancellation

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

Jump to

Keyboard shortcuts

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