queueinformer

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultResyncPeriod = 15 * time.Minute

Variables

This section is empty.

Functions

func NewLoopID

func NewLoopID() string

func ResyncWithJitter

func ResyncWithJitter(resyncPeriod time.Duration, factor float64) func() time.Duration

ResyncWithJitter takes a resync interval and adds jitter within a percent difference. factor is a value between 0 and 1 indicating the amount of jitter a factor of 0.2 and a period of 10m will have a range of 8 to 12 minutes (20%)

Types

type ExtensibleOperator added in v0.23.0

type ExtensibleOperator interface {
	// RegisterQueueInformer registers the given QueueInformer with the Operator.
	// This method returns an error if the Operator has already been started.
	RegisterQueueInformer(queueInformer *QueueInformer) error

	// RegisterInformer registers an informer with the Operator.
	// This method returns an error if the Operator has already been started.
	RegisterInformer(cache.SharedIndexInformer) error
}

ExtensibleOperator describes a Reconciler that can be extended with additional informers and queue informers

type KeyFunc

type KeyFunc func(obj interface{}) (string, bool)

KeyFunc returns a key for the given object and a bool which is true if the key was successfully generated and false otherwise.

type LegacySyncHandler

type LegacySyncHandler func(obj interface{}) error

LegacySyncHandler is a deprecated signature for syncing resources.

func (LegacySyncHandler) ToSyncer

func (l LegacySyncHandler) ToSyncer() kubestate.Syncer

ToSyncer returns the Syncer equivalent of the sync handler.

func (LegacySyncHandler) ToSyncerWithDelete

func (l LegacySyncHandler) ToSyncerWithDelete(onDelete func(obj interface{})) kubestate.Syncer

ToSyncerWithDelete returns the Syncer equivalent of the given sync handler and delete function.

type ObservableOperator added in v0.23.0

type ObservableOperator interface {
	// Ready returns a channel that is closed when the Operator is ready to run.
	Ready() <-chan struct{}

	// Done returns a channel that is closed when the Operator is done running.
	Done() <-chan struct{}

	// AtLevel returns a channel that emits errors when the Operator is not at level.
	AtLevel() <-chan error

	// Started returns true if RunInformers() has been called, false otherwise.
	Started() bool

	// HasSynced returns true if the Operator's Informers have synced, false otherwise.
	HasSynced() bool
}

ObservableOperator describes a Reconciler whose state can be queried

type Operator

type Operator interface {
	ObservableOperator
	ExtensibleOperator
	// RunInformers starts the Operator's underlying Informers.
	RunInformers(ctx context.Context)

	// Run starts the Operator and its underlying Informers.
	Run(ctx context.Context)
}

Operator describes a Reconciler that manages a set of QueueInformers.

func NewOperator

func NewOperator(sv discovery.ServerVersionInterface, options ...OperatorOption) (Operator, error)

NewOperator returns a new Operator configured to manage the cluster with the given server version client.

type OperatorOption

type OperatorOption func(*operatorConfig)

func WithInformers

func WithInformers(informers ...cache.SharedIndexInformer) OperatorOption

WithInformers registers a set of initial Informers with an Operator.

func WithNumWorkers

func WithNumWorkers(numWorkers int) OperatorOption

WithNumWorkers sets the number of workers an Operator uses to process each queue. It translates directly to the number of queue items processed in parallel for a given queue. Specifying zero or less workers is an invariant and will cause an error upon configuration. Specifying one worker indicates that each queue will only have one item processed at a time.

func WithOperatorLogger

func WithOperatorLogger(logger *logrus.Logger) OperatorOption

WithOperatorLogger sets the logger used by an Operator.

func WithQueueInformers

func WithQueueInformers(queueInformers ...*QueueInformer) OperatorOption

WithQueueInformers registers a set of initial QueueInformers with an Operator. If the QueueInformer is configured with a SharedIndexInformer, that SharedIndexInformer is registered with the Operator automatically.

type Option

type Option func(config *queueInformerConfig)

Option applies an option to the given queue informer config.

func WithIndexer

func WithIndexer(indexer cache.Indexer) Option

WithIndexer sets the indexer used by a QueueInformer.

func WithInformer

func WithInformer(informer cache.SharedIndexInformer) Option

WithInformer sets the informer used by a QueueInformer.

func WithKeyFunc

func WithKeyFunc(keyFunc KeyFunc) Option

WithKeyFunc sets the key func used by a QueueInformer.

func WithLogger

func WithLogger(logger *logrus.Logger) Option

WithLogger configures logger as the QueueInformer's Logger.

func WithMetricsProvider

func WithMetricsProvider(provider metrics.MetricsProvider) Option

WithMetricsProvider configures the QueueInformer's MetricsProvider as provider.

func WithQueue

func WithQueue(queue workqueue.RateLimitingInterface) Option

WithQueue sets the queue used by a QueueInformer.

func WithSyncer

func WithSyncer(syncer kubestate.Syncer) Option

WithSyncer sets the syncer invoked by a QueueInformer.

type QueueInformer

type QueueInformer struct {
	metrics.MetricsProvider
	// contains filtered or unexported fields
}

QueueInformer ties an informer to a queue in order to process events from the informer the informer watches objects of interest and adds objects to the queue for processing the syncHandler is called for all objects on the queue

func NewQueue

func NewQueue(ctx context.Context, options ...Option) (*QueueInformer, error)

func NewQueueInformer

func NewQueueInformer(ctx context.Context, options ...Option) (*QueueInformer, error)

NewQueueInformer returns a new QueueInformer configured with options.

func (*QueueInformer) Enqueue

func (q *QueueInformer) Enqueue(event kubestate.ResourceEvent)

Enqueue adds a key to the queue. If obj is a key already it gets added directly. Otherwise, the key is extracted via keyFunc.

func (*QueueInformer) Sync

Sync invokes all registered sync handlers in the QueueInformer's chain

type ResourceQueueSet

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

ResourceQueueSet is a set of workqueues that is assumed to be keyed by namespace

func NewEmptyResourceQueueSet

func NewEmptyResourceQueueSet() *ResourceQueueSet

NewEmptyResourceQueueSet returns a new queue set with an empty but initialized queue map

func NewResourceQueueSet

func NewResourceQueueSet(queueSet map[string]workqueue.RateLimitingInterface) *ResourceQueueSet

NewResourceQueueSet returns a new queue set with the given queue map

func (*ResourceQueueSet) Requeue

func (r *ResourceQueueSet) Requeue(namespace, name string) error

Requeue requeues the resource in the set with the given name and namespace

func (*ResourceQueueSet) RequeueAfter

func (r *ResourceQueueSet) RequeueAfter(namespace, name string, duration time.Duration) error

TODO: this may not actually be required if the requeue is done on the namespace rather than the installplan RequeueAfter requeues the resource in the set with the given name and namespace (just like Requeue), but only does so after duration has passed

func (*ResourceQueueSet) RequeueByKey

func (r *ResourceQueueSet) RequeueByKey(key string) error

RequeueByKey adds the given key to the resource queue that should contain it

func (*ResourceQueueSet) RequeueEvent

func (r *ResourceQueueSet) RequeueEvent(namespace string, resourceEvent kubestate.ResourceEvent) error

func (*ResourceQueueSet) Set

Set sets the queue at the given key

Jump to

Keyboard shortcuts

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