storage

package
v0.48.3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStorageNameEmpty = errors.New("storage name is empty")
)
View Source
var Storages = make(map[string]Storage)
View Source
var UserStorages = make(map[int64][]Storage)

Functions

func LoadStorages added in v0.11.0

func LoadStorages(ctx context.Context)

func WithContext added in v0.23.0

func WithContext(ctx context.Context, storage Storage) context.Context

Types

type Storage

type Storage interface {
	// Init 只应该在创建存储时调用一次
	Init(ctx context.Context, cfg storcfg.StorageConfig) error
	Type() storenum.StorageType
	Name() string
	JoinStoragePath(p string) string
	Save(ctx context.Context, reader io.Reader, storagePath string) error
	Exists(ctx context.Context, storagePath string) bool
}

func FromContext added in v0.23.0

func FromContext(ctx context.Context) Storage

func GetStorageByName added in v0.11.0

func GetStorageByName(ctx context.Context, name string) (Storage, error)

GetStorageByName returns storage by name from cache or creates new one It should NOT be used to get storage for user, use GetStorageByUserIDAndName instead

func GetStorageByUserIDAndName added in v0.11.0

func GetStorageByUserIDAndName(ctx context.Context, chatID int64, name string) (Storage, error)

检查 user 是否可用指定的 storage, 若不可用则返回未找到错误

func GetUserStorages added in v0.11.0

func GetUserStorages(ctx context.Context, chatID int64) []Storage

func NewStorage added in v0.11.0

func NewStorage(ctx context.Context, cfg storcfg.StorageConfig) (Storage, error)

NewStorage creates a new storage instance based on the provided config and initializes it

type StorageCannotStream added in v0.23.0

type StorageCannotStream interface {
	Storage
	CannotStream() string
}

type StorageConstructor added in v0.11.0

type StorageConstructor func() Storage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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