w3rc

package module
v0.0.0-...-de8e8a8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT, Apache-2.0 Imports: 24 Imported by: 0

README

A Web3 Retrieval Client

An experimental retrieval client for web3 content.

This client attempts to delegate the content routing problem, using a delegated content routing interface like the one provided by storetheindex. It then will attempt to provide as simple as possible retrieval of discovered content, focusing on simplicity over optimality.

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*config) error

An Option allows opening a Session with configured options.

func WithDS

func WithDS(ds datastore.Batching) Option

WithDS sets the datastore to use for the session

func WithDataTransfer

func WithDataTransfer(dt datatransferi.Manager) Option

WithDataTransfer runs the session using an existing data transfer manager.

func WithHost

func WithHost(h host.Host) Option

WithHost sets a libp2p host for the client to use.

func WithIndexer

func WithIndexer(url string) Option

WithIndexer sets a URL of the indexer to use.

type ProgressResult

type ProgressResult struct {
	Status
	Error error
	ipld.Path
	ipld.Node
}

A ProgressResult is an individual update from a call to `GetStream` The result will either have a status of `Error` and an Error set, or will have a node and path set. The ResultChan a result is sent down will close after an error result or 'complete' result is sent.

type ResultChan

type ResultChan chan ProgressResult

ResultChan provides progress updates from a call to `GetStream`

type Session

type Session interface {
	// Get returns a dag rooted at root. If selector is `nil`, the single block
	// of the root will be assumed. If the full dag under root is desired, (following links)
	// `CommonSelector_MatchAllRecursively` should be provided.
	Get(ctx context.Context, root cid.Cid, selector datamodel.Node) (ipld.Node, error)

	// TODO: GetStream is not yet implemented - should follow logic of get but with incremental responses.
	//GetStream(ctx context.Context, root cid.Cid, selector datamodel.Node) ResultChan
	Close() error
}

A Session is able to fetch content addressed data.

func NewSession

func NewSession(ls ipld.LinkSystem, opts ...Option) (Session, error)

NewSession creates a Session with given configuration. A session represents a set of related queries for content addressed data. Connections to peers may stay open for the life of a session.

type Status

type Status uint8

Status is a code of the type of an individual Progress Result

const (
	ERROR Status = iota
	INPROGRESS
	COMPLETE
)

These are valid status codes

Directories

Path Synopsis
cmd
w3r

Jump to

Keyboard shortcuts

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