stream

package
v2.1.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2019 License: MIT Imports: 3 Imported by: 28

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInterrupted = fmt.Errorf("read interrupted by channel")

Functions

This section is empty.

Types

type ChanReader

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

Implements the io.Reader interface for a chan []byte

func NewChanReader

func NewChanReader(input <-chan *StreamChunk) *ChanReader

func (*ChanReader) Read

func (c *ChanReader) Read(out []byte) (int, error)

Read from the channel into `out`. This will block until data is available, and can be interrupted with a channel using `SetInterrupt()`. If the read was interrupted, `ErrInterrupted` will be returned.

func (*ChanReader) SetInterrupt

func (c *ChanReader) SetInterrupt(interrupt <-chan struct{})

Specify a channel that can interrupt a read if it is blocking.

type ChanWriter

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

Implements the io.WriteCloser interface for a chan []byte

func NewChanWriter

func NewChanWriter(output chan<- *StreamChunk) *ChanWriter

func (*ChanWriter) Close

func (c *ChanWriter) Close() error

Close the output channel

func (*ChanWriter) Write

func (c *ChanWriter) Write(buf []byte) (int, error)

Write `buf` as a StreamChunk to the channel. The full buffer is always written, and error will always be nil. Calling `Write()` after closing the channel will panic.

type Direction

type Direction uint8
const (
	Upstream Direction = iota
	Downstream
	NumDirections
)

type StreamChunk

type StreamChunk struct {
	Data      []byte
	Timestamp time.Time
}

Stores a slice of bytes with its receive timestmap

Jump to

Keyboard shortcuts

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