lassie

package
v0.14.2-releaser-test Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: Apache-2.0, MIT Imports: 14 Imported by: 7

Documentation

Index

Constants

This section is empty.

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, eventsCb func(types.RetrievalEvent)) (*types.RetrievalStats, error)

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 {
	Finder                 retriever.CandidateFinder
	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
}

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, applied using a preloader during traversals. The default is 6.

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 WithFinder

func WithFinder(finder retriever.CandidateFinder) LassieOption

WithFinder allows you to specify a custom candidate finder.

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