getter

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultStrategy     = DATA                           // default prefetching strategy
	DefaultStrict       = false                          // default fallback modes
	DefaultFetchTimeout = retrieval.RetrieveChunkTimeout // timeout for each chunk retrieval
)

Variables

View Source
var DefaultConfig = Config{
	Strategy:     DefaultStrategy,
	Strict:       DefaultStrict,
	FetchTimeout: DefaultFetchTimeout,
	Logger:       log.Noop,
}

DefaultConfig is the default configuration for the getter

Functions

func New

func New(addrs []swarm.Address, shardCnt int, g storage.Getter, p storage.Putter, remove func(error), conf Config) storage.Getter

New returns a decoder object used to retrieve children of an intermediate chunk

func SetConfigInContext

func SetConfigInContext(ctx context.Context, s *Strategy, fallbackmode *bool, fetchTimeout *string, logger log.Logger) (context.Context, error)

SetConfigInContext sets the config params in the context

func SetFetchTimeout

func SetFetchTimeout(ctx context.Context, timeout time.Duration) context.Context

SetFetchTimeout sets the timeout for each fetch

func SetLogger

func SetLogger(ctx context.Context, l log.Logger) context.Context

func SetStrategy

func SetStrategy(ctx context.Context, s Strategy) context.Context

SetStrategy sets the strategy for the retrieval

func SetStrict

func SetStrict(ctx context.Context, strict bool) context.Context

SetStrict sets the strict mode for the retrieval

Types

type Config

type Config struct {
	Strategy     Strategy
	Strict       bool
	FetchTimeout time.Duration
	Logger       log.Logger
}

Config is the configuration for the getter - public

func NewConfigFromContext

func NewConfigFromContext(ctx context.Context, def Config) (conf Config, err error)

NewConfigFromContext returns a new Config based on the context

type ReDecoder added in v2.7.0

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

ReDecoder is a wrapper around a Getter that first attempts to fetch a chunk directly from the network, and only falls back to recovery if the network fetch fails. This is used to handle cases where previously recovered chunks have been evicted from cache.

func NewReDecoder added in v2.7.0

func NewReDecoder(fetcher storage.Getter, recovery Recovery, logger log.Logger) *ReDecoder

NewReDecoder creates a new ReDecoder instance with the provided fetcher and recovery factory. The recovery decoder will only be created if needed (when network fetch fails).

func (*ReDecoder) Get added in v2.7.0

func (rd *ReDecoder) Get(ctx context.Context, addr swarm.Address) (swarm.Chunk, error)

Get implements the storage.Getter interface. It first attempts to fetch the chunk directly from the network. If that fails with ErrNotFound, it then creates the recovery decoder and attempts to recover the chunk.

type Recovery added in v2.7.0

type Recovery func() storage.Getter

Recovery is a function that creates a recovery decoder on demand

type Strategy

type Strategy = int
const (
	NONE Strategy = iota // no prefetching and no decoding
	DATA                 // just retrieve data shards no decoding
	PROX                 // proximity driven selective fetching
	RACE                 // aggressive fetching racing all chunks

)

Jump to

Keyboard shortcuts

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