downloaders

package
v1.54.4 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Downloaders

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

Downloaders is a number of downloader~s and a queue of waiters waiting for segments to be downloaded to a file.

func New

func New(item Item, opt *vfscommon.Options, remote string, src fs.Object) (dls *Downloaders)

New makes a downloader for item

func (*Downloaders) Close

func (dls *Downloaders) Close(inErr error) (err error)

Close all running downloaders and return any unfulfilled waiters with inErr

func (*Downloaders) Download

func (dls *Downloaders) Download(r ranges.Range) (err error)

Download the range passed in returning when it has been downloaded with an error from the downloading go routine.

func (*Downloaders) EnsureDownloader

func (dls *Downloaders) EnsureDownloader(r ranges.Range) (err error)

EnsureDownloader makes sure a downloader is running for the range passed in. If one isn't found then it starts it.

It does not wait for the range to be downloaded

type Item

type Item interface {
	// FindMissing adjusts r returning a new ranges.Range which only
	// contains the range which needs to be downloaded. This could be
	// empty - check with IsEmpty. It also adjust this to make sure it is
	// not larger than the file.
	FindMissing(r ranges.Range) (outr ranges.Range)

	// HasRange returns true if the current ranges entirely include range
	HasRange(r ranges.Range) bool

	// WriteAtNoOverwrite writes b to the file, but will not overwrite
	// already present ranges.
	//
	// This is used by the downloader to write bytes to the file
	//
	// It returns n the total bytes processed and skipped the number of
	// bytes which were processed but not actually written to the file.
	WriteAtNoOverwrite(b []byte, off int64) (n int, skipped int, err error)
}

Item is the interface that an item to download must obey

Jump to

Keyboard shortcuts

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