Documentation
¶
Overview ¶
Package chunker provides a way to chunk an input into uploadable-size byte slices.
Index ¶
Constants ¶
const DefaultChunkSize = 1024 * 1024
DefaultChunkSize is the default chunk size for ByteStream.Write RPCs.
Variables ¶
var ErrEOF = errors.New("ErrEOF")
ErrEOF is returned when Next is called when HasNext is false.
var IOBufferSize = 10 * 1024 * 1024
IOBufferSize regulates how many bytes at a time the Chunker will read from a file source.
Functions ¶
This section is empty.
Types ¶
type Chunker ¶
type Chunker struct {
// contains filtered or unexported fields
}
Chunker can be used to chunk an input into uploadable-size byte slices. A single Chunker is NOT thread-safe; it should be used by a single uploader thread.
func New ¶
New creates a new chunker from an uploadinfo.Entry. If compressed, the data will of the Entry will be compressed on the fly.
func (*Chunker) FullData ¶
FullData returns the overall (non-chunked) underlying data. The Chunker is Reset. It is supposed to be used for batch uploading small inputs.
func (*Chunker) HasNext ¶
HasNext returns whether a subsequent call to Next will return a valid chunk. Always true for a newly created Chunker.
func (*Chunker) Next ¶
Next returns the next chunk of data or error. ErrEOF is returned if and only if HasNext is false. Chunk.Data will be empty if and only if the full underlying data is empty (in which case it will be the only chunk returned). Chunk.Digest will only be filled for the first chunk.