Documentation
¶
Index ¶
Constants ¶
View Source
const ( MinRetrySleepDuration = time.Duration(0.2 * float64(time.Second)) MaxRetrySleepDuration = time.Duration(1.5 * float64(time.Second)) )
View Source
const ( ChunkSize int64 = 16384 // 16kb MinJobTakeoverSize int64 = 1048576 // 1mb EndJobTakeoverSize int64 = MinJobTakeoverSize / 3 * 2 MinEndJobTakeoverSize int64 = MinJobTakeoverSize / 3 DefaultTimeout = 10 * time.Second DefaultWorkers = 5 )
Variables ¶
View Source
var ( DefaultClient = internal.NewHTTPClient(DefaultTimeout, true) DefaultRetry = Retry{Status: 2, Connection: 6} )
Functions ¶
This section is empty.
Types ¶
type Download ¶
type Download struct { URL string DownloadInfo *DownloadInfo // contains filtered or unexported fields }
func NewDownload ¶
type DownloadInfo ¶
type DownloadInfo struct {
// contains filtered or unexported fields
}
func NewDownloadInfo ¶
func NewDownloadInfo() *DownloadInfo
func (*DownloadInfo) Done ¶
func (d *DownloadInfo) Done() <-chan struct{}
func (*DownloadInfo) Downloaded ¶
func (d *DownloadInfo) Downloaded() int64
func (*DownloadInfo) Inc ¶
func (d *DownloadInfo) Inc(value int64) int64
func (*DownloadInfo) SetDone ¶
func (d *DownloadInfo) SetDone()
type Downloader ¶
type Downloader struct { Client *http.Client Header http.Header Retry Retry // contains filtered or unexported fields }
func NewDownloader ¶
func NewDownloader(client *http.Client, retry Retry, workers int) *Downloader
func NewDownloaderWithDefaults ¶
func NewDownloaderWithDefaults() *Downloader
func (*Downloader) Run ¶
func (d *Downloader) Run(f *os.File, initialReq InitialRequest, download Download) error
func (*Downloader) SendInitialRequest ¶
func (d *Downloader) SendInitialRequest(ctx context.Context, download Download) (InitialRequest, error)
func (*Downloader) Workers ¶
func (d *Downloader) Workers() int
type IncompleteReadError ¶
type IncompleteReadError struct {
ExpectedLength, ActualLength int64
}
func (IncompleteReadError) Error ¶
func (e IncompleteReadError) Error() string
type InitialRequest ¶
type InitialRequest struct { RequestInfo // contains filtered or unexported fields }
func (InitialRequest) Cancel ¶
func (ir InitialRequest) Cancel() context.CancelFunc
func (InitialRequest) Close ¶
func (ir InitialRequest) Close() error
type RequestError ¶
type RequestError struct { Request *http.Request Response *http.Response // contains filtered or unexported fields }
func (RequestError) Error ¶
func (e RequestError) Error() string
func (RequestError) Unwrap ¶
func (e RequestError) Unwrap() error
type RequestInfo ¶
type RequestInfo struct { Retry Retry // contains filtered or unexported fields }
func (RequestInfo) Close ¶
func (r RequestInfo) Close() error
func (RequestInfo) Length ¶
func (r RequestInfo) Length() int64
func (RequestInfo) Response ¶
func (r RequestInfo) Response() *http.Response
type Retry ¶
type Retry struct {
Status, Connection RetryCount
}
type RetryCount ¶
type RetryCount int
func (RetryCount) Exceeds ¶
func (rc RetryCount) Exceeds(that RetryCount) bool
type StatusCodeError ¶
type StatusCodeError struct {
Code int
}
func (StatusCodeError) Error ¶
func (e StatusCodeError) Error() string
Click to show internal directories.
Click to hide internal directories.