fetcher

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0, MIT Imports: 13 Imported by: 12

README

go-fetcher

Go-fetcher is a library to retrieve IPLD prime nodes from IPFS using Bitswap.

Contribute

PRs are welcome!

License

The go-fetcher project is dual-licensed under Apache 2.0 and MIT terms:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Block

func Block(ctx context.Context, f Fetcher, link ipld.Link) (ipld.Node, error)

Block fetches a schemaless node graph corresponding to single block by link.

func BlockAll

func BlockAll(ctx context.Context, f Fetcher, root ipld.Link, cb FetchCallback) error

BlockAll traverses all nodes in the graph linked by root. The nodes will be untyped and send over the results channel.

func BlockAllOfType

func BlockAllOfType(ctx context.Context, f Fetcher, root ipld.Link, ptype ipld.NodePrototype, cb FetchCallback) error

BlockAllOfType traverses all nodes in the graph linked by root. The nodes will typed according to ptype and send over the results channel.

func BlockMatching

func BlockMatching(ctx context.Context, f Fetcher, root ipld.Link, match selector.Selector, cb FetchCallback) error

BlockMatching traverses a schemaless node graph starting with the given link using the given selector and possibly crossing block boundaries. Each matched node is sent to the FetchResult channel.

Types

type FetchCallback added in v1.0.0

type FetchCallback func(result FetchResult) error

type FetchResult

type FetchResult struct {
	Node          ipld.Node
	Path          ipld.Path
	LastBlockPath ipld.Path
	LastBlockLink ipld.Link
}

type Fetcher

type Fetcher interface {
	// NodeMatching traverses a node graph starting with the provided node using the given selector and possibly crossing
	// block boundaries. Each matched node is passed as FetchResult to the callback. Errors returned from callback will
	// halt the traversal. The sequence of events is: NodeMatching begins, the callback is called zero or more times
	// with a FetchResult, then NodeMatching returns.
	NodeMatching(context.Context, ipld.Node, selector.Selector, FetchCallback) error

	// BlockOfType fetches a node graph of the provided type corresponding to single block by link.
	BlockOfType(context.Context, ipld.Link, ipld.NodePrototype) (ipld.Node, error)

	// BlockMatchingOfType traverses a node graph starting with the given link using the given selector and possibly
	// crossing block boundaries. The nodes will be typed using the provided prototype. Each matched node is passed as
	// a FetchResult to the callback. Errors returned from callback will halt the traversal.
	// The sequence of events is: BlockMatchingOfType begins, the callback is called zero or more times with a
	// FetchResult, then BlockMatchingOfType returns.
	BlockMatchingOfType(context.Context, ipld.Link, selector.Selector, ipld.NodePrototype, FetchCallback) error
}

type FetcherConfig

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

func NewFetcherConfig

func NewFetcherConfig(blockService blockservice.BlockService) FetcherConfig

NewFetcherConfig creates a FetchConfig from which session may be created and nodes retrieved.

func (FetcherConfig) NewSession

func (fc FetcherConfig) NewSession(ctx context.Context) Fetcher

NewSession creates a session from which nodes may be retrieved. The session ends when the provided context is canceled.

Jump to

Keyboard shortcuts

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