storage

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CacheableStorageOptions = map[string]StorageCreator{
	"file":     NewFileStorage,
	"bigcache": NewBigCacheStorage,
	"gcs":      NewGCSStorage,
}

CacheableStorageOptions is a map of available storage options specified at the server.options.cache config path

View Source
var StorageOptions = map[string]StorageCreator{
	"file":      NewFileStorage,
	"bigcache":  NewBigCacheStorage,
	"cacheable": NewCacheableStorageWithConf,
	"gcs":       NewGCSStorage,
}

StorageOptions is a map of available storage options specified at the server.storage config path

Functions

func ValidatePath

func ValidatePath(path string) error

Types

type BigCacheStorage

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

func (*BigCacheStorage) Delete

func (f *BigCacheStorage) Delete(ctx context.Context, logicalPath string) error

func (*BigCacheStorage) Get

func (f *BigCacheStorage) Get(ctx context.Context, logicalPath string) (*StorageEntry, error)

func (*BigCacheStorage) List

func (f *BigCacheStorage) List(ctx context.Context, prefix string) ([]string, error)

func (*BigCacheStorage) Put

type CacheableStorage

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

CacheableStorage is a wrapper storage used for providing a write-through cache. This allows any storage type to be used on top, however, in-memory storage types are recommended to reduce latency. Size and implementation details of the cache layer will be up to the consumer.

func (*CacheableStorage) Delete

func (c *CacheableStorage) Delete(ctx context.Context, logicalPath string) error

func (*CacheableStorage) Get

func (c *CacheableStorage) Get(ctx context.Context, logicalPath string) (*StorageEntry, error)

func (*CacheableStorage) List

func (c *CacheableStorage) List(ctx context.Context, prefix string) ([]string, error)

func (*CacheableStorage) Put

type FileStorage

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

func (*FileStorage) Delete

func (f *FileStorage) Delete(ctx context.Context, logicalPath string) error

func (*FileStorage) Get

func (f *FileStorage) Get(ctx context.Context, logicalPath string) (*StorageEntry, error)

func (*FileStorage) List

func (f *FileStorage) List(ctx context.Context, prefix string) ([]string, error)

func (*FileStorage) Put

func (f *FileStorage) Put(ctx context.Context, e StorageEntry) error

type GCSStorage added in v0.0.22

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

func (*GCSStorage) Delete added in v0.0.22

func (s *GCSStorage) Delete(ctx context.Context, logicalPath string) error

func (*GCSStorage) Get added in v0.0.22

func (s *GCSStorage) Get(ctx context.Context, logicalPath string) (*StorageEntry, error)

func (*GCSStorage) List added in v0.0.22

func (s *GCSStorage) List(ctx context.Context, prefix string) ([]string, error)

func (*GCSStorage) Put added in v0.0.22

func (s *GCSStorage) Put(ctx context.Context, e StorageEntry) (retErr error)

type InheritableStorage added in v0.0.21

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

func (*InheritableStorage) Delete added in v0.0.21

func (s *InheritableStorage) Delete(ctx context.Context, logicalPath string) error

func (*InheritableStorage) Get added in v0.0.21

func (s *InheritableStorage) Get(ctx context.Context, logicalPath string) (*StorageEntry, error)

func (*InheritableStorage) List added in v0.0.21

func (s *InheritableStorage) List(ctx context.Context, prefix string) ([]string, error)

func (*InheritableStorage) Put added in v0.0.21

type NotFoundError

type NotFoundError struct {
	Key string
}

func (*NotFoundError) Error

func (nf *NotFoundError) Error() string

type Storage

type Storage interface {
	// Get retrieves the entry by key from the underlying storage
	Get(ctx context.Context, key string) (*StorageEntry, error)
	// Put adds the entry to the underlying storage
	Put(ctx context.Context, e StorageEntry) error
	// Delete removes the entry by key from the underlying storage
	Delete(ctx context.Context, key string) error
	// List returns a slice of paths at the specified prefix
	List(ctx context.Context, prefix string) ([]string, error)
}

func NewBigCacheStorage

func NewBigCacheStorage(config map[string]string) (Storage, error)

func NewCacheableStorage

func NewCacheableStorage(cache Storage, source Storage) (Storage, error)

NewCacheableStorage returns a write-through cacheable storage.

func NewCacheableStorageWithConf

func NewCacheableStorageWithConf(conf map[string]string) (Storage, error)

func NewFileStorage

func NewFileStorage(conf map[string]string) (Storage, error)

func NewGCSStorage added in v0.0.22

func NewGCSStorage(conf map[string]string) (Storage, error)

func NewInheritableStorage added in v0.0.21

func NewInheritableStorage(source Storage) (Storage, error)

NewInheritableStorage returns a InheritableStorage with the source Storage

type StorageCreator

type StorageCreator func(conf map[string]string) (Storage, error)

StorageCreator is a factory function to be used for all storage types

type StorageEntry

type StorageEntry struct {
	Key   string
	Value []byte
}

Jump to

Keyboard shortcuts

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