file

package
v0.0.0-...-8e96821 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UpdateChannelSize         = 25
	InitialWatchNodesSize     = 20
	InitialBufferedEventsSize = 25
)
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 {
	// contains filtered or unexported fields
}

func NewRESTOptionsGetter

func NewRESTOptionsGetter(path string,
	originalStorageConfig storagebackend.Config,
	createResourceDirs ...string) (*RESTOptionsGetter, error)

Optionally, this constructor allows specifying directories for resources that are required to be read/watched on startup and there won't be any write operations that initially bootstrap their directories

func (*RESTOptionsGetter) GetRESTOptions

func (r *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) RequestWatchProgress

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

RequestWatchProgress requests the a watch stream progress status be sent in the watch response stream as soon as possible. Used for monitor watch progress even if watching resources with no changes.

If watch is lagging, progress status might: * be pointing to stale resource version. Use etcd KV request to get linearizable resource version. * not be delivered at all. It's recommended to poll request progress periodically.

Note: Only watches with matching context grpc metadata will be notified. https://github.com/kubernetes/kubernetes/blob/9325a57125e8502941d1b0c7379c4bb80a678d5c/vendor/go.etcd.io/etcd/client/v3/watch.go#L1037-L1042

TODO: Remove when storage.Interface will be separate from etc3.store. Deprecated: Added temporarily to simplify exposing RequestProgress for watch cache.

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 the predicate 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