storage

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

DefaultStorage is the default storage implementation

Functions

func KeyForKind

func KeyForKind(kind meta.Kind) string

func KeyForUID

func KeyForUID(kind meta.Kind, uid meta.UID) string

Types

type Cache

type Cache interface {
	Storage
	// Flush is used to write the state of the entire cache to storage
	// Warning: this is a very expensive operation
	Flush() error
}

Cache is an intermediate caching layer, which conforms to Storage Typically you back the cache with an actual storage

func NewCache

func NewCache(backingStorage Storage) Cache

type DefaultRawStorage

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

func (*DefaultRawStorage) Delete

func (r *DefaultRawStorage) Delete(key string) error

func (*DefaultRawStorage) Exists

func (r *DefaultRawStorage) Exists(key string) bool

func (*DefaultRawStorage) List

func (r *DefaultRawStorage) List(parentKey string) ([]string, error)

func (*DefaultRawStorage) Read

func (r *DefaultRawStorage) Read(key string) ([]byte, error)

func (*DefaultRawStorage) Write

func (r *DefaultRawStorage) Write(key string, content []byte) error

type GenericStorage

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

GenericStorage implements the Storage interface

func (*GenericStorage) Count

func (s *GenericStorage) Count(kind meta.Kind) (uint64, error)

Count counts the objects for the specific kind

func (*GenericStorage) Delete

func (s *GenericStorage) Delete(kind meta.Kind, uid meta.UID) error

Delete removes an object from the storage

func (*GenericStorage) Get

func (s *GenericStorage) Get(obj meta.Object) error

Get populates the pointer to the Object given, based on the file content

func (*GenericStorage) GetByID

func (s *GenericStorage) GetByID(kind meta.Kind, uid meta.UID) (meta.Object, error)

GetByID returns a new Object for the resource at the specified kind/uid path, based on the file content

func (*GenericStorage) List

func (s *GenericStorage) List(kind meta.Kind) ([]meta.Object, error)

List lists objects for the specific kind

func (*GenericStorage) ListMeta

func (s *GenericStorage) ListMeta(kind meta.Kind) ([]meta.Object, error)

ListMeta lists all objects' APIType representation. In other words, only metadata about each object is unmarshalled (uid/name/kind/apiVersion). This allows for faster runs (no need to unmarshal "the world"), and less resource usage, when only metadata is unmarshalled into memory

func (*GenericStorage) Set

func (s *GenericStorage) Set(obj meta.Object) error

Set saves the Object to disk. If the object does not exist, the ObjectMeta.Created field is set automatically

type RawStorage

type RawStorage interface {
	Read(key string) ([]byte, error)
	Exists(key string) bool
	Write(key string, content []byte) error
	Delete(key string) error
	List(directory string) ([]string, error)
}

func NewDefaultRawStorage

func NewDefaultRawStorage(dir string) RawStorage

type Storage

type Storage interface {
	// Get populates the Object using the given pointer, based on the file content
	Get(obj meta.Object) error
	// Set saves the Object to disk. If the object does not exist, the
	// ObjectMeta.Created field is set automatically
	Set(obj meta.Object) error
	// GetByID returns a new Object for the resource at the specified kind/uid path, based on the file content
	GetByID(kind meta.Kind, uid meta.UID) (meta.Object, error)
	// Delete removes an object from the storage
	Delete(kind meta.Kind, uid meta.UID) error
	// List lists objects for the specific kind
	List(kind meta.Kind) ([]meta.Object, error)
	// ListMeta lists all objects' APIType representation. In other words,
	// only metadata about each object is unmarshalled (uid/name/kind/apiVersion).
	// This allows for faster runs (no need to unmarshal "the world"), and less
	// resource usage, when only metadata is unmarshalled into memory
	ListMeta(kind meta.Kind) ([]meta.Object, error)
	// Count returns the amount of available Objects of a specific kind
	// This is used by Caches to check if all objects are cached to perform a List
	Count(kind meta.Kind) (uint64, error)
}

Storage is an interface for persisting and retrieving API objects to/from a backend One Storage instance handles all different Kinds of Objects

func NewGenericStorage

func NewGenericStorage(rawStorage RawStorage, serializer serializer.Serializer) Storage

NewGenericStorage constructs a new Storage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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