storage

package
v0.0.0-...-7c64bbc Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBackendName = "_"

Variables

View Source
var Root string

Functions

func Initialize

func Initialize(cfg Config, logger zerolog.Logger) error

func InsertBackend

func InsertBackend(d db.Handler, name string, driver Driver, params map[string]string) error

func ListBackends

func ListBackends() map[string]Backend

func Migrate

func Migrate(name string, dryRun bool) error

Types

type Backend

type Backend interface {
	Name() string
	OpenRead(name string, start, length int) (io.ReadCloser, error)
	Delete(name string) error
	DeleteAll(names []string) []error
	Copy(ctx context.Context, src Backend, srcName, destName string) error
}

func GetBackendByMountPoint

func GetBackendByMountPoint(id uuid.UUID) (Backend, error)

func GetBackendByName

func GetBackendByName(name string) (Backend, error)

type Config

type Config struct {
	Root   string                 `koanf:"root"`
	Temp   string                 `koanf:"temp"`
	Mounts map[string]MountConfig `koanf:"mounts"`
}

type Driver

type Driver struct {
	Name        string
	Description string
	Params      []string
	Create      func(name string, params map[string]string) (Backend, error)
}

func FindDriver

func FindDriver(driverName string) (Driver, error)

func ListDrivers

func ListDrivers() []Driver

type LocalBackend

type LocalBackend interface {
	Backend
	Write(name string, contents io.Reader) (WrittenFile, error)
	Path(name string) string
}

func DefaultBackend

func DefaultBackend() LocalBackend

type MountConfig

type MountConfig struct {
	MountPoints []string       `koanf:"mount_points"`
	Driver      string         `koanf:"driver"`
	Params      map[string]any `koanf:"params"`
}

type WrittenFile

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

func (WrittenFile) Delete

func (w WrittenFile) Delete() error

func (WrittenFile) OpenRead

func (w WrittenFile) OpenRead() (io.ReadSeekCloser, error)

func (WrittenFile) SHA256Sum

func (w WrittenFile) SHA256Sum() string

func (WrittenFile) Size

func (w WrittenFile) Size() int64

Jump to

Keyboard shortcuts

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