transfer

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 3, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultBlockSize 默认的BlockSize
	DefaultBlockSize = 256 * converter.KB
)

Variables

View Source
var (
	// ErrUnknownRangeGenMode RangeGenMode 非法
	ErrUnknownRangeGenMode = errors.New("Unknown RangeGenMode")
)
View Source
var RangeGenMode_name = map[int32]string{
	0: "Default",
	1: "BlockSize",
}
View Source
var RangeGenMode_value = map[string]int32{
	"Default":   0,
	"BlockSize": 1,
}

Functions

This section is empty.

Types

type DownloadInstanceInfo

type DownloadInstanceInfo struct {
	DownloadStatus *DownloadStatus
	Ranges         RangeList
}

DownloadInstanceInfo 状态详细信息, 用于导出状态文件

type DownloadInstanceInfoExport

type DownloadInstanceInfoExport struct {
	RangeGenMode         RangeGenMode `` /* 127-byte string literal not displayed */
	TotalSize            int64        `protobuf:"varint,2,opt,name=total_size,json=totalSize,proto3" json:"total_size,omitempty"`
	GenBegin             int64        `protobuf:"varint,3,opt,name=gen_begin,json=genBegin,proto3" json:"gen_begin,omitempty"`
	BlockSize            int64        `protobuf:"varint,4,opt,name=block_size,json=blockSize,proto3" json:"block_size,omitempty"`
	Ranges               []*Range     `protobuf:"bytes,5,rep,name=ranges,proto3" json:"ranges,omitempty"`
	XXX_NoUnkeyedLiteral struct{}     `json:"-"`
	XXX_unrecognized     []byte       `json:"-"`
	XXX_sizecache        int32        `json:"-"`
}

DownloadInstanceInfoExport 断点续传

func (*DownloadInstanceInfoExport) Descriptor

func (*DownloadInstanceInfoExport) Descriptor() ([]byte, []int)

func (*DownloadInstanceInfoExport) GetBlockSize

func (m *DownloadInstanceInfoExport) GetBlockSize() int64

func (*DownloadInstanceInfoExport) GetGenBegin

func (m *DownloadInstanceInfoExport) GetGenBegin() int64

func (*DownloadInstanceInfoExport) GetInstanceInfo

func (m *DownloadInstanceInfoExport) GetInstanceInfo() (eii *DownloadInstanceInfo)

GetInstanceInfo 从断点信息获取下载状态

func (*DownloadInstanceInfoExport) GetRangeGenMode

func (m *DownloadInstanceInfoExport) GetRangeGenMode() RangeGenMode

func (*DownloadInstanceInfoExport) GetRanges

func (m *DownloadInstanceInfoExport) GetRanges() []*Range

func (*DownloadInstanceInfoExport) GetTotalSize

func (m *DownloadInstanceInfoExport) GetTotalSize() int64

func (*DownloadInstanceInfoExport) ProtoMessage

func (*DownloadInstanceInfoExport) ProtoMessage()

func (*DownloadInstanceInfoExport) Reset

func (m *DownloadInstanceInfoExport) Reset()

func (*DownloadInstanceInfoExport) SetInstanceInfo

func (m *DownloadInstanceInfoExport) SetInstanceInfo(eii *DownloadInstanceInfo)

SetInstanceInfo 从下载状态导出断点信息

func (*DownloadInstanceInfoExport) String

func (m *DownloadInstanceInfoExport) String() string

func (*DownloadInstanceInfoExport) XXX_DiscardUnknown

func (m *DownloadInstanceInfoExport) XXX_DiscardUnknown()

func (*DownloadInstanceInfoExport) XXX_Marshal

func (m *DownloadInstanceInfoExport) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DownloadInstanceInfoExport) XXX_Merge

func (m *DownloadInstanceInfoExport) XXX_Merge(src proto.Message)

func (*DownloadInstanceInfoExport) XXX_Size

func (m *DownloadInstanceInfoExport) XXX_Size() int

func (*DownloadInstanceInfoExport) XXX_Unmarshal

func (m *DownloadInstanceInfoExport) XXX_Unmarshal(b []byte) error

type DownloadInstanceInfoExporter

type DownloadInstanceInfoExporter interface {
	GetInstanceInfo() *DownloadInstanceInfo
	SetInstanceInfo(*DownloadInstanceInfo)
}

DownloadInstanceInfoExporter 断点续传类型接口

type DownloadStatus

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

DownloadStatus 下载状态及统计信息

func NewDownloadStatus

func NewDownloadStatus() *DownloadStatus

NewDownloadStatus 初始化DownloadStatus

func (*DownloadStatus) AddDownloaded

func (ds *DownloadStatus) AddDownloaded(d int64)

AddDownloaded 增加已下载数据量

func (*DownloadStatus) AddSpeedsDownloaded

func (ds *DownloadStatus) AddSpeedsDownloaded(d int64)

AddSpeedsDownloaded 增加已下载数据量, 用于统计速度

func (*DownloadStatus) AddTotalSize

func (ds *DownloadStatus) AddTotalSize(size int64)

AddTotalSize 增加总大小 (不支持多线程)

func (*DownloadStatus) ClearMaxSpeeds

func (ds *DownloadStatus) ClearMaxSpeeds()

ClearMaxSpeeds 清空统计最大速度, 原子操作

func (*DownloadStatus) Downloaded

func (ds *DownloadStatus) Downloaded() int64

Downloaded 返回已下载数据量

func (*DownloadStatus) MaxSpeeds

func (ds *DownloadStatus) MaxSpeeds() int64

MaxSpeeds 返回最大速度

func (*DownloadStatus) RangeListGen

func (ds *DownloadStatus) RangeListGen() *RangeListGen

