chunker

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package chunker provides functionalities to create chunks from an io.Reader and also create an io.Reader from chunks.

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 converts data read from reader into chunks.

func New

func New(r io.Reader, chunks chan Data, err chan error, options ...Option) *Chunker

New returns a new chunker for r and it forwards each chunk to chunks channel. an error will be sent to err channel if chunking fails.

func (*Chunker) Close

func (c *Chunker) Close() error

Close will stop reading from reader and no more chunks will be emitted.

type Data

type Data struct {
	// Value carries the context value of data chunk.
	Value interface{}

	// Data is data chunk.
	Data []byte
}

Data represents a data chunk.

type Option

type Option func(*Chunker)

Option is the configuration func of Chunker.

func ChunkSizeOption

func ChunkSizeOption(n int) Option

ChunkSizeOption returns an option to set chunk size.

func ValueOption

func ValueOption(value interface{}) Option

ValueOption returns an option to set context value to chunks.

type Stream

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

Stream implements io.Reader.

func NewStream

func NewStream() *Stream

NewStream returns a new stream.

func (*Stream) Close

func (s *Stream) Close() error

Close closes reader.

func (*Stream) Provide

func (s *Stream) Provide(data []byte)

Provide provides data for Read.

func (*Stream) Read

func (s *Stream) Read(p []byte) (n int, err error)

Read puts data into p.

Jump to

Keyboard shortcuts

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