entity

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const FolderAnnoKey = "grafana.app/folder"
View Source
const ListDeletedKey = "grafana.app/listDeleted"
View Source
const ListHistoryKey = "grafana.app/listHistory"
View Source
const SortByKey = "grafana.app/sortBy"

Variables

This section is empty.

Functions

func NewStorage

func NewStorage(
	config *storagebackend.ConfigForResource,
	gr schema.GroupResource,
	store entityStore.EntityStoreClient,
	codec runtime.Codec,
	keyFunc func(obj runtime.Object) (string, error),
	newFunc func() runtime.Object,
	newListFunc func() runtime.Object,
	getAttrsFunc storage.AttrFunc,
) (storage.Interface, factory.DestroyFunc, error)

Types

type Decoder

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

func (*Decoder) Close

func (d *Decoder) Close()

func (*Decoder) Decode

func (d *Decoder) Decode() (action watch.EventType, object runtime.Object, err error)

type RESTOptionsGetter

type RESTOptionsGetter struct {
	Codec runtime.Codec
	// contains filtered or unexported fields
}

func NewRESTOptionsGetter

func NewRESTOptionsGetter(cfg *setting.Cfg, store entityStore.EntityStoreClient, codec runtime.Codec) *RESTOptionsGetter

func (*RESTOptionsGetter) GetRESTOptions

func (f *RESTOptionsGetter) GetRESTOptions(resource schema.GroupResource) (generic.RESTOptions, error)

type Requirements

type Requirements struct {
	// Equals folder
	Folder *string
	// SortBy is a list of fields to sort by
	SortBy []string
	// ListDeleted is a flag to list deleted entities
	ListDeleted bool
	// ListHistory is a resource name to list the history of
	ListHistory string
	// ListOriginKeys needs to include the origin key of a given entity in order for it to be selected.
	ListOriginKeys []string
}

func ReadLabelSelectors

func ReadLabelSelectors(selector labels.Selector) (Requirements, labels.Selector, error)

type Storage

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

Storage implements storage.Interface and stores resources in unified storage

func (*Storage) Count

func (s *Storage) Count(key string) (int64, error)

Count returns number of different entries under the key (generally being path prefix).

func (*Storage) Create

func (s *Storage) Create(ctx context.Context, key string, obj runtime.Object, out runtime.Object, ttl uint64) error

Create adds a new object at a key unless it already exists. 'ttl' is time-to-live in seconds (0 means forever). If no error is returned and out is not nil, out will be set to the read value from database.

func (*Storage) Delete

func (s *Storage) Delete(ctx context.Context, key string, out runtime.Object, preconditions *storage.Preconditions, validateDeletion storage.ValidateObjectFunc, cachedExistingObject runtime.Object) error

Delete removes the specified key and returns the value that existed at that spot. If key didn't exist, it will return NotFound storage error. If 'cachedExistingObject' is non-nil, it can be used as a suggestion about the current version of the object to avoid read operation from storage to get it. However, the implementations have to retry in case suggestion is stale.

func (*Storage) Get

func (s *Storage) Get(ctx context.Context, key string, opts storage.GetOptions, objPtr runtime.Object) error

Get unmarshals object found at key into objPtr. On a not found error, will either return a zero object of the requested type, or an error, depending on 'opts.ignoreNotFound'. Treats empty responses and nil response nodes exactly like a not found error. The returned contents may be delayed, but it is guaranteed that they will match 'opts.ResourceVersion' according 'opts.ResourceVersionMatch'.

func (*Storage) GetList

func (s *Storage) GetList(ctx context.Context, key string, opts storage.ListOptions, listObj runtime.Object) error

GetList unmarshalls objects found at key into a *List api object (an object that satisfies runtime.IsList definition). If 'opts.Recursive' is false, 'key' is used as an exact match. If `opts.Recursive' is true, 'key' is used as a prefix. The returned contents may be delayed, but it is guaranteed that they will match 'opts.ResourceVersion' according 'opts.ResourceVersionMatch'.

func (*Storage) GuaranteedUpdate

func (s *Storage) GuaranteedUpdate(
	ctx context.Context,
	key string,
	destination runtime.Object,
	ignoreNotFound bool,
	preconditions *storage.Preconditions,
	tryUpdate storage.UpdateFunc,
	cachedExistingObject runtime.Object,
) error

GuaranteedUpdate keeps calling 'tryUpdate()' to update key 'key' (of type 'destination') retrying the update until success if there is index conflict. Note that object passed to tryUpdate may change across invocations of tryUpdate() if other writers are simultaneously updating it, so tryUpdate() needs to take into account the current contents of the object when deciding how the update object should look. If the key doesn't exist, it will return NotFound storage error if ignoreNotFound=false else `destination` will be set to the zero value of it's type. If the eventual successful invocation of `tryUpdate` returns an output with the same serialized contents as the input, it won't perform any update, but instead set `destination` to an object with those contents. If 'cachedExistingObject' is non-nil, it can be used as a suggestion about the current version of the object to avoid read operation from storage to get it. However, the implementations have to retry in case suggestion is stale.

func (*Storage) RequestWatchProgress

func (s *Storage) RequestWatchProgress(ctx context.Context) error

func (*Storage) Versioner

func (s *Storage) Versioner() storage.Versioner

func (*Storage) Watch

func (s *Storage) Watch(ctx context.Context, key string, opts storage.ListOptions) (watch.Interface, error)

Watch begins watching the specified key. Events are decoded into API objects, and any items selected by 'p' are sent down to returned watch.Interface. resourceVersion may be used to specify what version to begin watching, which should be the current resourceVersion, and no longer rv+1 (e.g. reconnecting without missing any updates). If resource version is "0", this interface will get current object at given key and send it in an "ADDED" event, before watch starts.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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