chunking

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunker

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

Chunker is a reader that reads from an underlying io.Reader and returns LoadChunkRequests of a given size.

func NewChunker

func NewChunker(r io.Reader, chunkSize int64) *Chunker

NewChunker returns a new Chunker that reads from r and returns LoadChunkRequests of size chunkSize.

func (*Chunker) Abort

func (c *Chunker) Abort() *proto.LoadChunkRequest

Abort returns a LoadChunkRequest that signals the receiver to abort the given stream.

func (*Chunker) Counts

func (c *Chunker) Counts() (int64, int64, int64)

Counts returns the number of chunks generated, bytes read, and bytes written.

func (*Chunker) Next

func (c *Chunker) Next() (*proto.LoadChunkRequest, error)

Next returns the next LoadChunkRequest, or io.EOF if finished.

type Dechunker

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

Dechunker is a writer that writes chunks to a file and returns the file path when the last chunk is received and the Dechunker is closed.

func NewDechunker

func NewDechunker(dir string) (*Dechunker, error)

NewDechunker returns a new Dechunker that writes chunks to a file in dir.

func (*Dechunker) Close

func (d *Dechunker) Close() (string, error)

Close closes the Dechunker and returns the file path containing the reassembled data.

func (*Dechunker) WriteChunk

func (d *Dechunker) WriteChunk(chunk *proto.LoadChunkRequest) (bool, error)

WriteChunk writes the chunk to the file. If the chunk is the last chunk, the the bool return value is true.

type DechunkerManager

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

DechunkerManager manages Dechunkers.

func NewDechunkerManager

func NewDechunkerManager(dir string) (*DechunkerManager, error)

NewDechunkerManager returns a new DechunkerManager.

func (*DechunkerManager) Close

func (d *DechunkerManager) Close()

Closes closes the DechunkerManager and all Dechunkers it manages.

func (*DechunkerManager) Delete

func (d *DechunkerManager) Delete(id string)

Delete deletes the Dechunker for the given stream ID.

func (*DechunkerManager) Get

func (d *DechunkerManager) Get(id string) (*Dechunker, error)

Get returns the Dechunker for the given stream ID. If the Dechunker does not exist, it is created.

Jump to

Keyboard shortcuts

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