block_store

package
v0.57.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBlockStoreIDEmpty is returned if the block store id was empty.
	ErrBlockStoreIDEmpty = errors.New("block store id cannot be empty")
	// ErrBlockStoreNotFound is returned if the block store was not found.
	ErrBlockStoreNotFound = errors.New("block store not found")
	// ErrReadOnly is returned if the block store is not writable.
	ErrReadOnly = errors.New("block store is read-only")
)

Functions

This section is empty.

Types

type AccessBlockStoreFunc

type AccessBlockStoreFunc = func(ctx context.Context, released func()) (Store, func(), error)

AccessBlockStoreFunc is a function to access a BlockStoreHandle. Optionally pass a released function that may be called when the handle was released. Returns a release function.

func NewAccessBlockStoreViaBusFunc

func NewAccessBlockStoreViaBusFunc(b bus.Bus, blockStoreID string, returnIfIdle bool) AccessBlockStoreFunc

NewAccessBlockStoreViaBusFunc builds a new func which accesses the BlockStore on the given bus using the LookupBlocKStore directive.

If returnIfIdle is set: ErrBlockStoreNotFound is returned if not found.

type Constructor

type Constructor func(
	ctx context.Context,
	le *logrus.Entry,
) (Store, error)

Constructor constructs a block store with common parameters.

type LookupBlockStore

type LookupBlockStore interface {
	// Directive indicates LookupBlockStore is a directive.
	directive.Directive

	// LookupBlockStoreId is the block store id to lookup.
	// If empty, returns all block stores on the bus.
	LookupBlockStoreId() string
}

LookupBlockStore is a directive to lookup a block store.

func NewLookupBlockStore

func NewLookupBlockStore(blockStoreId string) LookupBlockStore

NewLookupBlockStore constructs a new LookupBlockStore directive.

type LookupBlockStoreValue

type LookupBlockStoreValue = Store

LookupBlockStoreValue is the result type for LookupBlockStore. Multiple results may be pushed to the directive.

func ExLookupBlockStores

func ExLookupBlockStores(
	ctx context.Context,
	b bus.Bus,
	blockStoreId string,
	waitOne bool,
) ([]LookupBlockStoreValue, directive.Instance, directive.Reference, error)

ExLookupBlockStores executes the LookupBlockStore directive. If waitOne is set, waits for at least one value before returning.

func ExLookupFirstBlockStore

func ExLookupFirstBlockStore(
	ctx context.Context,
	b bus.Bus,
	blockStoreId string,
	returnIfIdle bool,
	valDisposeCb func(),
) (LookupBlockStoreValue, directive.Instance, directive.Reference, error)

ExLookupFirstBlockStore waits for the first block store to be returned. if returnIfIdle is set and the directive becomes idle, returns nil, nil, nil,

type Store

type Store interface {
	// GetID returns the ID of the block store.
	GetID() string

	// StoreOps are the block store operations.
	block.StoreOps
}

Store is a block store with an ID and read/write functions.

func NewStore

func NewStore(id string, ops block.StoreOps) Store

NewStore constructs a store with an id and opts.

type StoreReadThrough added in v0.57.0

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

StoreReadThrough reads from a primary source, then an optional lower source. When writeback is enabled, lower hits are synchronously written to primary.

StoreReadThrough is separate from block.StoreOverlay because StoreOverlay readback is asynchronous.

func NewStoreReadThrough added in v0.57.0

func NewStoreReadThrough(primary, lower StoreSource, writeback bool) *StoreReadThrough

NewStoreReadThrough constructs a synchronous read-through store.

func (*StoreReadThrough) BeginReadOperation added in v0.57.0

func (s *StoreReadThrough) BeginReadOperation(ctx context.Context) (block.StoreOps, func(), error)

BeginReadOperation opens read scopes on the currently available sources.

func (*StoreReadThrough) GetBlock added in v0.57.0

func (s *StoreReadThrough) GetBlock(ctx context.Context, ref *block.BlockRef) ([]byte, bool, error)

GetBlock reads the primary source, then the current lower source. When writeback is enabled, a lower hit is synchronously inserted into primary.

func (*StoreReadThrough) GetBlockExists added in v0.57.0

func (s *StoreReadThrough) GetBlockExists(ctx context.Context, ref *block.BlockRef) (bool, error)

GetBlockExists follows the same source order as GetBlock.

func (*StoreReadThrough) GetBlockExistsBatch added in v0.57.0

func (s *StoreReadThrough) GetBlockExistsBatch(ctx context.Context, refs []*block.BlockRef) ([]bool, error)

GetBlockExistsBatch follows the same source order as GetBlock.

func (*StoreReadThrough) GetHashType added in v0.57.0

func (s *StoreReadThrough) GetHashType() hash.HashType

GetHashType returns the first available source hash type.

func (*StoreReadThrough) GetSupportedFeatures added in v0.57.0

func (s *StoreReadThrough) GetSupportedFeatures() block.StoreFeature

GetSupportedFeatures returns the primary source's feature set.

func (*StoreReadThrough) PutBlock added in v0.57.0

PutBlock is unsupported because this store is read-only.

func (*StoreReadThrough) PutBlockBatch added in v0.57.0

PutBlockBatch is unsupported because this store is read-only.

func (*StoreReadThrough) RmBlock added in v0.57.0

RmBlock is unsupported because this store is read-only.

func (*StoreReadThrough) StatBlock added in v0.57.0

func (s *StoreReadThrough) StatBlock(ctx context.Context, ref *block.BlockRef) (*block.BlockStat, error)

StatBlock follows the same source order as GetBlock.

func (*StoreReadThrough) Sync added in v0.57.0

Sync reports that no durability barrier is needed for this read-only view.

type StoreSource added in v0.57.0

type StoreSource func() block.StoreOps

StoreSource resolves the current store for a read pipeline.

A nil result means that the source is unavailable and the pipeline moves to its next source.

Jump to

Keyboard shortcuts

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