Documentation ¶
Index ¶
- Constants
- Variables
- type DownloadInstanceInfo
- type DownloadInstanceInfoExport
- func (*DownloadInstanceInfoExport) Descriptor() ([]byte, []int)
- func (m *DownloadInstanceInfoExport) GetBlockSize() int64
- func (m *DownloadInstanceInfoExport) GetGenBegin() int64
- func (m *DownloadInstanceInfoExport) GetInstanceInfo() (eii *DownloadInstanceInfo)
- func (m *DownloadInstanceInfoExport) GetRangeGenMode() RangeGenMode
- func (m *DownloadInstanceInfoExport) GetRanges() []*Range
- func (m *DownloadInstanceInfoExport) GetTotalSize() int64
- func (*DownloadInstanceInfoExport) ProtoMessage()
- func (m *DownloadInstanceInfoExport) Reset()
- func (m *DownloadInstanceInfoExport) SetInstanceInfo(eii *DownloadInstanceInfo)
- func (m *DownloadInstanceInfoExport) String() string
- func (m *DownloadInstanceInfoExport) XXX_DiscardUnknown()
- func (m *DownloadInstanceInfoExport) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *DownloadInstanceInfoExport) XXX_Merge(src proto.Message)
- func (m *DownloadInstanceInfoExport) XXX_Size() int
- func (m *DownloadInstanceInfoExport) XXX_Unmarshal(b []byte) error
- type DownloadInstanceInfoExporter
- type DownloadStatus
- func (ds *DownloadStatus) AddDownloaded(d int64)
- func (ds *DownloadStatus) AddSpeedsDownloaded(d int64)
- func (ds *DownloadStatus) AddTotalSize(size int64)
- func (ds *DownloadStatus) ClearMaxSpeeds()
- func (ds *DownloadStatus) Downloaded() int64
- func (ds *DownloadStatus) MaxSpeeds() int64
- func (ds *DownloadStatus) RangeListGen() *RangeListGen
- func (ds *DownloadStatus) SetMaxSpeeds(speeds int64)
- func (ds *DownloadStatus) SetRangeListGen(gen *RangeListGen)
- func (ds *DownloadStatus) SetRateLimit(rl *speeds.RateLimit)
- func (ds *DownloadStatus) SetTotalSize(size int64)
- func (ds *DownloadStatus) SpeedsPerSecond() int64
- func (ds *DownloadStatus) TimeElapsed() (elapsed time.Duration)
- func (ds *DownloadStatus) TimeLeft() (left time.Duration)
- func (ds *DownloadStatus) TotalSize() int64
- func (ds *DownloadStatus) UpdateSpeeds()
- type DownloadStatuser
- type Range
- func (r *Range) AddBegin(i int64) (newi int64)
- func (*Range) Descriptor() ([]byte, []int)
- func (m *Range) GetBegin() int64
- func (m *Range) GetEnd() int64
- func (r *Range) Len() int64
- func (r *Range) LoadBegin() int64
- func (r *Range) LoadEnd() int64
- func (*Range) ProtoMessage()
- func (m *Range) Reset()
- func (r *Range) ShowDetails() string
- func (r *Range) StoreBegin(end int64)
- func (r *Range) StoreEnd(end int64)
- func (m *Range) String() string
- func (m *Range) XXX_DiscardUnknown()
- func (m *Range) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Range) XXX_Merge(src proto.Message)
- func (m *Range) XXX_Size() int
- func (m *Range) XXX_Unmarshal(b []byte) error
- type RangeGenMode
- type RangeList
- type RangeListGen
- func (gen *RangeListGen) GenRange() (index int, r *Range)
- func (gen *RangeListGen) IsDone() bool
- func (gen *RangeListGen) LoadBegin() (begin int64)
- func (gen *RangeListGen) LoadBlockSize() (blockSize int64)
- func (gen *RangeListGen) RangeCount() (rangeCount int)
- func (gen *RangeListGen) RangeGenMode() RangeGenMode
Constants ¶
const ( // DefaultBlockSize 默认的BlockSize DefaultBlockSize = 256 * converter.KB )
Variables ¶
var ( // ErrUnknownRangeGenMode RangeGenMode 非法 ErrUnknownRangeGenMode = errors.New("Unknown RangeGenMode") )
var RangeGenMode_name = map[int32]string{
0: "Default",
1: "BlockSize",
}
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) 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) 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) Descriptor ¶
func (*Range) ProtoMessage ¶
func (*Range) ProtoMessage()
func (*Range) XXX_DiscardUnknown ¶
func (m *Range) XXX_DiscardUnknown()
func (*Range) XXX_Marshal ¶
func (*Range) XXX_Unmarshal ¶
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 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) 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生成方式