downloader

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionDownload           = "download"
	StatusDownloadSuccessful = "success"
	StatusDownloadFailed     = "failed"
	ActionDeclare            = "declare"
	StatusDeclareSuccessful  = "success"
	StatusDeclareFailed      = "failed"
	StatusCodeOK             = 10000
	StatusCodeFailed         = 20000
)

Variables

This section is empty.

Functions

func Downloading

func Downloading() bool

Types

type DownloadCallBackContent

type DownloadCallBackContent struct {
	Action     string   `json:"action,omitempty"`
	Status     string   `json:"status,omitempty"`
	StatusCode int      `json:"statusCode,omitempty"`
	SectorIDs  []string `json:"sectorIds,omitempty"`
	MinerID    string   `json:"minerID,omitempty"`
	ErrMsg     string   `json:"errMsg,omitempty"`
}

type DownloadPart

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

type Downloader

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

one download task <=> one Downloader

func InitDownloader

func InitDownloader(downloadURL, targetFile, targetPath, token, minerID string, partSize, maxWorkers, sectorID int,
	decompression, depart bool, ctx context.Context) *Downloader

todo: too many params

func (*Downloader) DownloadFile

func (d *Downloader) DownloadFile() error

type Transformer

type Transformer struct {
	sync.Mutex

	CacheDir  string
	SealedDir string

	MaxDownloader    int
	MaxDownloadRetry int
	// contains filtered or unexported fields
}
var (
	ErrRetryExceed    = errors.New("retry exceed")
	GlobalTransformer *Transformer
)

func InitTransformer

func InitTransformer(conf config.Config, ctx context.Context) *Transformer

func (*Transformer) CallBack

func (t *Transformer) CallBack(content DownloadCallBackContent) error

func (*Transformer) DeclareSector

func (t *Transformer) DeclareSector(sectorID int) error

func (*Transformer) Downloading

func (t *Transformer) Downloading() bool

not very precise

func (*Transformer) Run

func (t *Transformer) Run(buf chan types.Sector)

todo: run code need improve

func (*Transformer) UnProcessing

func (t *Transformer) UnProcessing(sectorID int)

Jump to

Keyboard shortcuts

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