Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client performs HTTP downloads with retry logic, resumption, and validation.
func (*Client) Download ¶
func (c *Client) Download(ctx context.Context, opts DownloadOptions) (*DownloadResult, error)
Download downloads a file from the given URL to the destination path. It supports resumable downloads, retries with exponential backoff, and checksum validation.
type DownloadOptions ¶
type DownloadOptions struct {
URL string
DestPath string
ExpectedChecksum string // SHA256 hex string, empty to skip validation
ExpectedSize int64 // 0 to skip size check
Headers map[string]string
RetryCount int // 0 defaults to 3
OnProgress ProgressFunc
}
DownloadOptions contains configuration for a single download.
type DownloadResult ¶
type DownloadResult struct {
Path string // Path to the downloaded file
Size int64 // Final file size in bytes
SHA256 string // SHA256 checksum in hex
Resumed bool // Whether the download was resumed
Attempts int // Number of attempts made
Duration time.Duration // Total download duration
}
DownloadResult contains the result of a successful download.
type Job ¶
type Job struct {
URL string
DestPath string
ExpectedChecksum string
ExpectedSize int64
Headers map[string]string
}
Job represents a single download job.
type Pool ¶
type Pool struct {
OnProgress func(destPath string, bytesDownloaded, totalBytes int64)
OnComplete func(destPath string, size int64, success bool, errMsg string)
// contains filtered or unexported fields
}
Pool manages concurrent downloads using a worker pool pattern.
type ProgressFunc ¶
type ProgressFunc func(bytesDownloaded, totalBytes int64)
ProgressFunc is called periodically to report download progress. bytesDownloaded is the number of bytes downloaded so far, totalBytes is the total size of the download (or 0 if unknown).