fetcher

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultFetcher

type DefaultFetcher struct {
	Ctl    *controller.Controller
	Meta   *FetcherMeta
	DoneCh chan error
}

func (*DefaultFetcher) Setup

func (f *DefaultFetcher) Setup(ctl *controller.Controller) (err error)

func (*DefaultFetcher) Wait

func (f *DefaultFetcher) Wait() (err error)

type Fetcher

type Fetcher interface {
	// Name return the name of the protocol.
	Name() string

	Setup(ctl *controller.Controller) error
	// Resolve resource info from request
	Resolve(req *base.Request) error
	// Create ready to download, but not started
	Create(opts *base.Options) error
	Start() error
	Pause() error
	Continue() error
	Close() error

	// Meta returns the meta information of the download.
	Meta() *FetcherMeta
	// Progress returns the progress of the download.
	Progress() Progress
	// Wait for the download to complete, this method will block until the download is done.
	Wait() error
}

Fetcher defines the interface for a download protocol. One fetcher for each download task

type FetcherBuilder

type FetcherBuilder interface {
	// Schemes returns the schemes supported by the fetcher.
	Schemes() []string
	// Build returns a new fetcher.
	Build() Fetcher

	// Store fetcher
	Store(fetcher Fetcher) (any, error)
	// Restore fetcher
	Restore() (v any, f func(meta *FetcherMeta, v any) Fetcher)
}

FetcherBuilder defines the interface for a fetcher builder.

type FetcherMeta

type FetcherMeta struct {
	Req  *base.Request  `json:"req"`
	Res  *base.Resource `json:"res"`
	Opts *base.Options  `json:"opts"`
}

FetcherMeta defines the meta information of a fetcher.

func (*FetcherMeta) Filepath

func (m *FetcherMeta) Filepath(file *base.FileInfo) string

type Progress

type Progress []int64

Progress is a map of the progress of each file in the torrent.

func (Progress) TotalDownloaded

func (p Progress) TotalDownloaded() int64

TotalDownloaded returns the total downloaded bytes.

Jump to

Keyboard shortcuts

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