fetcher

package
v2.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultFetcher

type DefaultFetcher struct {
	// contains filtered or unexported fields
}

DefaultFetcher implements Fetcher

func NewDefaultFetcher added in v2.1.0

func NewDefaultFetcher() *DefaultFetcher

func (*DefaultFetcher) DownloadFile

func (d *DefaultFetcher) DownloadFile(urlPath string, maxLength int64, _ time.Duration) ([]byte, error)

DownloadFile downloads a file from urlPath, errors out if it failed, its length is larger than maxLength or the timeout is reached.

func (*DefaultFetcher) NewFetcherWithHTTPClient added in v2.1.0

func (f *DefaultFetcher) NewFetcherWithHTTPClient(hc httpClient) *DefaultFetcher

NewFetcherWithHTTPClient creates a new DefaultFetcher with a custom httpClient

func (*DefaultFetcher) NewFetcherWithRoundTripper added in v2.1.0

func (f *DefaultFetcher) NewFetcherWithRoundTripper(rt http.RoundTripper) *DefaultFetcher

NewFetcherWithRoundTripper creates a new DefaultFetcher with a custom RoundTripper The function will create a default http.Client and replace the transport with the provided RoundTripper implementation

func (*DefaultFetcher) SetHTTPClient added in v2.1.0

func (f *DefaultFetcher) SetHTTPClient(hc httpClient)

func (*DefaultFetcher) SetHTTPUserAgent

func (d *DefaultFetcher) SetHTTPUserAgent(httpUserAgent string)

func (*DefaultFetcher) SetRetry added in v2.1.0

func (f *DefaultFetcher) SetRetry(retryInterval time.Duration, retryCount uint)

func (*DefaultFetcher) SetRetryOptions added in v2.1.0

func (f *DefaultFetcher) SetRetryOptions(retryOptions ...backoff.RetryOption)

func (*DefaultFetcher) SetTransport added in v2.1.0

func (f *DefaultFetcher) SetTransport(rt http.RoundTripper) error

type Fetcher

type Fetcher interface {
	// DownloadFile downloads a file from the provided URL, reading
	// up to maxLength of bytes before it aborts.
	// The timeout argument is deprecated and not used. To configure
	// the timeout (or retries), modify the fetcher instead. For the
	// DefaultFetcher the underlying HTTP client can be substituted.
	DownloadFile(urlPath string, maxLength int64, _ time.Duration) ([]byte, error)
}

Fetcher interface

Jump to

Keyboard shortcuts

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