toxiproxy

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2015 License: MIT Imports: 4 Imported by: 0

README

toxiproxy-go

This is the Go client library for the Toxiproxy API. Please read the usage section in the Toxiproxy README before attempting to use the client.

For Usage please see the Godoc documentation for the package.

Documentation

Overview

Package Toxiproxy provides a client wrapper around the Toxiproxy HTTP API for testing the resiliency of Go applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiError added in v1.2.0

type ApiError struct {
	Title  string `json:"title"`
	Status int    `json:"status"`
}

func (*ApiError) Error added in v1.2.0

func (err *ApiError) Error() string

type Client

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

Client holds information about where to connect to Toxiproxy.

func NewClient

func NewClient(endpoint string) *Client

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 overriden)

func (*Client) NewProxy

func (client *Client) NewProxy(proxy *Proxy) *Proxy

NewProxy instantiates a new proxy instance. Note Create() must be called on it to create it. The Enabled field must be set to true, otherwise the Proxy will not be enabled when created.

func (*Client) Proxies

func (client *Client) Proxies() (map[string]*Proxy, error)

Proxies returns a map with all the proxies and their toxics.

func (*Client) Proxy

func (client *Client) Proxy(name string) (*Proxy, error)

Proxy returns a proxy by name.

func (*Client) ResetState

func (client *Client) ResetState() error

ResetState resets the state of all proxies and toxics in Toxiproxy.

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

	ToxicsUpstream   Toxics `json:"upstream_toxics"`   // Toxics in the upstream direction
	ToxicsDownstream Toxics `json:"downstream_toxics"` // Toxics in the downstream direction
	// contains filtered or unexported fields
}

Proxy represents a Proxy.

func (*Proxy) Create

func (proxy *Proxy) Create() error

Create creates a new proxy.

func (*Proxy) Delete

func (proxy *Proxy) Delete() error

Delete a proxy which will cause it to stop listening and delete all information associated with it. If you just wish to stop and later enable a proxy, set the `Enabled` field to `false` and call `Save()`.

func (*Proxy) Save

func (proxy *Proxy) Save() error

Save saves changes to a proxy such as its enabled status.

func (*Proxy) SetToxic added in v1.0.2

func (proxy *Proxy) SetToxic(name string, direction string, toxic Toxic) (Toxic, error)

SetToxic sets the parameters for a toxic with a given name in the direction. See https://github.com/Shopify/toxiproxy#toxics for a list of all Toxics.

func (*Proxy) Toxics

func (proxy *Proxy) Toxics(direction string) (Toxics, error)

Toxics returns a map of all the toxics and their attributes for a direction.

type Toxic added in v1.2.0

type Toxic map[string]interface{}

type Toxics added in v1.2.0

type Toxics map[string]Toxic

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL