Documentation
¶
Index ¶
- Variables
- func NewMetricsContainer(registry *prometheus.Registry) *metricsContainer
- type ApiError
- type ApiServer
- func (server *ApiServer) Listen(addr string) error
- 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) Routes() *mux.Router
- func (server *ApiServer) Shutdown() error
- 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(server *ApiServer, 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(ctx context.Context, name string) error
- func (c *ToxicCollection) ResetToxics(ctx context.Context)
- func (c *ToxicCollection) StartLink(server *ApiServer, name string, input io.Reader, output io.WriteCloser, ...)
- func (c *ToxicCollection) UpdateToxicJson(name string, data io.Reader) (*toxics.ToxicWrapper, error)
- type ToxicLink
- func (link *ToxicLink) AddToxic(toxic *toxics.ToxicWrapper)
- func (link *ToxicLink) Direction() string
- func (link *ToxicLink) RemoveToxic(ctx context.Context, toxic *toxics.ToxicWrapper)
- func (link *ToxicLink) Start(server *ApiServer, name string, source io.Reader, dest io.WriteCloser)
- func (link *ToxicLink) UpdateToxic(toxic *toxics.ToxicWrapper)
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 ¶
func NewMetricsContainer ¶ added in v2.4.0
func NewMetricsContainer(registry *prometheus.Registry) *metricsContainer
NewMetricsContainer initializes a container for storing all prometheus metrics.
Types ¶
type ApiServer ¶
type ApiServer struct { Collection *ProxyCollection Metrics *metricsContainer Logger *zerolog.Logger // contains filtered or unexported fields }
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:"-"` Logger *zerolog.Logger // contains filtered or unexported fields }
Proxy represents the proxy in its entirety 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 responsibility 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 (*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(ctx context.Context, name string) error
func (*ToxicCollection) ResetToxics ¶
func (c *ToxicCollection) ResetToxics(ctx context.Context)
func (*ToxicCollection) StartLink ¶
func (c *ToxicCollection) StartLink( server *ApiServer, 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 ¶
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 (*ToxicLink) AddToxic ¶
func (link *ToxicLink) AddToxic(toxic *toxics.ToxicWrapper)
Add a toxic to the end of the chain.
func (*ToxicLink) Direction ¶ added in v2.4.0
Direction returns the direction of the link (upstream or downstream).
func (*ToxicLink) RemoveToxic ¶
func (link *ToxicLink) RemoveToxic(ctx context.Context, toxic *toxics.ToxicWrapper)
Remove an existing toxic from the chain.
func (*ToxicLink) Start ¶
func (link *ToxicLink) Start( server *ApiServer, 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.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
_examples
|
|
toxics
Ported from https://github.com/xthexder/toxic-example/blob/master/http.go
|
Ported from https://github.com/xthexder/toxic-example/blob/master/http.go |
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. |
cmd
|
|
test
|
|