lassie

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: 14 Imported by: 4

Documentation

Index

Constants

View Source
const DefaultBitswapConcurrency = 32
View Source
const DefaultBitswapConcurrencyPerRetrieval = 12
View Source
const DefaultProviderTimeout = 20 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type Lassie

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

Lassie represents a reusable retrieval client.

func NewLassie

func NewLassie(ctx context.Context, opts ...LassieOption) (*Lassie, error)

NewLassie creates a new Lassie instance.

func NewLassieWithConfig

func NewLassieWithConfig(ctx context.Context, cfg *LassieConfig) (*Lassie, error)

NewLassieWithConfig creates a new Lassie instance with a custom configuration.

func (*Lassie) Fetch

func (l *Lassie) Fetch(ctx context.Context, request types.RetrievalRequest, opts ...types.FetchOption) (*types.RetrievalStats, error)

Fetch initiates a retrieval request and returns either some details about the retrieval or an error. The request should contain all of the parameters of the requested retrieval, including the LinkSystem where the blocks are intended to be stored.

func (*Lassie) RegisterSubscriber

func (l *Lassie) RegisterSubscriber(subscriber types.RetrievalEventSubscriber) func()

RegisterSubscriber registers a subscriber to receive retrieval events. The returned function can be called to unregister the subscriber.

type LassieConfig

type LassieConfig struct {
	Source                         types.CandidateSource
	Host                           host.Host
	ProviderTimeout                time.Duration
	ConcurrentSPRetrievals         uint
	GlobalTimeout                  time.Duration
	Libp2pOptions                  []libp2p.Option
	Protocols                      []multicodec.Code
	ProviderBlockList              map[peer.ID]bool
	ProviderAllowList              map[peer.ID]bool
	BitswapConcurrency             int
	BitswapConcurrencyPerRetrieval int
}

LassieConfig customizes the behavior of a Lassie instance.

func NewLassieConfig added in v0.13.0

func NewLassieConfig(opts ...LassieOption) *LassieConfig

NewLassieConfig creates a new LassieConfig instance with the given LassieOptions.

type LassieOption

type LassieOption func(cfg *LassieConfig)

func WithBitswapConcurrency added in v0.8.0

func WithBitswapConcurrency(concurrency int) LassieOption

WithBitswapConcurrency allows you to specify a custom concurrency for bitswap retrievals across all parallel retrievals in the same Lassie instance. This is applied using a preloader during traversals. The default is 32.

func WithBitswapConcurrencyPerRetrieval added in v0.18.0

func WithBitswapConcurrencyPerRetrieval(concurrency int) LassieOption

WithBitswapConcurrencyPerRetrieval allows you to specify a custom concurrency for bitswap retrievals for each individual parallel retrieval. This is applied using a preloader during traversals. The default is 8.

func WithCandidateSource added in v0.22.0

func WithCandidateSource(finder types.CandidateSource) LassieOption

WithCandidateSource allows you to specify a custom candidate finder.

func WithConcurrentSPRetrievals added in v0.4.6

func WithConcurrentSPRetrievals(maxConcurrentSPRtreievals uint) LassieOption

WithConcurrentSPRetrievals allows you to specify a custom number of concurrent retrievals from a single storage provider.

func WithGlobalTimeout added in v0.4.0

func WithGlobalTimeout(timeout time.Duration) LassieOption

WithGlobalTimeout allows you to specify a custom timeout for the entire retrieval process.

func WithHost added in v0.4.0

func WithHost(host host.Host) LassieOption

WithHost allows you to specify a custom libp2p host.

func WithLibp2pOpts added in v0.4.4

func WithLibp2pOpts(libp2pOptions ...libp2p.Option) LassieOption

WithLibp2pOpts allows you to specify custom libp2p options.

func WithProtocols added in v0.6.8

func WithProtocols(protocols []multicodec.Code) LassieOption

WithProtocols allows you to specify a custom set of protocols to use for retrieval.

func WithProviderAllowList added in v0.6.8

func WithProviderAllowList(providerAllowList map[peer.ID]bool) LassieOption

WithProviderAllowList allows you to specify a custom set of providers to allow fetching from. If this is not set, all providers will be allowed unless they are in the block list.

func WithProviderBlockList added in v0.6.8

func WithProviderBlockList(providerBlockList map[peer.ID]bool) LassieOption

WithProviderBlockList allows you to specify a custom provider block list.

func WithProviderTimeout added in v0.4.0

func WithProviderTimeout(timeout time.Duration) LassieOption

WithProviderTimeout allows you to specify a custom timeout for retrieving data from a provider. Beyond this limit, when no data has been received, the retrieval will fail.

Jump to

Keyboard shortcuts

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