blobstore

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDataInconsistent = errors.New("data consistency check failed")

ErrDataInconsistent is returned when the data being written does not hash to the expected value.

View Source
var ErrTooLarge = errors.New("payload too large")

ErrTooLarge is returned when the data being written is larger than expected.

View Source
var ErrTooSmall = errors.New("payload too small")

ErrTooSmall is returned when the data being written is smaller than expected.

Functions

This section is empty.

Types

type Blobstore

type Blobstore interface {
	// Put stores the bytes to the store and ensures it hashes to the passed
	// digest.
	Put(ctx context.Context, digest multihash.Multihash, size uint64, body io.Reader) error
	// Get retrieves the object identified by the passed digest. Returns nil and
	// [ErrNotFound] if the object does not exist.
	//
	// Note: data is not hashed on read.
	Get(ctx context.Context, digest multihash.Multihash, opts ...GetOption) (Object, error)
}

type FileObject

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

func (FileObject) Body

func (o FileObject) Body() io.Reader

func (FileObject) Size

func (o FileObject) Size() int64

type FileSystemer

type FileSystemer interface {
	// FileSystem returns a filesystem interface for reading blobs.
	FileSystem() http.FileSystem
}

FileSystemer exposes the filesystem interface for reading blobs.

type FsBlobstore

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

func NewFsBlobstore

func NewFsBlobstore(rootdir string, tmpdir string) (*FsBlobstore, error)

NewFsBlobstore creates a Blobstore backed by the local filesystem. The tmpdir parameter is optional, defaulting to os.TempDir + "blobs".

func (*FsBlobstore) FileSystem

func (b *FsBlobstore) FileSystem() http.FileSystem

FileSystem returns a filesystem interface for reading blobs.

func (*FsBlobstore) Get

func (b *FsBlobstore) Get(ctx context.Context, digest multihash.Multihash, opts ...GetOption) (Object, error)

func (*FsBlobstore) Put

func (b *FsBlobstore) Put(ctx context.Context, digest multihash.Multihash, size uint64, body io.Reader) error

type GetOption

type GetOption func(cfg *options) error

GetOption is an option configuring byte retrieval from a blobstore.

func WithRange

func WithRange(byteRange Range) GetOption

WithRange configures a byte range to extract.

type MapBlobstore

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

func NewMapBlobstore

func NewMapBlobstore() *MapBlobstore

NewMapBlobstore creates a Blobstore backed by an in-memory map.

func (*MapBlobstore) FileSystem

func (mb *MapBlobstore) FileSystem() http.FileSystem

func (*MapBlobstore) Get

func (mb *MapBlobstore) Get(ctx context.Context, digest multihash.Multihash, opts ...GetOption) (Object, error)

func (*MapBlobstore) Put

func (mb *MapBlobstore) Put(ctx context.Context, digest multihash.Multihash, size uint64, body io.Reader) error

type MapObject

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

func (MapObject) Body

func (o MapObject) Body() io.Reader

func (MapObject) Size

func (o MapObject) Size() int64

type Object

type Object interface {
	// Size returns the total size of the object in bytes.
	Size() int64
	Body() io.Reader
}

type Range

type Range struct {
	Offset uint64
	Length *uint64
}

Jump to

Keyboard shortcuts

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