storage

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Overview

Package storage contains storage interfaces and implementations for the apiserver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GenEventFunc

type GenEventFunc func(key string, prevObj, obj interface{}, resourceVersion uint64) (InternalEvent, error)

GenEventFunc generates InternalEvent from the add/update/delete of an object. Only a single InternalEvent will be generated for each add/update/delete, and the InternalEvent itself should be immutable during its conversion to *watch.Event.

type Interface

type Interface interface {
	// Create adds a new object unless it already exists.
	Create(obj interface{}) error

	// Update updates an object unless it doesn't exist.
	Update(obj interface{}) error

	// Get gets an object that has the specified key.
	Get(key string) (interface{}, bool, error)

	// GetByIndex gets a list of objects that has the specified index.
	GetByIndex(indexName, indexKey string) ([]interface{}, error)

	// List gets a list of all objects.
	List() []interface{}

	// Delete removes an object that has specified key.
	Delete(key string) error

	// Watch starts watching with the specified key and selectors. Events will be sent to the returned watch.Interface.
	Watch(ctx context.Context, key string, labelSelector labels.Selector, fieldSelector fields.Selector) (watch.Interface, error)

	// GetWatchersNum gets the number of watchers for the store.
	GetWatchersNum() int

	Stop()
}

Interface offers a common storage interface for runtime.Object. It's provided for Network Policy controller to store the translated Network Policy resources, then Antrea apiserver can dispatch events to clients that watch them via the Watch function.

type InternalEvent

type InternalEvent interface {
	// ToWatchEvent converts the InternalEvent to *watch.Event based on the provided Selectors.
	// It will be called once for all watchers that are interested in the event. Expensive computation that will repeat
	// for all watchers should be placed in GenEventFunc as pre-process. For example, the routine that groups a list of
	// pods by nodes is a potential candidate.
	ToWatchEvent(selectors *Selectors, isInitEvent bool) *watch.Event
	// GetResourceVersion returns the resourceVersion of this event.
	// The resourceVersion is used to filter out previously buffered events when watcher is started.
	GetResourceVersion() uint64
}

InternalEvent is an internal event that can be converted to *watch.Event based on watcher's Selectors. For example, an internal event may be converted to an ADDED event for one watcher, and to a MODIFIED event for another.

type SelectFunc

type SelectFunc func(selectors *Selectors, key string, obj interface{}) bool

SelectFunc checks whether an object match the provided selectors.

type Selectors

type Selectors struct {
	// Key is the identifier of the object the watcher monitors. It can be empty.
	Key string
	// Label filters objects based on LabelSelector.
	Label labels.Selector
	// Field filters objects based on the value of the resource fields.
	Field fields.Selector
}

Selectors represent a watcher's conditions to select objects.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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