cachedreader

package
v1.29.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0, MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxCachedReaders    = 512
	PieceReaderCacheTTL = 10 * time.Minute
	PieceErrorCacheTTL  = 5 * time.Second
)
View Source
const (
	// DEALS_TRUE_TTL is how long "this cluster has deals" is trusted. Deals
	// rarely disappear, and a stale true only means the legacy lookups run.
	DEALS_TRUE_TTL = 5 * time.Minute

	// DEALS_FALSE_TTL is how long "no deals" is trusted, so a cluster that gets
	// its first deal starts serving it quickly.
	DEALS_FALSE_TTL = 5 * time.Second

	DEALS_QUERY_TIMEOUT = 10 * time.Second
)

Variables

View Source
var CachedReaderMeasures = struct {
	CacheHits       *stats.Int64Measure
	CacheMisses     *stats.Int64Measure
	CacheEvictions  *stats.Int64Measure
	CacheSize       *stats.Int64Measure
	CacheRefs       *stats.Int64Measure
	ReaderErrors    *stats.Int64Measure
	ReaderSuccesses *stats.Int64Measure
}{
	CacheHits:       stats.Int64(pre+"cache_hits", "Number of cache hits.", stats.UnitDimensionless),
	CacheMisses:     stats.Int64(pre+"cache_misses", "Number of cache misses.", stats.UnitDimensionless),
	CacheEvictions:  stats.Int64(pre+"cache_evictions", "Number of cache evictions.", stats.UnitDimensionless),
	CacheSize:       stats.Int64(pre+"cache_size", "Current number of entries in cache.", stats.UnitDimensionless),
	CacheRefs:       stats.Int64(pre+"cache_refs", "Number of active references to cached readers.", stats.UnitDimensionless),
	ReaderErrors:    stats.Int64(pre+"reader_errors", "Total number of piece reader errors.", stats.UnitDimensionless),
	ReaderSuccesses: stats.Int64(pre+"reader_successes", "Total number of successful piece reader creations.", stats.UnitDimensionless),
}

CachedReaderMeasures groups all cached reader metrics.

View Source
var ErrNoDeal = errors.New("no deals found")

Functions

This section is empty.

Types

type CachedPieceReader

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

func NewCachedPieceReader

func NewCachedPieceReader(db *harmonydb.DB, sectorReader *pieceprovider.SectorReader, pieceParkReader *pieceprovider.PieceParkReader, idxStor *indexstore.IndexStore) *CachedPieceReader

func (*CachedPieceReader) GetSharedPieceReader

func (cpr *CachedPieceReader) GetSharedPieceReader(ctx context.Context, pieceCid cid.Cid, retrieval bool) (storiface.Reader, uint64, error)

func (*CachedPieceReader) SetOpenPieceReader added in v1.29.1

func (cpr *CachedPieceReader) SetOpenPieceReader(r OpenReader)

SetOpenPieceReader makes retrieval look in open-pieces before anything else.

type OpenReader added in v1.29.1

type OpenReader interface {
	ReadPiece(ctx context.Context, pc cid.Cid, rawSize int64) (storiface.Reader, error)
}

OpenReader reads pieces placed in the open-pieces hash space. It returns nil, nil when no disk that may hold the piece has it.

type SubPieceReader added in v1.27.2

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

func (SubPieceReader) Close added in v1.27.2

func (s SubPieceReader) Close() error

func (SubPieceReader) Read added in v1.27.2

func (s SubPieceReader) Read(p []byte) (n int, err error)

func (SubPieceReader) ReadAt added in v1.27.2

func (s SubPieceReader) ReadAt(p []byte, off int64) (n int, err error)

func (SubPieceReader) Seek added in v1.27.2

func (s SubPieceReader) Seek(offset int64, whence int) (int64, error)

Jump to

Keyboard shortcuts

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