partial

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultChunkSize = 1024 * 1024 * 10

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunk

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

func NewChunk

func NewChunk(index, start, end int64) *Chunk

func (*Chunk) Data

func (p *Chunk) Data() []byte

func (*Chunk) Error

func (p *Chunk) Error() error

func (*Chunk) SetData

func (p *Chunk) SetData(bytes []byte)

func (*Chunk) SetError

func (p *Chunk) SetError(err error)

type ChunkDownFunc

type ChunkDownFunc func(start, end int64) ([]byte, error)

type ChunksSorter

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

切片乱序写入后,将切片顺序读取

func NewChunksSorter

func NewChunksSorter(chunkCount int64, works int) *ChunksSorter

func (*ChunksSorter) Close

func (p *ChunksSorter) Close(workId int)

关闭 workId 下的通道

func (*ChunksSorter) Read

func (p *ChunksSorter) Read() *Chunk

顺序读取切片,如果下一个切片没有下载完,则会被阻塞

func (*ChunksSorter) Write

func (p *ChunksSorter) Write(chunk *Chunk)

将数据写入到缓存区,如果该缓存已满,则会被阻塞

type MultiPartialDownloader

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

func NewMultiPartialDownloader

func NewMultiPartialDownloader(filePath string, finalSize, chunkSize int64, writer io.Writer, works int, fn ChunkDownFunc) *MultiPartialDownloader

func (*MultiPartialDownloader) Download

func (p *MultiPartialDownloader) Download() error

Jump to

Keyboard shortcuts

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