stream - ActiveState ActiveGo 1.8
...

Package stream

import "github.com/Shopify/toxiproxy/stream"
Overview
Index

Overview ▾

Variables

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

type ChanReader

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

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

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

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

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

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

Stores a slice of bytes with its receive timestmap

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