sharded

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2020 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Overview

Package sharded implements common support for sharded blob providers, such as filesystem or webdav.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Impl

type Impl interface {
	GetBlobFromPath(ctx context.Context, dirPath, filePath string, offset, length int64) ([]byte, error)
	GetMetadataFromPath(ctx context.Context, dirPath, filePath string) (blob.Metadata, error)
	PutBlobInPath(ctx context.Context, dirPath, filePath string, dataSlices blob.Bytes) error
	SetTimeInPath(ctx context.Context, dirPath, filePath string, t time.Time) error
	DeleteBlobInPath(ctx context.Context, dirPath, filePath string) error
	ReadDir(ctx context.Context, path string) ([]os.FileInfo, error)
}

Impl must be implemented by underlying provided.

type Storage

type Storage struct {
	Impl Impl

	RootPath string
	Suffix   string
	Shards   []int
}

Storage provides common implementation of sharded storage.

func (Storage) DeleteBlob

func (s Storage) DeleteBlob(ctx context.Context, blobID blob.ID) error

DeleteBlob implements blob.Storage.

func (Storage) GetBlob

func (s Storage) GetBlob(ctx context.Context, blobID blob.ID, offset, length int64) ([]byte, error)

GetBlob implements blob.Storage.

func (Storage) GetMetadata added in v0.6.0

func (s Storage) GetMetadata(ctx context.Context, blobID blob.ID) (blob.Metadata, error)

GetMetadata implements blob.Storage.

func (Storage) GetShardedPathAndFilePath

func (s Storage) GetShardedPathAndFilePath(blobID blob.ID) (shardPath, filePath string)

GetShardedPathAndFilePath returns the path of the shard and file name within the shard for a given blob ID.

func (Storage) ListBlobs

func (s Storage) ListBlobs(ctx context.Context, prefix blob.ID, callback func(blob.Metadata) error) error

ListBlobs implements blob.Storage.

func (Storage) PutBlob

func (s Storage) PutBlob(ctx context.Context, blobID blob.ID, data blob.Bytes) error

PutBlob implements blob.Storage.

func (Storage) SetTime added in v0.7.0

func (s Storage) SetTime(ctx context.Context, blobID blob.ID, n time.Time) error

SetTime implements blob.Storage.

Jump to

Keyboard shortcuts

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