framework

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventName

type EventName string
const (
	PodEventName EventName = "PodsSync"

	NodeResourcesEventName EventName = "NodeResourcesSync"

	NodeMonitorEventName EventName = "NodeUtilizationSync"
)

type EventQueue

type EventQueue struct {
	// Name is the name of event.
	Name string
	// Workers is the number of handle workers that are allowed to sync concurrently.
	Workers int
	// Queue for caching events
	Queue workqueue.RateLimitingInterface
	// List of handlers that need to handle this event.
	Handlers []Handle
	// List of event detectors.
	// Generate an event and put the event in the queue
	Probes []Probe
}

func NewEventQueue

func NewEventQueue(name string) *EventQueue

func (*EventQueue) AddHandler

func (eq *EventQueue) AddHandler(handle ...Handle)

func (*EventQueue) AddProbe

func (eq *EventQueue) AddProbe(p ...Probe)

func (*EventQueue) GetQueue

func (*EventQueue) ProcessEvent

func (eq *EventQueue) ProcessEvent(ctx context.Context)

func (*EventQueue) SetWorkers

func (eq *EventQueue) SetWorkers(workers int)

type EventQueueFactory

type EventQueueFactory struct {
	Mutex  sync.RWMutex
	Queues map[string]*EventQueue
}

func (*EventQueueFactory) EventQueue

func (f *EventQueueFactory) EventQueue(name string) *EventQueue

func (*EventQueueFactory) RegistryEventHandler

func (f *EventQueueFactory) RegistryEventHandler(name string, handle Handle) Handle

func (*EventQueueFactory) RegistryEventProbe

func (f *EventQueueFactory) RegistryEventProbe(name string, probe Probe) Probe

func (*EventQueueFactory) Start

func (f *EventQueueFactory) Start(ctx context.Context) error

func (*EventQueueFactory) SyncConfig

func (f *EventQueueFactory) SyncConfig(cfg *api.ColocationConfig) error

type Handle

type Handle interface {
	// HandleName returns name of the handler
	HandleName() string
	// Handle handles the given event
	// Return an error only if the event needs to be re-enqueued to be processed
	// Need to avoid returning errors that cannot be resolved by retrying
	Handle(event interface{}) error
	// IsActive returns true if the handler is enabled
	IsActive() bool
	// RefreshCfg hot update handler's cfg.
	RefreshCfg(cfg *api.ColocationConfig) error
}

type NodeMonitorEvent

type NodeMonitorEvent struct {
	// TimeStamp is the time when event occur.
	TimeStamp time.Time
	// Resource represents which resource is under pressure.
	Resource corev1.ResourceName
}

NodeMonitorEvent defines node pressure event.

type NodeResourceEvent

type NodeResourceEvent struct {
	MillCPU     int64
	MemoryBytes int64
}

NodeResourceEvent defines node resource event, overSubscription resource recently.

type PodEvent

type PodEvent struct {
	UID      types.UID
	QoSLevel int64
	QoSClass corev1.PodQOSClass
	Pod      *corev1.Pod
}

type Probe

type Probe interface {
	// ProbeName returns name of the probe
	ProbeName() string
	// Run runs the probe
	Run(stop <-chan struct{})
	// RefreshCfg hot update probe's cfg.
	RefreshCfg(cfg *api.ColocationConfig) error
}

Jump to

Keyboard shortcuts

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