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.
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.
Click to show internal directories.
Click to hide internal directories.