Documentation
¶
Overview ¶
Package core provides the core implementation of the gdl download functionality.
Index ¶
- Constants
- type Downloader
- func (d *Downloader) Download(ctx context.Context, url, destination string, options *types.DownloadOptions) (*types.DownloadStats, error)
- func (d *Downloader) DownloadToWriter(ctx context.Context, url string, writer io.Writer, ...) (*types.DownloadStats, error)
- func (d *Downloader) GetFileInfo(ctx context.Context, url string) (*types.FileInfo, error)
- func (d *Downloader) WithLogging(enabled bool) *Downloader
- func (d *Downloader) WithRetryStrategy(manager *retry.RetryManager) *Downloader
- func (d *Downloader) WithSpaceChecker(checker *storage.SpaceChecker) *Downloader
Constants ¶
const DefaultChunkSize = 32 * 1024 // 32KB
DefaultChunkSize is the default size for reading chunks during download.
const DefaultTimeout = 30 * time.Minute
DefaultTimeout is the default timeout for download operations.
const DefaultUserAgent = "gdl/1.0"
DefaultUserAgent is the default User-Agent string used for HTTP requests.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
func NewDownloader ¶
func NewDownloader() *Downloader
NewDownloader creates a new Downloader instance with default settings.
func NewDownloaderWithClient ¶
func NewDownloaderWithClient(client *http.Client) *Downloader
NewDownloaderWithClient creates a new Downloader instance with a custom HTTP client.
func (*Downloader) Download ¶
func (d *Downloader) Download( ctx context.Context, url, destination string, options *types.DownloadOptions, ) (*types.DownloadStats, error)
func (*Downloader) DownloadToWriter ¶
func (d *Downloader) DownloadToWriter( ctx context.Context, url string, writer io.Writer, options *types.DownloadOptions, ) (*types.DownloadStats, error)
DownloadToWriter downloads a file from the given URL and writes it to the provided writer. It implements the types.Downloader interface.
func (*Downloader) GetFileInfo ¶
GetFileInfo retrieves information about a file without downloading it. It implements the types.Downloader interface.
func (*Downloader) WithLogging ¶
func (d *Downloader) WithLogging(enabled bool) *Downloader
WithLogging enables or disables enhanced logging with error context.
func (*Downloader) WithRetryStrategy ¶
func (d *Downloader) WithRetryStrategy(manager *retry.RetryManager) *Downloader
WithRetryStrategy configures the retry strategy for downloads.
func (*Downloader) WithSpaceChecker ¶
func (d *Downloader) WithSpaceChecker(checker *storage.SpaceChecker) *Downloader
WithSpaceChecker configures the disk space checker.