ipldutil

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsContextCancelErr

func IsContextCancelErr(err error) bool

IsContextCancelErr checks whther the given err is ContextCancelError or has a one wrapped. See: errors.Is.

Types

type ContextCancelError

type ContextCancelError struct{}

ContextCancelError is a sentinel that indicates the passed in context was cancelled

func (ContextCancelError) Error

func (cp ContextCancelError) Error() string

type TraversalBuilder

type TraversalBuilder struct {
	Root          ipld.Link
	Selector      ipld.Node
	Visitor       traversal.AdvVisitFn
	LinkSystem    ipld.LinkSystem
	Chooser       traversal.LinkTargetNodePrototypeChooser
	Budget        *traversal.Budget
	PanicCallback panics.CallBackFn
}

TraversalBuilder defines parameters for an iterative traversal

func (TraversalBuilder) Start

func (tb TraversalBuilder) Start(parentCtx context.Context) Traverser

Start initiates the traversal (run in a go routine because the regular selector traversal expects a call back)

type Traverser

type Traverser interface {
	// IsComplete returns the completion state (boolean) and if so, the final
	// error result from IPLD.
	//
	// Note that CurrentRequest will block if the traverser is performing an
	// IPLD load.
	IsComplete() (bool, error)

	// CurrentRequest returns the parameters for the current block load waiting
	// to be fulfilled in order to advance further.
	//
	// Note that CurrentRequest will block if the traverser is performing an
	// IPLD load.
	CurrentRequest() (ipld.Link, ipld.LinkContext)

	// Advance advances the traversal successfully by supplying the given reader
	// as the result of the next IPLD load.
	Advance(reader io.Reader) error

	// Error errors the traversal by returning the given error as the result of
	// the next IPLD load.
	Error(err error)

	// Shutdown cancels the traversal
	Shutdown(ctx context.Context)

	// NBlocksTraversed returns the number of blocks successfully traversed
	NBlocksTraversed() int
}

Traverser is an interface for performing a selector traversal that operates iteratively -- it stops and waits for a manual load every time a block boundary is encountered

Jump to

Keyboard shortcuts

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