Safe Haskell | None |
---|---|
Language | Haskell2010 |
- getVersion :: ClientM Version
- postReset :: ClientM NoContent
- getProxies :: ClientM (Map ProxyName Proxy)
- createProxy :: Proxy -> ClientM Proxy
- getProxy :: ProxyName -> ClientM Proxy
- postPopulate :: [Proxy] -> ClientM Populate
- updateProxy :: ProxyName -> Proxy -> ClientM Proxy
- deleteProxy :: ProxyName -> ClientM NoContent
- getToxics :: ProxyName -> ClientM [Toxic]
- createToxic :: ProxyName -> Toxic -> ClientM Toxic
- getToxic :: ProxyName -> ToxicName -> ClientM Toxic
- updateToxic :: ProxyName -> ToxicName -> Toxic -> ClientM Toxic
- deleteToxic :: ProxyName -> ToxicName -> ClientM NoContent
- data Proxy = Proxy {
- proxyName :: ProxyName
- proxyListen :: Host
- proxyUpstream :: Host
- proxyEnabled :: Bool
- proxyToxics :: [Toxic]
- data Toxic = Toxic {}
- newtype Populate = Populate {
- populateProxies :: [Proxy]
- newtype Version = Version Text
- data Stream
- data ToxicType
- newtype ProxyName = ProxyName Text
- newtype ToxicName = ToxicName Text
- type Host = Text
- toxiproxyUrl :: BaseUrl
- withDisabled :: Proxy -> IO a -> IO a
- withToxic :: Proxy -> Toxic -> IO a -> IO a
- withProxy :: Proxy -> (Proxy -> IO a) -> IO a
- run :: ClientM a -> IO (Either ServantError a)
Documentation
getVersion :: ClientM Version Source #
Returns the server version number.
A Toxiproxy proxy. It forwards TCP connections between a listen and upstream host. Toxics can be injected into the proxy to simulate network failure.
Proxy | |
|
A toxic is applied to a proxy. It allows the user to simulate a specified kind of network failure on the proxy.
Toxic | |
|
The return value of the populate
endpoint.
Populate | |
|
The version of the Toxiproxy server. This library is fully supported by any version greater or equal to 2.1.3.
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.
Different toxic types simulate different kinds of failure. Different toxics require different attribute configuration. Please refer to the Toxiproxy documentation.
A unique string for identifying a proxy on the server.
A unique string for identifying a toxic on a proxy.
A host:port pair to represent the entrence of a proxy or the upstream the proxy forwards to. For the best experience, provide 127.0.0.1 instead of localhost.
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