Documentation ¶
Overview ¶
Package Toxiproxy provides a client wrapper around the Toxiproxy HTTP API for testing the resiliency of Go applications.
For use with Toxiproxy 2.x ¶
Package Toxiproxy provides a client wrapper around the Toxiproxy HTTP API for testing the resiliency of Go applications.
For use with Toxiproxy 2.x ¶
Package Toxiproxy provides a client wrapper around the Toxiproxy HTTP API for testing the resiliency of Go applications.
For use with Toxiproxy 2.x
Index ¶
- type ApiError
- type Attributes
- type Client
- func (client *Client) AddToxic(options *ToxicOptions) (*Toxic, error)
- func (client *Client) CreateProxy(name, listen, upstream string) (*Proxy, error)
- func (client *Client) NewProxy() *Proxy
- func (client *Client) Populate(config []Proxy) ([]*Proxy, error)
- func (client *Client) Proxies() (map[string]*Proxy, error)
- func (client *Client) Proxy(name string) (*Proxy, error)
- func (client *Client) RemoveToxic(options *ToxicOptions) error
- func (client *Client) ResetState() error
- func (client *Client) UpdateToxic(options *ToxicOptions) (*Toxic, error)
- func (client *Client) Version() ([]byte, error)
- type Proxy
- func (proxy *Proxy) AddToxic(name, typeName, stream string, toxicity float32, attrs Attributes) (*Toxic, error)
- func (proxy *Proxy) Delete() error
- func (proxy *Proxy) Disable() error
- func (proxy *Proxy) Enable() error
- func (proxy *Proxy) RemoveToxic(name string) error
- func (proxy *Proxy) Save() error
- func (proxy *Proxy) Toxics() (Toxics, error)
- func (proxy *Proxy) UpdateToxic(name string, toxicity float32, attrs Attributes) (*Toxic, error)
- type Toxic
- type ToxicOptions
- type Toxics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attributes ¶
type Attributes map[string]interface{}
type Client ¶
type Client struct { UserAgent string // contains filtered or unexported fields }
Client holds information about where to connect to Toxiproxy.
func NewClient ¶
NewClient creates a new client which provides the base of all communication with Toxiproxy. Endpoint is the address to the proxy (e.g. localhost:8474 if not overridden).
func (*Client) AddToxic ¶
func (client *Client) AddToxic(options *ToxicOptions) (*Toxic, error)
AddToxic creates a toxic to proxy.
func (*Client) CreateProxy ¶
CreateProxy instantiates a new proxy and starts listening on the specified address. This is an alias for `NewProxy()` + `proxy.Save()`.
func (*Client) NewProxy ¶
Generates a new uncommitted proxy instance. In order to use the result, the proxy fields will need to be set and have `Save()` called.
func (*Client) Populate ¶
Create a list of proxies using a configuration list. If a proxy already exists, it will be replaced with the specified configuration. For large amounts of proxies, `config` can be loaded from a file. Returns a list of the successfully created proxies.
func (*Client) RemoveToxic ¶
func (client *Client) RemoveToxic(options *ToxicOptions) error
RemoveToxic removes toxic from proxy.
func (*Client) ResetState ¶
ResetState resets the state of all proxies and toxics in Toxiproxy.
func (*Client) UpdateToxic ¶
func (client *Client) UpdateToxic(options *ToxicOptions) (*Toxic, error)
UpdateToxic update a toxic in proxy.
type Proxy ¶
type Proxy struct { Name string `json:"name"` // The name of the proxy Listen string `json:"listen"` // The address the proxy listens on Upstream string `json:"upstream"` // The upstream address to proxy to Enabled bool `json:"enabled"` // Whether the proxy is enabled // The toxics active on this proxy. Note: you cannot set this // when passing Proxy into Populate() ActiveToxics Toxics `json:"toxics"` // contains filtered or unexported fields }
func (*Proxy) AddToxic ¶
func (proxy *Proxy) AddToxic( name, typeName, stream string, toxicity float32, attrs Attributes, ) (*Toxic, error)
AddToxic adds a toxic to the given stream direction. If a name is not specified, it will default to <type>_<stream>. If a stream is not specified, it will default to downstream. See https://github.com/Shopify/toxiproxy#toxics for a list of all Toxic types.
func (*Proxy) Delete ¶
Delete a proxy complete and close all existing connections through it. All information about the proxy such as listen port and active toxics will be deleted as well. If you just wish to stop and later enable a proxy, use `Enable()` and `Disable()`.
func (*Proxy) Disable ¶
Disable a proxy so that no connections can pass through. This will drop all active connections.
func (*Proxy) RemoveToxic ¶
RemoveToxic renives the toxic with the given name.
func (*Proxy) UpdateToxic ¶
UpdateToxic sets the parameters for an existing toxic with the given name. If toxicity is set to -1, the current value will be used.
type Toxic ¶
type Toxic struct { Name string `json:"name"` Type string `json:"type"` Stream string `json:"stream,omitempty"` Toxicity float32 `json:"toxicity"` Attributes Attributes `json:"attributes"` }
type ToxicOptions ¶
type ToxicOptions struct { ProxyName, ToxicName, ToxicType, Stream string Toxicity float32 Attributes Attributes }