download

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	// DownloadURL is the target file's download URL.
	DownloadURL string

	// UserAgent is the user agent to use for the request.
	// If empty, Go's default behavior is preserved.
	UserAgent string

	// TargetFile is the target file.
	TargetFile *os.File

	// SecondaryTargetFile is the secondary target file.
	// Nil means no secondary target file.
	SecondaryTargetFile *os.File
}

Job is a download job.

func (*Job) Run

func (j *Job) Run(ctx context.Context, logger *slog.Logger, client *http.Client)

Run runs the job.

type WorkerFleet

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

WorkerFleet manages a fleet of workers.

func NewWorkerFleet

func NewWorkerFleet(ctx context.Context, logger *slog.Logger, client *http.Client, numWorkers int, jobCh <-chan Job) *WorkerFleet

NewWorkerFleet creates a new worker fleet with the given number of workers.

The workers pick up jobs from the given channel and run them.

After use, close the channel to stop the workers. Call the Wait method to wait for the workers to finish.

func (*WorkerFleet) Wait

func (wf *WorkerFleet) Wait()

Wait waits for the workers to finish.

Jump to

Keyboard shortcuts

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