v0.0.0-...-7055397 Latest Latest

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

Go to latest
Published: Jan 23, 2024 License: Apache-2.0 Imports: 21 Imported by: 257



Package controller contains interfaces, structs, and functions that can be used to create shared controllers for managing clients, caches, and handlers for multiple types aka GroupVersionKinds.



This section is empty.


View Source
var (
	ErrIgnore = errors.New("ignore handler error")


This section is empty.


type Controller

type Controller interface {
	Enqueue(namespace, name string)
	EnqueueAfter(namespace, name string, delay time.Duration)
	EnqueueKey(key string)
	Informer() cache.SharedIndexInformer
	Start(ctx context.Context, workers int) error

func New

func New(name string, informer cache.SharedIndexInformer, startCache func(context.Context) error, handler Handler, opts *Options) Controller

type Handler

type Handler interface {
	OnChange(key string, obj runtime.Object) error

type HandlerFunc

type HandlerFunc func(key string, obj runtime.Object) error

func (HandlerFunc) OnChange

func (h HandlerFunc) OnChange(key string, obj runtime.Object) error

type HandlerTransaction

type HandlerTransaction struct {
	// contains filtered or unexported fields

func NewHandlerTransaction

func NewHandlerTransaction(ctx context.Context) *HandlerTransaction

func (*HandlerTransaction) Commit

func (h *HandlerTransaction) Commit()

func (*HandlerTransaction) Rollback

func (h *HandlerTransaction) Rollback()

type Options

type Options struct {
	RateLimiter            workqueue.RateLimiter
	SyncOnlyChangedObjects bool

type ResourceVersionGetter

type ResourceVersionGetter interface {
	GetResourceVersion() string

type SharedController

type SharedController interface {

	RegisterHandler(ctx context.Context, name string, handler SharedControllerHandler)
	Client() *client.Client

func NewSharedControllerWithAgent

func NewSharedControllerWithAgent(userAgent string, controller SharedController) SharedController

type SharedControllerFactory

type SharedControllerFactory interface {
	ForObject(obj runtime.Object) (SharedController, error)
	ForKind(gvk schema.GroupVersionKind) (SharedController, error)
	ForResource(gvr schema.GroupVersionResource, namespaced bool) SharedController
	ForResourceKind(gvr schema.GroupVersionResource, kind string, namespaced bool) SharedController
	SharedCacheFactory() cache.SharedCacheFactory
	Start(ctx context.Context, workers int) error

func NewSharedControllerFactoryFromConfig

func NewSharedControllerFactoryFromConfig(config *rest.Config, scheme *runtime.Scheme) (SharedControllerFactory, error)

func NewSharedControllerFactoryFromConfigWithOptions

func NewSharedControllerFactoryFromConfigWithOptions(config *rest.Config, scheme *runtime.Scheme, opts *SharedControllerFactoryOptions) (SharedControllerFactory, error)

NewSharedControllerFactoryFromConfigWithOptions accepts options for configuring a new SharedControllerFactory and its cache.

func NewSharedControllerFactoryWithAgent

func NewSharedControllerFactoryWithAgent(userAgent string, clientFactory SharedControllerFactory) SharedControllerFactory

NewSharedControllerFactoryWithAgent returns a controller factory that is equivalent to the passed controller factory with the addition that it will wrap the returned controllers from ForKind, ForResource, and ForResourceKind with the sharedController struct using the passed user agent.

type SharedControllerFactoryOptions

type SharedControllerFactoryOptions struct {
	CacheOptions *cache.SharedCacheFactoryOptions

	DefaultRateLimiter workqueue.RateLimiter
	DefaultWorkers     int

	KindRateLimiter map[schema.GroupVersionKind]workqueue.RateLimiter
	KindWorkers     map[schema.GroupVersionKind]int

	// SyncOnlyChangedObjects causes the handle function to only proceed if the object was actually updated.
	// This is intended to be used by applications with many objects and/or controllers types that have
	// alternative means of rerunning when necessary. When the informer's resync their cache the update
	// function is run. If this setting is enabled, when the update handler is triggered the overhead is
	// reduced but has the tradeoff of not rerunning handlers. Handlers that rely on external objects or
	// services, or experience a bug might need to rerun despite the respective object not changing. If this
	// is enabled, it is the responsibility of the app to ensure logic is retried when needed. The result is
	// that running the handler func on resync will mostly only serve the purpose of catching missed cache
	// events.
	SyncOnlyChangedObjects bool

type SharedControllerHandler

type SharedControllerHandler interface {
	OnChange(key string, obj runtime.Object) (runtime.Object, error)

type SharedControllerHandlerFunc

type SharedControllerHandlerFunc func(key string, obj runtime.Object) (runtime.Object, error)

func (SharedControllerHandlerFunc) OnChange

type SharedHandler

type SharedHandler struct {
	// contains filtered or unexported fields

func (*SharedHandler) OnChange

func (h *SharedHandler) OnChange(key string, obj runtime.Object) error

func (*SharedHandler) Register

func (h *SharedHandler) Register(ctx context.Context, name string, handler SharedControllerHandler)

Jump to

Keyboard shortcuts

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