toxiproxy - ActiveState ActiveGo 1.8
...

Package toxiproxy

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

Overview ▾

Index ▾

Variables
type ApiError
    func (e *ApiError) Error() string
type ApiServer
    func NewServer() *ApiServer
    func (server *ApiServer) Listen(host string, port string)
    func (server *ApiServer) Populate(response http.ResponseWriter, request *http.Request)
    func (server *ApiServer) PopulateConfig(filename string)
    func (server *ApiServer) ProxyCreate(response http.ResponseWriter, request *http.Request)
    func (server *ApiServer) ProxyDelete(response http.ResponseWriter, request *http.Request)
    func (server *ApiServer) ProxyIndex(response http.ResponseWriter, request *http.Request)
    func (server *ApiServer) ProxyShow(response http.ResponseWriter, request *http.Request)
    func (server *ApiServer) ProxyUpdate(response http.ResponseWriter, request *http.Request)
    func (server *ApiServer) ResetState(response http.ResponseWriter, request *http.Request)
    func (server *ApiServer) ToxicCreate(response http.ResponseWriter, request *http.Request)
    func (server *ApiServer) ToxicDelete(response http.ResponseWriter, request *http.Request)
    func (server *ApiServer) ToxicIndex(response http.ResponseWriter, request *http.Request)
    func (server *ApiServer) ToxicShow(response http.ResponseWriter, request *http.Request)
    func (server *ApiServer) ToxicUpdate(response http.ResponseWriter, request *http.Request)
    func (server *ApiServer) Version(response http.ResponseWriter, request *http.Request)
type ConnectionList
    func (c *ConnectionList) Lock()
    func (c *ConnectionList) Unlock()
type Proxy
    func NewProxy() *Proxy
    func (proxy *Proxy) RemoveConnection(name string)
    func (proxy *Proxy) Start() error
    func (proxy *Proxy) Stop()
    func (proxy *Proxy) Update(input *Proxy) error
type ProxyCollection
    func NewProxyCollection() *ProxyCollection
    func (collection *ProxyCollection) Add(proxy *Proxy, start bool) error
    func (collection *ProxyCollection) AddOrReplace(proxy *Proxy, start bool) error
    func (collection *ProxyCollection) Clear() error
    func (collection *ProxyCollection) Get(name string) (*Proxy, error)
    func (collection *ProxyCollection) PopulateJson(data io.Reader) ([]*Proxy, error)
    func (collection *ProxyCollection) Proxies() map[string]*Proxy
    func (collection *ProxyCollection) Remove(name string) error
type ToxicCollection
    func NewToxicCollection(proxy *Proxy) *ToxicCollection
    func (c *ToxicCollection) AddToxicJson(data io.Reader) (*toxics.ToxicWrapper, error)
    func (c *ToxicCollection) GetToxic(name string) *toxics.ToxicWrapper
    func (c *ToxicCollection) GetToxicArray() []toxics.Toxic
    func (c *ToxicCollection) RemoveLink(name string)
    func (c *ToxicCollection) RemoveToxic(name string) error
    func (c *ToxicCollection) ResetToxics()
    func (c *ToxicCollection) StartLink(name string, input io.Reader, output io.WriteCloser, direction stream.Direction)
    func (c *ToxicCollection) UpdateToxicJson(name string, data io.Reader) (*toxics.ToxicWrapper, error)
type ToxicLink
    func NewToxicLink(proxy *Proxy, collection *ToxicCollection, direction stream.Direction) *ToxicLink
    func (link *ToxicLink) AddToxic(toxic *toxics.ToxicWrapper)
    func (link *ToxicLink) RemoveToxic(toxic *toxics.ToxicWrapper)
    func (link *ToxicLink) Start(name string, source io.Reader, dest io.WriteCloser)
    func (link *ToxicLink) UpdateToxic(toxic *toxics.ToxicWrapper)

Package files

api.go link.go proxy.go proxy_collection.go toxic_collection.go version.go

Variables

