storage

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserIDMustNotBeEmpty = errors.New("userID must not be empty")
	ErrUserIDMustBeEmpty    = errors.New("userID must be empty")
)

Functions

func DownloadFileFromStorage

func DownloadFileFromStorage(destination string, decompressFile bool, sync bool, logger log.Logger, getFileFunc GetFileFunc) error

DownloadFileFromStorage downloads a file from storage to given location.

func IsCompressedFile

func IsCompressedFile(filename string) bool

func LoggerWithFilename

func LoggerWithFilename(logger log.Logger, filename string) log.Logger

func ValidateSharedStoreKeyPrefix

func ValidateSharedStoreKeyPrefix(prefix string) error

Types

type Client

type Client interface {
	CommonIndexClient
	UserIndexClient

	RefreshIndexListCache(ctx context.Context)
	ListTables(ctx context.Context) ([]string, error)
	IsFileNotFoundErr(err error) bool
	Stop()
}

Client is used to manage boltdb index files in object storage, when using boltdb-shipper.

func NewIndexStorageClient

func NewIndexStorageClient(origObjectClient client.ObjectClient, storagePrefix string) Client

type CommonIndexClient

type CommonIndexClient interface {
	ListFiles(ctx context.Context, tableName string, bypassCache bool) ([]IndexFile, []string, error)
	GetFile(ctx context.Context, tableName, fileName string) (io.ReadCloser, error)
	PutFile(ctx context.Context, tableName, fileName string, file io.ReadSeeker) error
	DeleteFile(ctx context.Context, tableName, fileName string) error
}

CommonIndexClient allows doing operations on the object store for common index.

type GetFileFunc

type GetFileFunc func() (io.ReadCloser, error)

type IndexFile

type IndexFile struct {
	Name       string
	ModifiedAt time.Time
}

type IndexSet

type IndexSet interface {
	RefreshIndexListCache(ctx context.Context)
	ListFiles(ctx context.Context, tableName, userID string, bypassCache bool) ([]IndexFile, error)
	GetFile(ctx context.Context, tableName, userID, fileName string) (io.ReadCloser, error)
	PutFile(ctx context.Context, tableName, userID, fileName string, file io.ReadSeeker) error
	DeleteFile(ctx context.Context, tableName, userID, fileName string) error
	IsFileNotFoundErr(err error) bool
	IsUserBasedIndexSet() bool
}

IndexSet provides storage operations for user or common index tables.

func NewIndexSet

func NewIndexSet(client Client, userBasedIndex bool) IndexSet

NewIndexSet handles storage operations based on the value of indexSet.userBasedIndex

type UserIndexClient

type UserIndexClient interface {
	ListUserFiles(ctx context.Context, tableName, userID string, bypassCache bool) ([]IndexFile, error)
	GetUserFile(ctx context.Context, tableName, userID, fileName string) (io.ReadCloser, error)
	PutUserFile(ctx context.Context, tableName, userID, fileName string, file io.ReadSeeker) error
	DeleteUserFile(ctx context.Context, tableName, userID, fileName string) error
}

UserIndexClient allows doing operations on the object store for user specific index.

Jump to

Keyboard shortcuts

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