Documentation ¶
Index ¶
- Constants
- Variables
- func MakeAsyncCandidates(buffer int) (InboundAsyncCandidates, OutboundAsyncCandidates)
- func ParseProtocolsString(v string) ([]multicodec.Code, error)
- func ParseProviderStrings(v string) ([]peer.AddrInfo, error)
- func PathScopeSelector(path string, scope DagScope) ipld.Node
- func QueryResponseFromReader(r io.Reader) (*retrievaltypes.QueryResponse, error)
- func QueryToWriter(q *retrievaltypes.Query, w io.Writer) error
- func RegisterRetrievalIDToContext(parentCtx context.Context, id RetrievalID) context.Context
- type AsyncCandidateSplitter
- type AsyncRetrievalSplitter
- type AsyncRetrievalTask
- type CandidateFinder
- type CandidateRetrieval
- type CandidateRetriever
- type CandidateSplitter
- type CoordinationKind
- type DagScope
- type DeferredErrorTask
- type EventCode
- type FIL
- type Fetcher
- type FindCandidatesResult
- type InboundAsyncCandidates
- type OutboundAsyncCandidates
- type QueueRetrievalsFn
- type ReadableWritableStorage
- type RetrievalCandidate
- type RetrievalCoordinator
- type RetrievalEvent
- type RetrievalEventSubscriber
- type RetrievalID
- type RetrievalRequest
- func (r RetrievalRequest) Etag() string
- func (r RetrievalRequest) GetSelector() ipld.Node
- func (r RetrievalRequest) GetSupportedProtocols(allSupportedProtocols []multicodec.Code) []multicodec.Code
- func (r RetrievalRequest) GetUrlPath() (string, error)
- func (r RetrievalRequest) HasPreloadLinkSystem() bool
- type RetrievalResult
- type RetrievalSplitter
- type RetrievalStats
- type RetrievalTask
- type Retriever
Constants ¶
const ( RaceCoordination = "race" SequentialCoordination = "sequential" )
const BitswapIndentifier = "Bitswap"
const FilecoinPrecision = uint64(1_000_000_000_000_000_000)
Variables ¶
var ErrIncorrectContextValue = errors.New("context key does not point to a valid retrieval id")
ErrIncorrectContextValue indicates a value for the retrieval id context key that wasn't a retrieval id
var ErrMissingContextKey = errors.New("context key for retrieval is missing")
ErrMissingContextKey indicates no retrieval context key was present for a given context
Functions ¶
func MakeAsyncCandidates ¶ added in v0.6.0
func MakeAsyncCandidates(buffer int) (InboundAsyncCandidates, OutboundAsyncCandidates)
func ParseProtocolsString ¶ added in v0.6.9
func ParseProviderStrings ¶ added in v0.9.0
func PathScopeSelector ¶ added in v0.11.0
func QueryResponseFromReader ¶ added in v0.4.0
func QueryResponseFromReader(r io.Reader) (*retrievaltypes.QueryResponse, error)
QueryResponseFromReader reads a QueryResponse object in dag-cbor form from a stream
func QueryToWriter ¶ added in v0.4.0
func QueryToWriter(q *retrievaltypes.Query, w io.Writer) error
QueryToWriter writes a Query object in dag-cbor form to a stream
func RegisterRetrievalIDToContext ¶ added in v0.4.0
func RegisterRetrievalIDToContext(parentCtx context.Context, id RetrievalID) context.Context
Types ¶
type AsyncCandidateSplitter ¶ added in v0.6.0
type AsyncCandidateSplitter[T comparable] interface { SplitRetrievalRequest(ctx context.Context, request RetrievalRequest, events func(RetrievalEvent)) AsyncRetrievalSplitter[T] }
type AsyncRetrievalSplitter ¶ added in v0.6.0
type AsyncRetrievalSplitter[T comparable] interface { SplitAsyncCandidates(asyncCandidates InboundAsyncCandidates) (map[T]InboundAsyncCandidates, <-chan error) }
type AsyncRetrievalTask ¶ added in v0.6.0
type AsyncRetrievalTask struct { Candidates InboundAsyncCandidates AsyncCandidateRetrieval CandidateRetrieval }
AsyncRetrievalTask runs an asynchronous retrieval and returns a result
func (AsyncRetrievalTask) Run ¶ added in v0.6.0
func (art AsyncRetrievalTask) Run() (*RetrievalStats, error)
Run executes the asychronous retrieval task
type CandidateFinder ¶ added in v0.4.0
type CandidateFinder interface {
FindCandidates(ctx context.Context, request RetrievalRequest, events func(RetrievalEvent), onCandidates func([]RetrievalCandidate)) error
}
type CandidateRetrieval ¶ added in v0.4.0
type CandidateRetrieval interface {
RetrieveFromAsyncCandidates(asyncCandidates InboundAsyncCandidates) (*RetrievalStats, error)
}
type CandidateRetriever ¶ added in v0.3.0
type CandidateRetriever interface {
Retrieve(ctx context.Context, request RetrievalRequest, events func(RetrievalEvent)) CandidateRetrieval
}
type CandidateSplitter ¶ added in v0.4.0
type CandidateSplitter[T comparable] interface { SplitRetrievalRequest(ctx context.Context, request RetrievalRequest, events func(RetrievalEvent)) RetrievalSplitter[T] }
type CoordinationKind ¶ added in v0.4.0
type CoordinationKind string
type DagScope ¶ added in v0.11.0
type DagScope string
const DagScopeAll DagScope = "all"
const DagScopeBlock DagScope = "block"
const DagScopeEntity DagScope = "entity"
func (DagScope) AcceptHeader ¶ added in v0.11.0
func (DagScope) TerminalSelectorSpec ¶ added in v0.11.0
func (ds DagScope) TerminalSelectorSpec() builder.SelectorSpec
type DeferredErrorTask ¶ added in v0.6.0
DeferredErrorTask simply reads from an error channel and returns the result as an error
func (DeferredErrorTask) Run ¶ added in v0.6.0
func (det DeferredErrorTask) Run() (*RetrievalStats, error)
Run reads the error channel and returns a result
type EventCode ¶ added in v0.3.0
type EventCode string
const ( CandidatesFoundCode EventCode = "candidates-found" CandidatesFilteredCode EventCode = "candidates-filtered" StartedCode EventCode = "started" StartedFetchCode EventCode = "started-fetch" StartedFindingCandidatesCode EventCode = "started-finding-candidates" StartedRetrievalCode EventCode = "started-retrieval" ConnectedToProviderCode EventCode = "connected-to-provider" QueryAskedCode EventCode = "query-asked" QueryAskedFilteredCode EventCode = "query-asked-filtered" ProposedCode EventCode = "proposed" AcceptedCode EventCode = "accepted" FirstByteCode EventCode = "first-byte-received" FailedCode EventCode = "failed" FailedRetrievalCode EventCode = "failed-retrieval" SuccessCode EventCode = "success" FinishedCode EventCode = "finished" )
type FIL ¶
type FIL gostatetypesbig.Int
type Fetcher ¶ added in v0.14.3
type Fetcher interface {
Fetch(context.Context, RetrievalRequest, func(RetrievalEvent)) (*RetrievalStats, error)
}
type FindCandidatesResult ¶ added in v0.4.0
type FindCandidatesResult struct { Candidate RetrievalCandidate Err error }
type InboundAsyncCandidates ¶ added in v0.6.0
type InboundAsyncCandidates <-chan []RetrievalCandidate
func (InboundAsyncCandidates) Next ¶ added in v0.6.0
func (ias InboundAsyncCandidates) Next(ctx context.Context) (bool, []RetrievalCandidate, error)
type OutboundAsyncCandidates ¶ added in v0.6.0
type OutboundAsyncCandidates chan<- []RetrievalCandidate
func (OutboundAsyncCandidates) SendNext ¶ added in v0.6.0
func (oas OutboundAsyncCandidates) SendNext(ctx context.Context, next []RetrievalCandidate) error
type QueueRetrievalsFn ¶ added in v0.6.0
type QueueRetrievalsFn func(ctx context.Context, nextRetrievalCall func(RetrievalTask))
type ReadableWritableStorage ¶ added in v0.5.0
type ReadableWritableStorage interface { ipldstorage.ReadableStorage ipldstorage.WritableStorage ipldstorage.StreamingReadableStorage }
type RetrievalCandidate ¶ added in v0.3.0
type RetrievalCandidate struct { MinerPeer peer.AddrInfo RootCid cid.Cid Metadata metadata.Metadata }
func NewRetrievalCandidate ¶ added in v0.3.0
func NewRetrievalCandidate(pid peer.ID, addrs []multiaddr.Multiaddr, rootCid cid.Cid, protocols ...metadata.Protocol) RetrievalCandidate
type RetrievalCoordinator ¶ added in v0.4.0
type RetrievalCoordinator func(context.Context, QueueRetrievalsFn) (*RetrievalStats, error)
type RetrievalEvent ¶ added in v0.3.0
type RetrievalEvent interface { fmt.Stringer // Time returns the time that the event occurred Time() time.Time // RetrievalId returns the unique ID for this retrieval RetrievalId() RetrievalID // Code returns the type of event this is Code() EventCode // PayloadCid returns the CID being requested PayloadCid() cid.Cid }
type RetrievalEventSubscriber ¶ added in v0.3.0
type RetrievalEventSubscriber func(event RetrievalEvent)
RetrievalEventSubscriber is a function that receives a stream of retrieval events from all retrievals that are in progress. Various different types implement the RetrievalEvent interface and may contain additional information about the event beyond what is available on the RetrievalEvent interface.
type RetrievalID ¶ added in v0.3.0
func NewRetrievalID ¶ added in v0.3.0
func NewRetrievalID() (RetrievalID, error)
func RetrievalIDFromContext ¶ added in v0.4.0
func RetrievalIDFromContext(ctx context.Context) (RetrievalID, error)
func (RetrievalID) MarshalText ¶ added in v0.3.0
func (id RetrievalID) MarshalText() ([]byte, error)
func (RetrievalID) String ¶ added in v0.3.0
func (id RetrievalID) String() string
func (*RetrievalID) UnmarshalText ¶ added in v0.3.0
func (id *RetrievalID) UnmarshalText(data []byte) error
type RetrievalRequest ¶ added in v0.3.0
type RetrievalRequest struct { // RetrievalID is a unique identifier for this request. RetrievalID RetrievalID // Cid is the root CID to fetch. Cid cid.Cid // LinkSystem is the destination for the blocks to fetch, it may be // pre-populated with existing blocks in the DAG, in which case they may // be used to satisfy the request (except in the case of an HTTP retrieval, // which will fetch the entire DAG, regardless). LinkSystem ipld.LinkSystem // Selector is the IPLD selector to use when fetching the DAG. If nil, the // Path and Scope will be used to generate a selector. Selector ipld.Node // Path is the optional path within the DAG to fetch. Path string // Scope describes the scope of the DAG to fetch. If the Selector parameter // is not set, Scope and Path will be used to construct a selector. Scope DagScope // Duplicates is a flag that indicates whether duplicate blocks should be // stored into the LinkSystem where they occur in the traversal. Duplicates bool // Protocols is an optional list of protocols to use when fetching the DAG. // If nil, the default protocols will be used. Protocols []multicodec.Code // PreloadLinkSystem must be setup to enable Bitswap preload behavior. This // LinkSystem must be thread-safe as multiple goroutines may be using it to // store and retrieve blocks concurrently. PreloadLinkSystem ipld.LinkSystem // MaxBlocks optionally specifies the maximum number of blocks to fetch. // If zero, no limit is applied. MaxBlocks uint64 // FixedPeers optionally specifies a list of peers to use when fetching // blocks. If nil, the default peer discovery mechanism will be used. FixedPeers []peer.AddrInfo }
RetrievalRequest describes the parameters of a request. It is intended to be immutable.
func NewRequestForPath ¶ added in v0.5.0
func NewRequestForPath(store ipldstorage.WritableStorage, cid cid.Cid, path string, dagScope DagScope) (RetrievalRequest, error)
NewRequestForPath creates a new RetrievalRequest from the provided parameters and assigns a new RetrievalID to it.
The LinkSystem is configured to use the provided store for both reading and writing and it is explicitly set to be trusted (i.e. it will not check CIDs match bytes). If the storage is not truested, request.LinkSystem.TrustedStore should be set to false after this call.
func (RetrievalRequest) Etag ¶ added in v0.12.0
func (r RetrievalRequest) Etag() string
func (RetrievalRequest) GetSelector ¶ added in v0.5.0
func (r RetrievalRequest) GetSelector() ipld.Node
GetSelector will safely return a selector for this request. If none has been set, it will generate one for the path & scope.
func (RetrievalRequest) GetSupportedProtocols ¶ added in v0.6.9
func (r RetrievalRequest) GetSupportedProtocols(allSupportedProtocols []multicodec.Code) []multicodec.Code
GetSupportedProtocols will safely return the supported protocols for a specific request. It takes a list of all supported protocols, and -- if the request has protocols, it will return all the request protocols that are in the supported list -- if the request has no protocols, it will return the entire supported protocol list
func (RetrievalRequest) GetUrlPath ¶ added in v0.10.0
func (r RetrievalRequest) GetUrlPath() (string, error)
GetUrlPath returns a URL path and query string valid with the Trusted HTTP Gateway spec by combining the Path and the Scope of this request. If this request uses an explicit Selector rather than a Path, an error will be returned.
func (RetrievalRequest) HasPreloadLinkSystem ¶ added in v0.13.0
func (r RetrievalRequest) HasPreloadLinkSystem() bool
type RetrievalResult ¶ added in v0.4.0
type RetrievalResult struct { Stats *RetrievalStats Err error }
type RetrievalSplitter ¶ added in v0.4.0
type RetrievalSplitter[T comparable] interface { SplitCandidates([]RetrievalCandidate) (map[T][]RetrievalCandidate, error) }
type RetrievalStats ¶ added in v0.3.0
type RetrievalTask ¶ added in v0.6.0
type RetrievalTask interface {
Run() (*RetrievalStats, error)
}
retrieval task is any task that can be run to produce a result
type Retriever ¶ added in v0.3.0
type Retriever interface {
Retrieve(ctx context.Context, request RetrievalRequest, events func(RetrievalEvent)) (*RetrievalStats, error)
}