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 // MigrateFromPath is the path to a possible existing file. // The path may be empty. The file may not exist or may have different content. MigrateFromPath string // PreserveMigrationSource controls whether to preserve the file at // MigrateFromPath should a migration happen. PreserveMigrationSource bool // DestinationPath is the destination path for downloading the file // or migrating an existing file to. DestinationPath string // SecondaryDestinationPath specifies where to put a copy of the file. // If empty, no copy is made. SecondaryDestinationPath string // NewHash is the function that returns a [hash.Hash] for verifying the file content. NewHash func() hash.Hash // Sum is the expected hash sum of the file. Sum []byte // Size is the expected size of the file. Size int64 }
Job is a precheck job.
A precheck job short-circuits the download process if any of the following conditions are met:
- The target file already exists at DestinationPath or SecondaryDestinationPath. In this case, the file is copied to the other path if it's not already there.
- The target file already exists at MigrateFromPath. In this case, the file is moved/copied to DestinationPath and copied to SecondaryDestinationPath.
type WorkerFleet ¶
type WorkerFleet struct {
// contains filtered or unexported fields
}
WorkerFleet manages a fleet of workers.
func NewWorkerFleet ¶
NewWorkerFleet creates a fleet of runtime.NumCPU workers.
These workers pick up precheck jobs from the given channel and produce download jobs to a download job channel.
After use, close the precheck job channel to stop the workers. Call the Wait method to wait for all workers to finish, and it will close the download job channel.
func (*WorkerFleet) DownloadJobChannel ¶
func (wf *WorkerFleet) DownloadJobChannel() <-chan download.Job
DownloadJobChannel returns the download job channel.
func (*WorkerFleet) Wait ¶
func (wf *WorkerFleet) Wait()
Wait waits for all workers to finish and closes the download job channel.
Click to show internal directories.
Click to hide internal directories.