runnables

package
v2.0.0-...-2f19ba8 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package runnables provides helper types for creating runnables for the controller-runtime manager when leader election is enabled.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallFunctionsAfterBecameLeader

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

CallFunctionsAfterBecameLeader is a Runnable that will call the given functions when the current instance becomes the leader.

func NewCallFunctionsAfterBecameLeader

func NewCallFunctionsAfterBecameLeader(
	enableFunctions []func(context.Context),
) *CallFunctionsAfterBecameLeader

NewCallFunctionsAfterBecameLeader creates a new CallFunctionsAfterBecameLeader Runnable.

func (*CallFunctionsAfterBecameLeader) NeedLeaderElection

func (j *CallFunctionsAfterBecameLeader) NeedLeaderElection() bool

func (*CallFunctionsAfterBecameLeader) Start

type CronJob

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

CronJob periodically runs a worker function.

func NewCronJob

func NewCronJob(cfg CronJobConfig) *CronJob

NewCronJob creates a new cronjob.

func (*CronJob) Start

func (j *CronJob) Start(ctx context.Context) error

Start starts the cronjob. Implements controller-runtime manager.Runnable.

type CronJobConfig

type CronJobConfig struct {
	// Worker is the function that will be run for every cronjob iteration.
	Worker func(context.Context)
	// ReadyCh delays the start of the job until the channel is closed.
	ReadyCh <-chan struct{}
	// Logger is the logger.
	Logger logr.Logger
	// Period defines the period of the cronjob. The cronjob will run every Period.
	Period time.Duration
	// JitterFactor sets the jitter for the cronjob. If positive, the period is jittered before every
	// run of the worker. If jitterFactor is not positive, the period is unchanged and not jittered.
	JitterFactor float64
}

CronJobConfig is the configuration for a cronjob.

type Leader

type Leader struct {
	manager.Runnable
}

Leader is a Runnable that needs to be run only when the current instance is the leader.

func (*Leader) NeedLeaderElection

func (r *Leader) NeedLeaderElection() bool

type LeaderOrNonLeader

type LeaderOrNonLeader struct {
	manager.Runnable
}

LeaderOrNonLeader is a Runnable that needs to be run regardless of whether the current instance is the leader.

func (*LeaderOrNonLeader) NeedLeaderElection

func (r *LeaderOrNonLeader) NeedLeaderElection() bool

Jump to

Keyboard shortcuts

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