storage

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: Apache-2.0, MIT Imports: 21 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsIdentity added in v0.19.0

func AsIdentity(key string) (digest []byte, ok bool, err error)

Types

type CachingTempStore

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

CachingTempStore is a ReadableWritableStorage that is intended for temporary use. It uses DeferredStorageCar as a backing store, so the underlying CAR file is lazily created on the first write (none will be created if there are no writes).

A provided BlockWriteOpener will receive blocks for each Put operation, this is intended to be used to write a properly ordered CARv1 file.

PreloadStore returns a secondary ReadableWritableStorage that can be used by a traversal preloader to optimistically load blocks into the temporary store. Blocks loaded via the PreloadStore will not be written to the provided BlockWriteOpener until they appear in a Put operation on the parent store. In this way, the BlockWriteOpener will receive blocks in the order that they appear in the traversal.

func NewCachingTempStore

func NewCachingTempStore(outWriter linking.BlockWriteOpener, store *DeferredStorageCar) *CachingTempStore

func (*CachingTempStore) Close

func (ttrw *CachingTempStore) Close() error

Close will clean up any temporary resources used by the storage.

func (*CachingTempStore) Get

func (ttrw *CachingTempStore) Get(ctx context.Context, key string) ([]byte, error)

func (*CachingTempStore) GetStream

func (ttrw *CachingTempStore) GetStream(ctx context.Context, key string) (io.ReadCloser, error)

func (*CachingTempStore) Has

func (ttrw *CachingTempStore) Has(ctx context.Context, key string) (bool, error)

func (*CachingTempStore) PreloadStore

func (ttrw *CachingTempStore) PreloadStore() types.ReadableWritableStorage

func (*CachingTempStore) Put

func (ttrw *CachingTempStore) Put(ctx context.Context, key string, data []byte) error

Put writes both to temporary readwrite caching storage (available for read operations) and to the underlying write-only CARv1 output at the same time.

type DeferredStorageCar

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

DeferredStorageCar is a wrapper around github.com/ipld/go-car/v2/storage.StorageCar that defers creating the CAR until the first Put() operation. In this way it can be optimistically instantiated and no file will be created if it is never written to (such as in the case of an error).

func NewDeferredStorageCar

func NewDeferredStorageCar(tempDir string, root cid.Cid) *DeferredStorageCar

NewDeferredStorageCar creates a new DeferredStorageCar.

func (*DeferredStorageCar) Close

func (dcs *DeferredStorageCar) Close() error

Close will clean up any temporary resources used by the storage.

func (*DeferredStorageCar) Get

func (dcs *DeferredStorageCar) Get(ctx context.Context, key string) ([]byte, error)

Get returns data from the underlying CARv1.

func (*DeferredStorageCar) GetStream

func (dcs *DeferredStorageCar) GetStream(ctx context.Context, key string) (io.ReadCloser, error)

GetStream returns data from the underlying CARv1.

func (*DeferredStorageCar) Has

func (dcs *DeferredStorageCar) Has(ctx context.Context, key string) (bool, error)

Has returns true if the underlying CARv1 has the key.

func (*DeferredStorageCar) Put

func (dcs *DeferredStorageCar) Put(ctx context.Context, key string, data []byte) error

Put writes data to the underlying CARv1 which will be initialised on the first call to Put.

type DeferredWriter added in v0.11.0

type DeferredWriter interface {
	ipldstorage.WritableStorage
	io.Closer
	BlockWriteOpener() linking.BlockWriteOpener
	OnPut(cb func(int), once bool)
}

type DuplicateAdderCar added in v0.11.0

type DuplicateAdderCar struct {
	*deferred.DeferredCarWriter
	// contains filtered or unexported fields
}

func NewDuplicateAdderCarForPath added in v0.20.1

func NewDuplicateAdderCarForPath(
	ctx context.Context,
	outPath string,
	root cid.Cid,
	path string,
	scope trustlessutils.DagScope,
	bytes *trustlessutils.ByteRange,
	store *DeferredStorageCar,
) *DuplicateAdderCar

func NewDuplicateAdderCarForStream added in v0.11.0

func NewDuplicateAdderCarForStream(
	ctx context.Context,
	outStream io.Writer,
	root cid.Cid,
	path string,
	scope trustlessutils.DagScope,
	bytes *trustlessutils.ByteRange,
	store *DeferredStorageCar,
) *DuplicateAdderCar

func (*DuplicateAdderCar) BlockWriteOpener added in v0.11.0

func (da *DuplicateAdderCar) BlockWriteOpener() linking.BlockWriteOpener

func (*DuplicateAdderCar) Close added in v0.11.0

func (da *DuplicateAdderCar) Close() error

Close closes the dup stream, verifying completion, if one was created.

Jump to

Keyboard shortcuts

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