toxiproxy-haskell-0.2.0.0: Client library for Toxiproxy: a TCP failure testing proxy.

Safe HaskellNone
LanguageHaskell2010

Toxiproxy

Synopsis

Documentation

getProxy :: ProxyName -> ClientM Proxy Source #

updateProxy :: ProxyName -> Proxy -> ClientM Proxy Source #

getToxics :: ProxyName -> ClientM [Toxic] Source #

createToxic :: ProxyName -> Toxic -> ClientM Toxic Source #

getToxic :: ProxyName -> ToxicName -> ClientM Toxic Source #

updateToxic :: ProxyName -> ToxicName -> Toxic -> ClientM Toxic Source #

deleteToxic :: ProxyName -> ToxicName -> ClientM NoContent Source #

data Proxy Source #

A Toxiproxy proxy. It forwards TCP connections between a listen and upstream host. Toxics can be injected into the proxy to simulate network failure.

Constructors

Proxy 

Fields

  • proxyName :: ProxyName

    A unique human readable name to identify a proxy.

  • proxyListen :: Host

    The proxy listens on this host:port.

  • proxyUpstream :: Host

    The proxy forwards to this upstream host:port.

  • proxyEnabled :: Bool

    Whether a proxy is currently listening / accepting connections.

  • proxyToxics :: [Toxic]

    The toxics currently applied to the proxy. These should not be specified when initially creating a proxy. They must be created seperately with createToxic or withToxic.

Instances

data Toxic Source #

A toxic is applied to a proxy. It allows the user to simulate a specified kind of network failure on the proxy.

Constructors

Toxic 

Fields

  • toxicName :: ToxicName

    A unique human readable name to identify a toxic.

  • toxicType :: ToxicType

    The type of toxic. For example "latency". Please refer to ToxicType or the Toxiproxy documentation for more information.

  • toxicStream :: Stream

    The direction on which the toxic is applied. Please refer to Stream.

  • toxicToxicity :: Float

    The strength that the toxic is applied to the proxy. Please refer to the Toxiproxy documation.

  • toxicAttributes :: Map Text Int

    Attributes configure a toxic. They differ based on the ToxicType. Please refer to the Toxiproxy documentation.

Instances

newtype Populate Source #

The return value of the populate endpoint.

Constructors

Populate 

Fields

Instances

Eq Populate Source # 
Show Populate Source # 
Generic Populate Source # 

Associated Types

type Rep Populate :: * -> * #

Methods

from :: Populate -> Rep Populate x #

to :: Rep Populate x -> Populate #

FromJSON Populate Source # 
type Rep Populate Source # 
type Rep Populate = D1 * (MetaData "Populate" "Toxiproxy" "toxiproxy-haskell-0.2.0.0-KB02vNhAQYNEaa7PaChM47" True) (C1 * (MetaCons "Populate" PrefixI True) (S1 * (MetaSel (Just Symbol "populateProxies") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * [Proxy])))

newtype Version Source #

The version of the Toxiproxy server. This library is fully supported by any version greater or equal to 2.1.3.

Constructors

Version Text 

data Stream Source #

A toxic can be applied to the upstream or the downstream of a connection. Upstream is the stream traveling from the connecting client to the upstream server. Downstream is the stream traveling from the upstream server to the connecting client.

Constructors

Upstream 
Downstream 

data ToxicType Source #

Different toxic types simulate different kinds of failure. Different toxics require different attribute configuration. Please refer to the Toxiproxy documentation.

toxiproxyUrl :: BaseUrl Source #

The default Toxiproxy service URL. (127.0.0.1:8474)

withDisabled :: Proxy -> IO a -> IO a Source #

Given an enabled proxy, disable the proxy, run the given action and then re-enable the proxy.

This is useful for simulating a crashed server or closed connection.

connectToMyProxy       -- This will connect.
withDisabled myProxy $
  connectToMyProxy     -- This will get rejected.
connectToMyProxy       -- This will connect again.

withToxic :: Proxy -> Toxic -> IO a -> IO a Source #

Given a proxy and a toxic, create the toxic on the proxy, run the given action and then delete the toxic.

This is useful for running some action with a toxic enabled.

withToxic myProxy latencyToxic $
  sendRequestThroughProxy -- This request will have latency applied to it.

withProxy :: Proxy -> (Proxy -> IO a) -> IO a Source #

Given a proxy record, create the proxy on the server, run the given action and then delete the proxy off the server.

This is useful for wrapping withDisabled and withToxic calls. It enures that your test cleans up the Toxiproxy server so that proxies don't leak into your other tests.

run :: ClientM a -> IO (Either ServantError a) Source #

A helper for easily querying the Toxiproxy API. Assumes Toxiproxy is running on toxiproxyUrl.

proxies <- run getProxies