Documentation ¶
Index ¶
- Variables
- func Count() int
- func Register(typeName string, toxic Toxic)
- type BandwidthToxic
- type BufferedToxic
- type CleanupToxic
- type LatencyToxic
- type LimitDataToxic
- type LimitDataToxicState
- type NoopToxic
- type SlicerToxic
- type SlowCloseToxic
- type StatefulToxic
- type TimeoutToxic
- type Toxic
- type ToxicStub
- type ToxicWrapper
Constants ¶
This section is empty.
Variables ¶
var ToxicRegistry map[string]Toxic
Functions ¶
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.
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) InterruptToxic ¶
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