Documentation ¶
Index ¶
- Variables
- func StopBrowsersMiddleware(h http.Handler) http.Handler
- type ApiError
- type 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
- type Proxy
- type 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 (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, ...)
- func (c *ToxicCollection) UpdateToxicJson(name string, data io.Reader) (*toxics.ToxicWrapper, error)
- type ToxicLink
Constants ¶
This section is empty.
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"
Functions ¶
Types ¶
type ApiServer ¶
type ApiServer struct {
Collection *ProxyCollection
}
func (*ApiServer) Populate ¶
func (server *ApiServer) Populate(response http.ResponseWriter, request *http.Request)
func (*ApiServer) PopulateConfig ¶
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)
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 ¶
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 }
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
func (*Proxy) RemoveConnection ¶
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.
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) 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).
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 (*ToxicCollection) RemoveLink ¶
func (c *ToxicCollection) RemoveLink(name string)
func (*ToxicCollection) RemoveToxic ¶
func (c *ToxicCollection) RemoveToxic(name string) error
func (*ToxicCollection) ResetToxics ¶
func (c *ToxicCollection) ResetToxics()
func (*ToxicCollection) StartLink ¶
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)
type ToxicLink ¶
type ToxicLink struct {
// contains filtered or unexported fields
}
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
func NewToxicLink ¶
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) UpdateToxic ¶
func (link *ToxicLink) UpdateToxic(toxic *toxics.ToxicWrapper)
Update an existing toxic in the chain.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package Toxiproxy provides a client wrapper around the Toxiproxy HTTP API for testing the resiliency of Go applications.
|
Package Toxiproxy provides a client wrapper around the Toxiproxy HTTP API for testing the resiliency of Go applications. |