Documentation ¶
Index ¶
- Constants
- Variables
- func Identifier(event RetrievalEvent) string
- 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 FindCandidatesResult
- type InboundAsyncCandidates
- type OutboundAsyncCandidates
- type Phase
- type QueueRetrievalsFn
- type ReadableWritableStorage
- type RetrievalCandidate
- type RetrievalCoordinator
- type RetrievalEvent
- type RetrievalEventSubscriber
- type RetrievalID
- type RetrievalRequest
- 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 Identifier ¶ added in v0.4.0
func Identifier(event RetrievalEvent) string
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" ConnectedCode EventCode = "connected" QueryAskedCode EventCode = "query-asked" QueryAskedFilteredCode EventCode = "query-asked-filtered" ProposedCode EventCode = "proposed" AcceptedCode EventCode = "accepted" FirstByteCode EventCode = "first-byte-received" FailedCode EventCode = "failure" SuccessCode EventCode = "success" FinishedCode EventCode = "finished" )
type FIL ¶
type FIL gostatetypesbig.Int
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 Phase ¶ added in v0.3.0
type Phase string
const ( // FetchPhase encompasses the entire process from start to end, involves the finished event FetchPhase Phase = "fetch" // IndexerPhase involves a candidates-found|failure IndexerPhase Phase = "indexer" // QueryPhase involves a connect, query-asked|failure QueryPhase Phase = "query" // RetrievalPhase involves the full data retrieval: connect, proposed, accepted, first-byte-received, success|failure RetrievalPhase Phase = "retrieval" )
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 // Phase returns what phase of a retrieval this even occurred on Phase() Phase // PhaseStartTime returns the time that the phase started for this storage provider PhaseStartTime() time.Time // PayloadCid returns the CID being requested PayloadCid() cid.Cid // StorageProviderId returns the peer ID of the storage provider if this // retrieval was requested via peer ID StorageProviderId() peer.ID // Protocol Protocols() []multicodec.Code }
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 RetrievalID Cid cid.Cid LinkSystem ipld.LinkSystem Selector ipld.Node Path string Scope DagScope Duplicates bool Protocols []multicodec.Code PreloadLinkSystem ipld.LinkSystem MaxBlocks uint64 FixedPeers []peer.AddrInfo }
RetrievalRequest is the top level parameters for a request -- this should be left unchanged as you move down a retriever tree
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.
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)
}