watcher

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateWatchObject

type CreateWatchObject func(namespace string) (WatchObject, error)

CreateWatchObject - A function that creates a WatchObject to be watched (monitored)

type ObjectMonitor

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

ObjectMonitor - Watches a particular kubernetes object through k8s API

func NewObjectMonitor

func NewObjectMonitor(ctx context.Context, name string, namespace string, handler WatchEventHandler, create CreateWatchObject) (*ObjectMonitor, error)

NewObjectMonitor - param name: name of the k8s object to monitor param namespace: namespace of the object to monitor param create: func that creates the specific type of k8s object for monitoring purposes (e.g. v1.SecretInterface) param handler: handles watch events generated by the monitor

func (*ObjectMonitor) Start

func (om *ObjectMonitor) Start(ctx context.Context)

Start - Starts monitoring the object, and relays events to handler Note: blocks caller

func (*ObjectMonitor) Stop

func (om *ObjectMonitor) Stop(ctx context.Context)

Stop - Stops the object monitor, and signals event handler

type ObjectMonitorInterface

type ObjectMonitorInterface interface {
	Start(ctx context.Context)
	Stop(ctx context.Context)
}

type ObjectMonitorManager

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

ObjectMonitorManager - Allows watching multiple k8s objects of the same type in the same namespace through k8s API

func NewObjectMonitorManager

func NewObjectMonitorManager(ctx context.Context, namespace string, handler WatchEventHandler, create CreateWatchObject) *ObjectMonitorManager

func (*ObjectMonitorManager) Manage

func (omm *ObjectMonitorManager) Manage(ctx context.Context, names []string)

Manage - Manages watchers/monitors based on the input (stops old watchers not included in names)

type ObjectMonitorManagerInterface

type ObjectMonitorManagerInterface interface {
	Manage(ctx context.Context, names []string)
}

type WatchEventHandler

type WatchEventHandler interface {
	Handle(ctx context.Context, event *watch.Event)
	End(ctx context.Context, namespace, name string)
}

WatchEventHandler - Handles watch events relayed by Monitor TODO: check if End() could be changed to accept *watch.Event

type WatchObject

type WatchObject interface {
	Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
}

WatchObject - Is a wrapper around Watch (implemented by v1.SecretInterface, v1.PodInterface etc.)

Jump to

Keyboard shortcuts

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