watcher

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEventBufferCap = 128
	// DefaultMaxEventAge is the default maximum age of an event to be considered
	// for writing to the buffer. This applies only during the initial cache sync.
	DefaultMaxEventAge = 1 * time.Minute
)

Variables

View Source
var CreateKubeClient = func(config *rest.Config) kubernetes.Interface {
	return kubernetes.NewForConfigOrDie(config)
}

Functions

This section is empty.

Types

type EventBuffer

type EventBuffer = circular.RingBuffer[*kube.EnhancedEvent]

func NewEventBuffer

func NewEventBuffer(capacity int) *EventBuffer

type EventHandler

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

func (*EventHandler) OnAdd

func (eh *EventHandler) OnAdd(obj interface{}, isInInitialList bool)

func (*EventHandler) OnDelete

func (eh *EventHandler) OnDelete(_ interface{})

func (*EventHandler) OnUpdate

func (eh *EventHandler) OnUpdate(oldObj, newObj interface{})

func (*EventHandler) WriteToBuffer

func (eh *EventHandler) WriteToBuffer(event *corev1.Event)

type Option

type Option func(*Watcher)

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger sets the logger for the watcher.

func WithMaxEventAge

func WithMaxEventAge(age time.Duration) Option

WithMaxEventAge sets the maximum age of an event to be considered for writing to the buffer. This applies only during the initial cache sync.

func WriteTo

func WriteTo(output *EventBuffer) Option

WriteTo sets the buffer where the watcher writes the observed events.

type Watcher

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

func New

func New(config *rest.Config, cluster kube.Cluster, opts ...Option) *Watcher

func (*Watcher) GetBuffer

func (w *Watcher) GetBuffer() *EventBuffer

GetBuffer returns the buffer where the watcher writes the observed events.

func (*Watcher) Watch

func (w *Watcher) Watch(ctx context.Context) error

Watch starts the watcher, which writes observed events to the buffer until the context is canceled. It returns an error if the initial cache sync fails.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