watcher

package
v0.113.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Source  EventSource
	Watcher Watcher
}

type EventSource

type EventSource int
const (
	EventSourceConfigMap EventSource = iota
	EventSourcePrometheusCR
)

func (EventSource) String

func (e EventSource) String() string

type PrometheusCRWatcher

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

func NewPrometheusCRWatcher

func NewPrometheusCRWatcher(ctx context.Context, logger logr.Logger, cfg allocatorconfig.Config) (*PrometheusCRWatcher, error)

func (*PrometheusCRWatcher) Close

func (w *PrometheusCRWatcher) Close() error

func (*PrometheusCRWatcher) LoadConfig

func (w *PrometheusCRWatcher) LoadConfig(ctx context.Context) (*promconfig.Config, error)

func (*PrometheusCRWatcher) WaitForNamedCacheSync added in v0.113.0

func (w *PrometheusCRWatcher) WaitForNamedCacheSync(controllerName string, inf cache.InformerSynced) bool

WaitForNamedCacheSync adds a timeout to the informer's wait for the cache to be ready. If the PrometheusCRWatcher is unable to load an informer within 15 seconds, the method is cancelled and returns false. A successful informer load will return true. This method also will be cancelled if the target allocator's stopChannel is called before it returns.

This method is inspired by the upstream prometheus-operator implementation, with a shorter timeout and support for the PrometheusCRWatcher's stopChannel. https://github.com/prometheus-operator/prometheus-operator/blob/293c16c854ce69d1da9fdc8f0705de2d67bfdbfa/pkg/operator/operator.go#L433

func (*PrometheusCRWatcher) Watch

func (w *PrometheusCRWatcher) Watch(upstreamEvents chan Event, upstreamErrors chan error) error

Watch wrapped informers and wait for an initial sync.

type Watcher

type Watcher interface {
	// Watch watcher and supply channels which will receive change events
	Watch(upstreamEvents chan Event, upstreamErrors chan error) error
	LoadConfig(ctx context.Context) (*promconfig.Config, error)
	Close() error
}

Jump to

Keyboard shortcuts

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