Documentation
¶
Index ¶
- Variables
- type StorageBackend
- type StorageConfig
- type StorageManager
- func (sm *StorageManager) Close() error
- func (sm *StorageManager) Delete(ctx context.Context, key string) error
- func (sm *StorageManager) Exists(ctx context.Context, key string) (bool, error)
- func (sm *StorageManager) GetBackend(name string) (StorageBackend, error)
- func (sm *StorageManager) GetDefault() (StorageBackend, error)
- func (sm *StorageManager) List(ctx context.Context, prefix string) ([]string, error)
- func (sm *StorageManager) Load(ctx context.Context, key string) (io.ReadCloser, error)
- func (sm *StorageManager) Register(name string, backend StorageBackend) error
- func (sm *StorageManager) Save(ctx context.Context, key string, data io.Reader) error
- func (sm *StorageManager) SetDefault(name string) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrBackendNotFound = errors.New("storage backend not found") ErrNoDefaultBackend = errors.New("no default storage backend configured") ErrKeyNotFound = errors.New("key not found in storage") ErrInvalidConfig = errors.New("invalid storage configuration") ErrBackendNotReady = errors.New("storage backend not ready") ErrUnsupportedOp = errors.New("operation not supported by this backend") )
Common storage errors
Functions ¶
This section is empty.
Types ¶
type StorageBackend ¶
type StorageBackend interface {
// Init initializes the storage backend with configuration
Init(config map[string]interface{}) error
// Save stores data to the storage backend at the specified key/path
Save(ctx context.Context, key string, data io.Reader) error
// Load retrieves data from the storage backend for the given key/path
Load(ctx context.Context, key string) (io.ReadCloser, error)
// Delete removes data from the storage backend for the given key/path
Delete(ctx context.Context, key string) error
// Exists checks if data exists at the given key/path in the storage backend
Exists(ctx context.Context, key string) (bool, error)
// List returns a list of keys with the given prefix
List(ctx context.Context, prefix string) ([]string, error)
// Close cleans up any resources used by the storage backend
Close() error
}
StorageBackend defines the interface for different storage backends This allows for flexible storage options like local filesystem, cloud storage, etc.
type StorageConfig ¶
type StorageConfig struct {
// Type specifies the storage backend type (filesystem, s3, redis, memory)
Type string `json:"type" yaml:"type"`
// Config holds backend-specific configuration
Config map[string]interface{} `json:"config" yaml:"config"`
}
StorageConfig holds common configuration options for storage backends
type StorageManager ¶
type StorageManager struct {
// contains filtered or unexported fields
}
StorageManager manages multiple storage backends
func NewStorageManager ¶
func NewStorageManager() *StorageManager
NewStorageManager creates a new storage manager
func (*StorageManager) Close ¶
func (sm *StorageManager) Close() error
Close closes all registered backends
func (*StorageManager) Delete ¶
func (sm *StorageManager) Delete(ctx context.Context, key string) error
Delete deletes data using the default backend
func (*StorageManager) GetBackend ¶
func (sm *StorageManager) GetBackend(name string) (StorageBackend, error)
GetBackend returns a storage backend by name
func (*StorageManager) GetDefault ¶
func (sm *StorageManager) GetDefault() (StorageBackend, error)
GetDefault returns the default storage backend
func (*StorageManager) Load ¶
func (sm *StorageManager) Load(ctx context.Context, key string) (io.ReadCloser, error)
Load loads data using the default backend
func (*StorageManager) Register ¶
func (sm *StorageManager) Register(name string, backend StorageBackend) error
Register registers a storage backend with a given name
func (*StorageManager) SetDefault ¶
func (sm *StorageManager) SetDefault(name string) error
SetDefault sets the default storage backend