watcher

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package watcher notify the change of gpupod and gpunode to watchers from rest api in metricserver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChanType

type ChanType string
const (
	GpuNodeType ChanType = "GpuNode"
	GpuPodType  ChanType = "GpuPod"
)

type EventType

type EventType string
const (
	Deleted EventType = "DELETED"
	Synced  EventType = "SYNCED" //Added or Modified
)

type GpuNodeEvent

type GpuNodeEvent struct {
	GpuNode *gpunodev1.GpuNode
	Type    EventType
}

func NewGpuNodeEvent

func NewGpuNodeEvent(gpuNode *gpunodev1.GpuNode, etype EventType) *GpuNodeEvent

type GpuPodEvent

type GpuPodEvent struct {
	GpuPod *gpupodv1.GpuPod
	Type   EventType
}

func NewGpuPodEvent

func NewGpuPodEvent(gpuPod *gpupodv1.GpuPod, etype EventType) *GpuPodEvent

type WatchIndex

type WatchIndex struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

WatchIndex provide AddWatcher, DelWatcher, ListWatcher to notify the change of gpupod and gpunode.

func (*WatchIndex) AddWatcher

func (w *WatchIndex) AddWatcher(chprd chan interface{}) string

func (*WatchIndex) CleanWatcher

func (w *WatchIndex) CleanWatcher()

CleanWatcher close all watcher chan and empty chanWatchIndex, called when gpuserver exit.

func (*WatchIndex) DelWatcher

func (w *WatchIndex) DelWatcher(watchUuid string)

func (*WatchIndex) ListWatcher

func (w *WatchIndex) ListWatcher() []chan interface{}

type Watcher

type Watcher interface {
	AddWatcher(chResource chan interface{}) string
	DelWatcher(watchUuid string)
	ListWatcher() []chan interface{}
	CleanWatcher()
}
var (
	GpuPodWatcher  Watcher
	GpuNodeWatcher Watcher
)

func NewWatcher

func NewWatcher(chType ChanType) Watcher

Jump to

Keyboard shortcuts

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