toxics

package
Version: v2.1.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ToxicRegistry map[string]Toxic

Functions

func Count

func Count() int

func Register

func Register(typeName string, toxic Toxic)

Types

type BandwidthToxic

type BandwidthToxic struct {
	// Rate in KB/s
	Rate int64 `json:"rate"`
}

The BandwidthToxic passes data through at a limited rate

func (*BandwidthToxic) Pipe

func (t *BandwidthToxic) Pipe(stub *ToxicStub)

type BufferedToxic

type BufferedToxic interface {
	// Defines the size of buffer this toxic should use
	GetBufferSize() int
}

type CleanupToxic

type CleanupToxic interface {
	// Cleanup is called before a toxic is removed.
	Cleanup(*ToxicStub)
}

type LatencyToxic

type LatencyToxic struct {
	// Times in milliseconds
	Latency int64 `json:"latency"`
	Jitter  int64 `json:"jitter"`
}

The LatencyToxic passes data through with the a delay of latency +/- jitter added.

func (*LatencyToxic) GetBufferSize

func (t *LatencyToxic) GetBufferSize() int

func (*LatencyToxic) Pipe

func (t *LatencyToxic) Pipe(stub *ToxicStub)

type LimitDataToxic

type LimitDataToxic struct {
	Bytes int64 `json:"bytes"`
}

LimitDataToxic has limit in bytes

func (*LimitDataToxic) NewState

func (t *LimitDataToxic) NewState() interface{}

func (*LimitDataToxic) Pipe

func (t *LimitDataToxic) Pipe(stub *ToxicStub)

type LimitDataToxicState

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

type NoopToxic

type NoopToxic struct{}

The NoopToxic passes all data through without any toxic effects.

func (*NoopToxic) Pipe

func (t *NoopToxic) Pipe(stub *ToxicStub)

type SlicerToxic

type SlicerToxic struct {
	// Average number of bytes to slice at
	AverageSize int `json:"average_size"`
	// +/- bytes to vary sliced amounts. Must be less than
	// the average size
	SizeVariation int `json:"size_variation"`
	// Microseconds to delay each packet. May be useful since there's
	// usually some kind of buffering of network data
	Delay int `json:"delay"`
}

The SlicerToxic slices data into multiple smaller packets to simulate real-world TCP behaviour.

func (*SlicerToxic) Pipe

func (t *SlicerToxic) Pipe(stub *ToxicStub)

type SlowCloseToxic

type SlowCloseToxic struct {
	// Times in milliseconds
	Delay int64 `json:"delay"`
}

The SlowCloseToxic stops the TCP connection from closing until after a delay.

func (*SlowCloseToxic) Pipe

func (t *SlowCloseToxic) Pipe(stub *ToxicStub)

type StatefulToxic

type StatefulToxic interface {
	// Creates a new object to store toxic state in
	NewState() interface{}
}

Stateful toxics store a per-connection state object on the ToxicStub. The state is created once when the toxic is added and persists until the toxic is removed or the connection is closed.

type TimeoutToxic

type TimeoutToxic struct {
	// Times in milliseconds
	Timeout int64 `json:"timeout"`
}

The TimeoutToxic stops any data from flowing through, and will close the connection after a timeout. If the timeout is set to 0, then the connection will not be closed.

func (*TimeoutToxic) Cleanup

func (t *TimeoutToxic) Cleanup(stub *ToxicStub)

func (*TimeoutToxic) Pipe

func (t *TimeoutToxic) Pipe(stub *ToxicStub)

type Toxic

type Toxic interface {
	// Defines how packets flow through a ToxicStub. Pipe() blocks until the link is closed or interrupted.
	Pipe(*ToxicStub)
}

func New

func New(wrapper *ToxicWrapper) Toxic

type ToxicStub

type ToxicStub struct {
	Input     <-chan *stream.StreamChunk
	Output    chan<- *stream.StreamChunk
	State     interface{}
	Interrupt chan struct{}
	// contains filtered or unexported fields
}

func NewToxicStub

func NewToxicStub(input <-chan *stream.StreamChunk, output chan<- *stream.StreamChunk) *ToxicStub

func (*ToxicStub) Close

func (s *ToxicStub) Close()

func (*ToxicStub) Closed

func (s *ToxicStub) Closed() bool

func (*ToxicStub) InterruptToxic

func (s *ToxicStub) InterruptToxic() bool

Interrupt the flow of data so that the toxic controlling the stub can be replaced. Returns true if the stream was successfully interrupted, or false if the stream is closed.

func (*ToxicStub) Run

func (s *ToxicStub) Run(toxic *ToxicWrapper)

Begin running a toxic on this stub, can be interrupted. Runs a noop toxic randomly depending on toxicity

type ToxicWrapper

type ToxicWrapper struct {
	Toxic      `json:"attributes"`
	Name       string           `json:"name"`
	Type       string           `json:"type"`
	Stream     string           `json:"stream"`
	Toxicity   float32          `json:"toxicity"`
	Direction  stream.Direction `json:"-"`
	Index      int              `json:"-"`
	BufferSize int              `json:"-"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL