filepath

package
v0.0.0-...-88a9ed4 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const MaxUpdateAttempts = 30

Variables

View Source
var ErrFileNotExists = fmt.Errorf("file doesn't exist")

ErrFileNotExists means the file doesn't actually exist.

View Source
var ErrNamespaceNotExists = errors.New("namespace does not exist")

ErrNamespaceNotExists means the directory for the namespace doesn't actually exist.

Functions

func NewStorage

func NewStorage(
	config *storagebackend.ConfigForResource,
	resourcePrefix string,
	keyFunc func(obj runtime.Object) (string, error),
	newFunc func() runtime.Object,
	newListFunc func() runtime.Object,
	getAttrsFunc storage.AttrFunc,
	trigger storage.IndexerFuncs,
	indexers *cache.Indexers,
) (storage.Interface, factory.DestroyFunc, error)

NewStorage instantiates a new Storage.

Types

type RESTOptionsGetter

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

func NewRESTOptionsGetter

func NewRESTOptionsGetter(path string, codec runtime.Codec) *RESTOptionsGetter

func (*RESTOptionsGetter) GetRESTOptions

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

type Storage

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

Storage implements storage.Interface and storage resources as JSON files on disk.

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) Versioner

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

Returns Versioner associated with this storage.

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.

type WatchSet

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

Keeps track of which watches need to be notified

func NewWatchSet

func NewWatchSet() *WatchSet

Jump to

Keyboard shortcuts

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