runnables

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 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 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 EnableAfterBecameLeader

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

EnableAfterBecameLeader is a Runnable that will call the enable function when the current instance becomes the leader.

func NewEnableAfterBecameLeader

func NewEnableAfterBecameLeader(enable func(context.Context)) *EnableAfterBecameLeader

NewEnableAfterBecameLeader creates a new EnableAfterBecameLeader Runnable.

func (*EnableAfterBecameLeader) NeedLeaderElection

func (j *EnableAfterBecameLeader) NeedLeaderElection() bool

func (*EnableAfterBecameLeader) Start

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