Documentation ¶
Index ¶
- type Downloader
- type Flags
- type Modifier
- func FromFlags(fl *Flags) Modifier
- func WithClientOptions(mods ...kclient.Modifier) Modifier
- func WithContext(ctx context.Context) Modifier
- func WithProtocolOptions(mods ...protocol.Modifier) Modifier
- func WithRequestOptions(mods ...krequest.Modifier) Modifier
- func WithRetryOptions(mods ...retry.Modifier) Modifier
- func WithSchedulerOptions(mods ...scheduler.Modifier) Modifier
- func WithTimeout(timeout time.Duration) Modifier
- func WithWaitGroup(wg *sync.WaitGroup) Modifier
- func WithWorkpoolOptions(mods ...workpool.Modifier) Modifier
- type Modifiers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
func New ¶
func New(mods ...Modifier) (*Downloader, error)
func (*Downloader) Get ¶
func (d *Downloader) Get(url string, handler protocol.ResponseHandler, eh workpool.ErrorHandler, mods ...Modifier) error
Get will fetch the specified url, invoke handler to process the response, and eh to process the returned error.
Get will schedule the operation through a workpool.
The operation will fail if something goes wrong with the HTTP request, or if the handler returns error. Regardless, the error handler is invoked with the result of the Get (which could be nil, to indicate success).
When combining with WithRetry options, if the handler or get return error, the operation will be retried.
Get returns an error. But given that downloads are scheduled asynchronously, the only case when Get will return an error is if an invalid combination of flags or options was specified.
func (*Downloader) ProtocolModifiers ¶
func (*Downloader) Retrier ¶
Retrier returns a retrier with the same options that would be used by the downloader.
func (*Downloader) Wait ¶
func (d *Downloader) Wait()
type Flags ¶
type Flags struct { Timeout time.Duration Retry *retry.Flags Workpool *workpool.Flags Client *kclient.Flags }
func DefaultFlags ¶
func DefaultFlags() *Flags
type Modifier ¶
type Modifier func(*options) error