var (
    ErrBadRequestBody     = newError("bad request body", http.StatusBadRequest)
    ErrMissingField       = newError("missing required field", http.StatusBadRequest)
    ErrProxyNotFound      = newError("proxy not found", http.StatusNotFound)
    ErrProxyAlreadyExists = newError("proxy already exists", http.StatusConflict)
    ErrInvalidStream      = newError("stream was invalid, can be either upstream or downstream", http.StatusBadRequest)
    ErrInvalidToxicType   = newError("invalid toxic type", http.StatusBadRequest)
    ErrToxicAlreadyExists = newError("toxic already exists", http.StatusConflict)
    ErrToxicNotFound      = newError("toxic not found", http.StatusNotFound)
)
var ErrProxyAlreadyStarted = errors.New("Proxy already started")
var Version = "git"

type ApiError

type ApiError struct {
    Message    string `json:"error"`
    StatusCode int    `json:"status"`
}

func (*ApiError) Error

func (e *ApiError) Error() string

type ApiServer

type ApiServer struct {
    Collection *ProxyCollection
}

func NewServer

func NewServer() *ApiServer

func (*ApiServer) Listen

func (server *ApiServer) Listen(host string, port string)

func (*ApiServer) Populate

func (server *ApiServer) Populate(response http.ResponseWriter, request *http.Request)

func (*ApiServer) PopulateConfig

func (server *ApiServer) PopulateConfig(filename string)

func (*ApiServer) ProxyCreate

func (server *ApiServer) ProxyCreate(response http.ResponseWriter, request *http.Request)

func (*ApiServer) ProxyDelete

func (server *ApiServer) ProxyDelete(response http.ResponseWriter, request *http.Request)

func (*ApiServer) ProxyIndex

func (server *ApiServer) ProxyIndex(response http.ResponseWriter, request *http.Request)

func (*ApiServer) ProxyShow

func (server *ApiServer) ProxyShow(response http.ResponseWriter, request *http.Request)

func (*ApiServer) ProxyUpdate

func (server *ApiServer) ProxyUpdate(response http.ResponseWriter, request *http.Request)

func (*ApiServer) ResetState

func (server *ApiServer) ResetState(response http.ResponseWriter, request *http.Request)

func (*ApiServer) ToxicCreate

func (server *ApiServer) ToxicCreate(response http.ResponseWriter, request *http.Request)

func (*ApiServer) ToxicDelete

func (server *ApiServer) ToxicDelete(response http.ResponseWriter, request *http.Request)

func (*ApiServer) ToxicIndex

func (server *ApiServer) ToxicIndex(response http.ResponseWriter, request *http.Request)

func (*ApiServer) ToxicShow

func (server *ApiServer) ToxicShow(response http.ResponseWriter, request *http.Request)

func (*ApiServer) ToxicUpdate

func (server *ApiServer) ToxicUpdate(response http.ResponseWriter, request *http.Request)

func (*ApiServer) Version

func (server *ApiServer) Version(response http.ResponseWriter, request *http.Request)

type ConnectionList

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

func (*ConnectionList) Lock

func (c *ConnectionList) Lock()

func (*ConnectionList) Unlock

func (c *ConnectionList) Unlock()

type Proxy

Proxy represents the proxy in its entirity with all its links. The main responsibility of Proxy is to accept new client and create Links between the client and upstream.

Client <-> toxiproxy <-> Upstream

type Proxy struct {
    sync.Mutex

    Name     string `json:"name"`
    Listen   string `json:"listen"`
    Upstream string `json:"upstream"`
    Enabled  bool   `json:"enabled"`

    Toxics *ToxicCollection `json:"-"`
    // contains filtered or unexported fields
}

func NewProxy

func NewProxy() *Proxy

func (*Proxy) RemoveConnection

func (proxy *Proxy) RemoveConnection(name string)

func (*Proxy) Start

func (proxy *Proxy) Start() error

func (*Proxy) Stop

func (proxy *Proxy) Stop()

func (*Proxy) Update

