Documentation
¶
Index ¶
- Variables
- func KeyForKind(kind meta.Kind) string
- func KeyForUID(kind meta.Kind, uid meta.UID) string
- type Cache
- type DefaultRawStorage
- func (r *DefaultRawStorage) Delete(key string) error
- func (r *DefaultRawStorage) Exists(key string) bool
- func (r *DefaultRawStorage) List(parentKey string) ([]string, error)
- func (r *DefaultRawStorage) Read(key string) ([]byte, error)
- func (r *DefaultRawStorage) Write(key string, content []byte) error
- type GenericStorage
- func (s *GenericStorage) Count(kind meta.Kind) (uint64, error)
- func (s *GenericStorage) Delete(kind meta.Kind, uid meta.UID) error
- func (s *GenericStorage) Get(obj meta.Object) error
- func (s *GenericStorage) GetByID(kind meta.Kind, uid meta.UID) (meta.Object, error)
- func (s *GenericStorage) List(kind meta.Kind) ([]meta.Object, error)
- func (s *GenericStorage) ListMeta(kind meta.Kind) ([]meta.Object, error)
- func (s *GenericStorage) Set(obj meta.Object) error
- type RawStorage
- type Storage
Constants ¶
This section is empty.
Variables ¶
var DefaultStorage = NewCache(NewGenericStorage(NewDefaultRawStorage(constants.DATA_DIR), scheme.Serializer))
DefaultStorage is the default storage implementation
Functions ¶
func KeyForKind ¶
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
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
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) 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 ¶
GetByID returns a new Object for the resource at the specified kind/uid path, based on the file content
func (*GenericStorage) ListMeta ¶
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
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