storage

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: Apache-2.0, MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxObjects is the default maximum number of objects to store in memory.
	DefaultMaxObjects = 10000
)

Variables

This section is empty.

Functions

func ValidateObjectManifest added in v0.5.1

func ValidateObjectManifest(store Storage, manifest *pb.ObjectManifest) error

ValidateObjectManifest checks that the object manifest is valid.

Types

type FilesystemStorage

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

FilesystemStorage is a storage backend that stores chunks and objects in the local filesystem.

func NewFilesystemStorage

func NewFilesystemStorage(dir string, opts *FilesystemStorageOpts) (*FilesystemStorage, error)

NewFilesystemStorage creates a new filesystem storage backend.

func (*FilesystemStorage) GetChunk

func (s *FilesystemStorage) GetChunk(id contenthash.Hash) (io.ReadCloser, error)

GetChunk retrieves a chunk from storage.

func (*FilesystemStorage) GetObject

GetObject retrieves an object manifest from storage.

func (*FilesystemStorage) PutChunk

func (s *FilesystemStorage) PutChunk(id contenthash.Hash, r io.ReadSeeker) error

PutChunk adds a chunk to the storage.

func (*FilesystemStorage) PutObject

func (s *FilesystemStorage) PutObject(manifest *pb.ObjectManifest) error

PutObject adds an object manifest to the storage.

type FilesystemStorageOpts added in v0.5.0

type FilesystemStorageOpts struct {
	// NoSync disables fsync() calls after writing files. This will increase
	// performance but may lead to data loss in the event of a system crash.
	NoSync bool
}

FilesystemStorageOpts is used to configure the behaviour of the filesystem storage backend.

type InMemoryStorage added in v0.5.1

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

InMemoryStorage is an in-memory storage backend.

func NewInMemoryStorage added in v0.5.1

func NewInMemoryStorage(opts *InMemoryStorageOpts) (*InMemoryStorage, error)

NewInMemoryStorage creates a new in-memory storage backend.

func (*InMemoryStorage) GetChunk added in v0.5.1

func (s *InMemoryStorage) GetChunk(id contenthash.Hash) (io.ReadCloser, error)

GetChunk retrieves a chunk from storage.

func (*InMemoryStorage) GetObject added in v0.5.1

func (s *InMemoryStorage) GetObject(id contenthash.Hash) (*pb.ObjectManifest, error)

GetObject retrieves an object manifest from storage.

func (*InMemoryStorage) PutChunk added in v0.5.1

func (s *InMemoryStorage) PutChunk(id contenthash.Hash, r io.ReadSeeker) error

PutChunk adds a chunk to the storage.

func (*InMemoryStorage) PutObject added in v0.5.1

func (s *InMemoryStorage) PutObject(manifest *pb.ObjectManifest) error

PutObject adds an object manifest to the storage.

type InMemoryStorageOpts added in v0.5.1

type InMemoryStorageOpts struct {
	// MaxObjects is the maximum number of objects to store.
	MaxObjects int64
	// ChunkMemoryLimit is the maximum amount of memory to use for storing chunks.
	ChunkMemoryLimit int64
}

InMemoryStorageOpts is used to configure the behavior of the in-memory storage.

type Storage

type Storage interface {
	// GetObject retrieves an object manifest from storage.
	GetObject(id contenthash.Hash) (*pb.ObjectManifest, error)
	// PutObject adds an object manifest to the storage.
	PutObject(manifest *pb.ObjectManifest) error
	// GetChunk retrieves a chunk from storage.
	GetChunk(id contenthash.Hash) (io.ReadCloser, error)
	// PutChunk adds a chunk to the storage.
	PutChunk(id contenthash.Hash, r io.ReadSeeker) error
}

type TieredStorage added in v0.5.2

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

TieredStorage is a storage that delegates to multiple other storage backends. It is useful for implementing read through caches.

func NewTieredStorage added in v0.5.2

func NewTieredStorage(stores ...Storage) *TieredStorage

NewTieredStorage creates a new tiered storage. The backends are ordered in descending order by read priority.

func (*TieredStorage) GetChunk added in v0.5.2

func (s *TieredStorage) GetChunk(id contenthash.Hash) (io.ReadCloser, error)

GetChunk retrieves a chunk from storage.

func (*TieredStorage) GetObject added in v0.5.2

func (s *TieredStorage) GetObject(id contenthash.Hash) (*pb.ObjectManifest, error)

GetObject retrieves an object manifest from storage.

func (*TieredStorage) PutChunk added in v0.5.2

func (s *TieredStorage) PutChunk(id contenthash.Hash, r io.ReadSeeker) error

PutChunk adds a chunk to the storage.

func (*TieredStorage) PutObject added in v0.5.2

func (s *TieredStorage) PutObject(manifest *pb.ObjectManifest) error

PutObject adds an object manifest to the storage.

Jump to

Keyboard shortcuts

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