core

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package core provides the core implementation of the gdl download functionality.

Index

Constants

View Source
const DefaultChunkSize = 32 * 1024 // 32KB

DefaultChunkSize is the default size for reading chunks during download.

View Source
const DefaultTimeout = 30 * time.Minute

DefaultTimeout is the default timeout for download operations.

View Source
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

func (d *Downloader) GetFileInfo(ctx context.Context, url string) (*types.FileInfo, error)

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.

Jump to

Keyboard shortcuts

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