RangeListGen 返回RangeListGen

func (*DownloadStatus) SetMaxSpeeds

func (ds *DownloadStatus) SetMaxSpeeds(speeds int64)

SetMaxSpeeds 设置最大速度, 原子操作

func (*DownloadStatus) SetRangeListGen

func (ds *DownloadStatus) SetRangeListGen(gen *RangeListGen)

SetRangeListGen 设置RangeListGen

func (*DownloadStatus) SetRateLimit

func (ds *DownloadStatus) SetRateLimit(rl *speeds.RateLimit)

SetRateLimit 设置限速

func (*DownloadStatus) SetTotalSize

func (ds *DownloadStatus) SetTotalSize(size int64)

SetTotalSize 返回总大小

func (*DownloadStatus) SpeedsPerSecond

func (ds *DownloadStatus) SpeedsPerSecond() int64

SpeedsPerSecond 返回每秒速度

func (*DownloadStatus) TimeElapsed

func (ds *DownloadStatus) TimeElapsed() (elapsed time.Duration)

TimeElapsed 返回花费的时间

func (*DownloadStatus) TimeLeft

func (ds *DownloadStatus) TimeLeft() (left time.Duration)

TimeLeft 返回预计剩余时间

func (*DownloadStatus) TotalSize

func (ds *DownloadStatus) TotalSize() int64

TotalSize 返回总大小

func (*DownloadStatus) UpdateSpeeds

func (ds *DownloadStatus) UpdateSpeeds()

UpdateSpeeds 更新speeds

type DownloadStatuser

type DownloadStatuser interface {
	TotalSize() int64
	Downloaded() int64
	SpeedsPerSecond() int64
	TimeElapsed() time.Duration // 已开始时间
	TimeLeft() time.Duration    // 预计剩余时间, 负数代表未知
}

DownloadStatuser 下载状态接口

type Range

type Range struct {
	Begin                int64    `protobuf:"varint,1,opt,name=begin,proto3" json:"begin,omitempty"`
	End                  int64    `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Range 请求范围

func (*Range) AddBegin

func (r *Range) AddBegin(i int64) (newi int64)

AddBegin 增加Begin, 原子操作

func (*Range) Descriptor

func (*Range) Descriptor() ([]byte, []int)

func (*Range) GetBegin

func (m *Range) GetBegin() int64

func (*Range) GetEnd

func (m *Range) GetEnd() int64

func (*Range) Len

func (r *Range) Len() int64

Len 长度

func (*Range) LoadBegin

func (r *Range) LoadBegin() int64

LoadBegin 读取Begin, 原子操作

func (*Range) LoadEnd

func (r *Range) LoadEnd() int64

LoadEnd 读取End, 原子操作

func (*Range) ProtoMessage

func (*Range) ProtoMessage()

func (*Range) Reset

func (m *Range) Reset()

func (*Range) ShowDetails

func (r *Range) ShowDetails() string

ShowDetails 显示Range细节

func (*Range) StoreBegin

func (r *Range) StoreBegin(end int64)

StoreBegin 储存End, 原子操作

func (*Range) StoreEnd

func (r *Range) StoreEnd(end int64)

StoreEnd 储存End, 原子操作

func (*Range) String

func (m *Range) String() string

func (*Range) XXX_DiscardUnknown

func (m *Range) XXX_DiscardUnknown()

func (*Range) XXX_Marshal

func (m *Range) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Range) XXX_Merge

func (m *Range) XXX_Merge(src proto.Message)

func (*Range) XXX_Size

func (m *Range) XXX_Size() int

func (*Range) XXX_Unmarshal

func (m *Range) XXX_Unmarshal(b []byte) error

type RangeGenMode

type RangeGenMode int32

RangeGenMode 线程分配方式

const (
	// RangeGenMode_Default 根据parallel平均生成
	RangeGenMode_Default RangeGenMode = 0
	// RangeGenMode_BlockSize 根据blockSize生成
	RangeGenMode_BlockSize RangeGenMode = 1
)

func (RangeGenMode) EnumDescriptor

func (RangeGenMode) EnumDescriptor() ([]byte, []int)

func (RangeGenMode) String

func (x RangeGenMode) String() string

type RangeList

type RangeList []*Range

RangeList 请求范围列表

func (*RangeList) Len

func (rl *RangeList) Len() int64

Len 获取所有的Range的剩余长度

type RangeListGen

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

RangeListGen Range 生成器

func NewRangeListGenBlockSize

func NewRangeListGenBlockSize(totalSize, begin, blockSize int64) *RangeListGen

NewRangeListGenBlockSize 初始化Range生成器, 根据blockSize生成

func NewRangeListGenDefault

func NewRangeListGenDefault(totalSize, begin int64, count, parallel int) *RangeListGen

NewRangeListGenDefault 初始化默认Range生成器, 根据parallel平均生成

func (*RangeListGen) GenRange

func (gen *RangeListGen) GenRange() (index int, r *Range)

GenRange 生成 Range

func (*RangeListGen) IsDone

func (gen *RangeListGen) IsDone() bool

IsDone 是否已分配完成

func (*RangeListGen) LoadBegin

func (gen *RangeListGen) LoadBegin() (begin int64)

LoadBegin 返回begin

func (*RangeListGen) LoadBlockSize

func (gen *RangeListGen) LoadBlockSize() (blockSize int64)

LoadBlockSize 返回blockSize

func (*RangeListGen) RangeCount

func (gen *RangeListGen) RangeCount() (rangeCount int)

RangeCount 返回预计生成的Range数量

func (*RangeListGen) RangeGenMode

func (gen *RangeListGen) RangeGenMode() RangeGenMode

RangeGenMode 返回Range生成方式

Jump to

Keyboard shortcuts

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