Documentation
¶
Index ¶
- type Sheltie
- func (l *Sheltie) Extract(ctx context.Context, rootCid cid.Cid, ext *extractor.Extractor, ...) (*types.RetrievalStats, error)
- func (l *Sheltie) Fetch(ctx context.Context, request types.RetrievalRequest, opts ...types.FetchOption) (*types.RetrievalStats, error)
- func (l *Sheltie) RegisterSubscriber(subscriber types.RetrievalEventSubscriber) func()
- type SheltieConfig
- type SheltieOption
- func WithCandidateSource(finder types.CandidateSource) SheltieOption
- func WithGlobalTimeout(timeout time.Duration) SheltieOption
- func WithProviderAllowList(providerAllowList map[peer.ID]bool) SheltieOption
- func WithProviderBlockList(providerBlockList map[peer.ID]bool) SheltieOption
- func WithSkipBlockVerification(skip bool) SheltieOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Sheltie ¶
type Sheltie struct {
// contains filtered or unexported fields
}
Sheltie represents a reusable retrieval client.
func NewSheltie ¶
func NewSheltie(ctx context.Context, opts ...SheltieOption) (*Sheltie, error)
NewSheltie creates a new Sheltie instance.
func NewSheltieWithConfig ¶
func NewSheltieWithConfig(ctx context.Context, cfg *SheltieConfig) (*Sheltie, error)
NewSheltieWithConfig creates a new Sheltie instance with a custom configuration.
func (*Sheltie) Extract ¶ added in v1.0.0
func (l *Sheltie) Extract( ctx context.Context, rootCid cid.Cid, ext *extractor.Extractor, eventsCallback func(types.RetrievalEvent), onBlock func(int), ) (*types.RetrievalStats, error)
Extract retrieves content and extracts it directly to disk. This is memory-efficient: blocks are processed once and discarded.
func (*Sheltie) Fetch ¶
func (l *Sheltie) Fetch(ctx context.Context, request types.RetrievalRequest, opts ...types.FetchOption) (*types.RetrievalStats, error)
Fetch initiates a retrieval request and returns either some details about the retrieval or an error. The request should contain all of the parameters of the requested retrieval, including the LinkSystem where the blocks are intended to be stored.
func (*Sheltie) RegisterSubscriber ¶
func (l *Sheltie) RegisterSubscriber(subscriber types.RetrievalEventSubscriber) func()
RegisterSubscriber registers a subscriber to receive retrieval events. The returned function can be called to unregister the subscriber.
type SheltieConfig ¶
type SheltieConfig struct {
Source types.CandidateSource
GlobalTimeout time.Duration
ProviderBlockList map[peer.ID]bool
ProviderAllowList map[peer.ID]bool
SkipBlockVerification bool
}
SheltieConfig customizes the behavior of a Sheltie instance.
func NewSheltieConfig ¶
func NewSheltieConfig(opts ...SheltieOption) *SheltieConfig
NewSheltieConfig creates a new SheltieConfig instance with the given SheltieOptions.
type SheltieOption ¶
type SheltieOption func(cfg *SheltieConfig)
func WithCandidateSource ¶
func WithCandidateSource(finder types.CandidateSource) SheltieOption
WithCandidateSource allows you to specify a custom candidate finder.
func WithGlobalTimeout ¶
func WithGlobalTimeout(timeout time.Duration) SheltieOption
WithGlobalTimeout allows you to specify a custom timeout for the entire retrieval process.
func WithProviderAllowList ¶
func WithProviderAllowList(providerAllowList map[peer.ID]bool) SheltieOption
WithProviderAllowList allows you to specify a custom set of providers to allow fetching from. If this is not set, all providers will be allowed unless they are in the block list.
func WithProviderBlockList ¶
func WithProviderBlockList(providerBlockList map[peer.ID]bool) SheltieOption
WithProviderBlockList allows you to specify a custom provider block list.
func WithSkipBlockVerification ¶ added in v1.0.0
func WithSkipBlockVerification(skip bool) SheltieOption
WithSkipBlockVerification disables per-block hash verification. WARNING: This is dangerous - malicious gateways can serve arbitrary data!