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

Safe HaskellNone




getVersion :: ClientM Version Source #

Returns the server version number.

postReset :: ClientM NoContent Source #

Enable all proxies and remove all active toxics.

getProxies :: ClientM (Map ProxyName Proxy) Source #

List existing proxies and their toxics.

createProxy :: Proxy -> ClientM Proxy Source #

Create a new proxy.

getProxy :: ProxyName -> ClientM Proxy Source #

Get a proxy with all its active toxics.

postPopulate :: [Proxy] -> ClientM Populate Source #

Create or replace a list of proxies.

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

Update a proxy's fields.

deleteProxy :: ProxyName -> ClientM NoContent Source #

Delete an existing proxy.

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

List active toxics.

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

Create a new toxic.

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

Get an active toxic's fields.

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

Update an active toxic.

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

Remove an active toxic.

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.




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.




newtype Populate Source #

The return value of the populate endpoint.





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

Associated Types

type Rep Populate :: * -> * #


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-" 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.


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.



data ToxicType Source #

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

newtype ProxyName Source #

A unique string for identifying a proxy on the server.


ProxyName Text 


Eq ProxyName Source # 
Ord ProxyName Source # 
Show ProxyName Source # 
IsString ProxyName Source # 
Generic ProxyName Source # 

Associated Types

type Rep ProxyName :: * -> * #

ToJSON ProxyName Source # 
FromJSON ProxyName Source # 
FromJSONKey ProxyName Source # 
ToHttpApiData ProxyName Source # 
type Rep ProxyName Source # 
type Rep ProxyName = D1 * (MetaData "ProxyName" "Toxiproxy" "toxiproxy-haskell-" True) (C1 * (MetaCons "ProxyName" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Text)))

type Host = Text Source #

A host:port pair to represent the entrence of a proxy or the upstream the proxy forwards to. For the best experience, provide instead of localhost.

toxiproxyUrl :: BaseUrl Source #

The default Toxiproxy service URL. (

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