Documentation
¶
Index ¶
- type DefaultFetcher
- func (d *DefaultFetcher) DownloadFile(urlPath string, maxLength int64, _ time.Duration) ([]byte, error)
- func (f *DefaultFetcher) NewFetcherWithHTTPClient(hc httpClient) *DefaultFetcher
- func (f *DefaultFetcher) NewFetcherWithRoundTripper(rt http.RoundTripper) *DefaultFetcher
- func (f *DefaultFetcher) SetHTTPClient(hc httpClient)
- func (d *DefaultFetcher) SetHTTPUserAgent(httpUserAgent string)
- func (f *DefaultFetcher) SetRetry(retryInterval time.Duration, retryCount uint)
- func (f *DefaultFetcher) SetRetryOptions(retryOptions ...backoff.RetryOption)
- func (f *DefaultFetcher) SetTransport(rt http.RoundTripper) error
- type Fetcher
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
Click to show internal directories.
Click to hide internal directories.