zssutils

package
v0.0.0-...-8f0ebae Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

* * * parallel download files * downloading with progress info and retry until completed * zssty2010@gmail.com

Index

Constants

View Source
const (
	Processing = iota
	Completed
	Failed
)

Variables

This section is empty.

Functions

func HttpGet

func HttpGet(url string, start int, end int) (*http.Response, error)

func NewPrinter

func NewPrinter(stat *statistics) func(TaskProgress)

golang not support default value. so we can use closures to do like this

Types

type FileInfo

type FileInfo struct {
	Name string
	Dir  string
	Ext  string
}

type MultitaskDL

type MultitaskDL struct {
	ThreadNum int
	// contains filtered or unexported fields
}

func NewMultitaskDL

func NewMultitaskDL(n int) MultitaskDL

func (*MultitaskDL) Do

func (dl *MultitaskDL) Do(res Resource, taskTrace chan TaskProgress) error

func (*MultitaskDL) ShutdownAndWait

func (dl *MultitaskDL) ShutdownAndWait()

func (*MultitaskDL) StartDownload

func (dl *MultitaskDL) StartDownload(resources []Resource)

main method start to download files

func (*MultitaskDL) StartSyncDownload

func (dl *MultitaskDL) StartSyncDownload(resourceChan chan Resource)

type Resource

type Resource struct {
	Url      string
	Fileinfo FileInfo
}

define download from where and where to save

type TaskProgress

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

inner struct to trace download progress

func (*TaskProgress) Failed

func (progress *TaskProgress) Failed(err error) error

func (*TaskProgress) Finish

func (progress *TaskProgress) Finish() error

func (*TaskProgress) Write

func (progress *TaskProgress) Write(p []byte) (n int, err error)

type Tracer

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

Jump to

Keyboard shortcuts

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