func (proxy *Proxy) Update(input *Proxy) error

type ProxyCollection

ProxyCollection is a collection of proxies. It's the interface for anything to add and remove proxies from the toxiproxy instance. It's responsibilty is to maintain the integrity of the proxy set, by guarding for things such as duplicate names.

type ProxyCollection struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

func NewProxyCollection

func NewProxyCollection() *ProxyCollection

func (*ProxyCollection) Add

func (collection *ProxyCollection) Add(proxy *Proxy, start bool) error

func (*ProxyCollection) AddOrReplace

func (collection *ProxyCollection) AddOrReplace(proxy *Proxy, start bool) error

func (*ProxyCollection) Clear

func (collection *ProxyCollection) Clear() error

func (*ProxyCollection) Get

func (collection *ProxyCollection) Get(name string) (*Proxy, error)

func (*ProxyCollection) PopulateJson

func (collection *ProxyCollection) PopulateJson(data io.Reader) ([]*Proxy, error)

func (*ProxyCollection) Proxies

func (collection *ProxyCollection) Proxies() map[string]*Proxy

func (*ProxyCollection) Remove

func (collection *ProxyCollection) Remove(name string) error

type ToxicCollection

ToxicCollection contains a list of toxics that are chained together. Each proxy has its own collection. A hidden noop toxic is always maintained at the beginning of each chain so toxics have a method of pausing incoming data (by interrupting the preceding toxic).

type ToxicCollection struct {
    sync.Mutex
    // contains filtered or unexported fields
}

func NewToxicCollection

func NewToxicCollection(proxy *Proxy) *ToxicCollection

func (*ToxicCollection) AddToxicJson

func (c *ToxicCollection) AddToxicJson(data io.Reader) (*toxics.ToxicWrapper, error)

func (*ToxicCollection) GetToxic

func (c *ToxicCollection) GetToxic(name string) *toxics.ToxicWrapper

func (*ToxicCollection) GetToxicArray

func (c *ToxicCollection) GetToxicArray() []toxics.Toxic
func (c *ToxicCollection) RemoveLink(name string)

func (*ToxicCollection) RemoveToxic

func (c *ToxicCollection) RemoveToxic(name string) error

func (*ToxicCollection) ResetToxics

func (c *ToxicCollection) ResetToxics()
func (c *ToxicCollection) StartLink(name string, input io.Reader, output io.WriteCloser, direction stream.Direction)

func (*ToxicCollection) UpdateToxicJson

func (c *ToxicCollection) UpdateToxicJson(name string, data io.Reader) (*toxics.ToxicWrapper, error)

ToxicLinks are single direction pipelines that connects an input and output via a chain of toxics. The chain always starts with a NoopToxic, and toxics are added and removed as they are enabled/disabled. New toxics are always added to the end of the chain.

NoopToxic  LatencyToxic
    v           v

Input > ToxicStub > ToxicStub > Output

type ToxicLink struct {
    // contains filtered or unexported fields
}
func NewToxicLink(proxy *Proxy, collection *ToxicCollection, direction stream.Direction) *ToxicLink

func (*ToxicLink) AddToxic

func (link *ToxicLink) AddToxic(toxic *toxics.ToxicWrapper)

Add a toxic to the end of the chain.

func (*ToxicLink) RemoveToxic

func (link *ToxicLink) RemoveToxic(toxic *toxics.ToxicWrapper)

Remove an existing toxic from the chain.

func (*ToxicLink) Start

func (link *ToxicLink) Start(name string, source io.Reader, dest io.WriteCloser)

Start the link with the specified toxics

func (*ToxicLink) UpdateToxic

func (link *ToxicLink) UpdateToxic(toxic *toxics.ToxicWrapper)

Update an existing toxic in the chain.

Subdirectories

Name Synopsis
..
cli
client Package Toxiproxy provides a client wrapper around the Toxiproxy HTTP API for testing the resiliency of Go applications.
cmd
stream
testhelper
testing
toxics