Crate toxiproxy_rust[][src]

Toxiproxy-Rust is a Toxiproxy client written for the Rust language. It’s designed for testing network code and its resiliency against various network issues, such as latency or unavailability (and many more).

Setting up a test

use toxiproxy_rust::{TOXIPROXY, proxy::ProxyPack};

TOXIPROXY.populate(vec![ProxyPack::new(
    "socket".into(),
    "localhost:2001".into(),
    "localhost:2000".into(),
)]);

TOXIPROXY
    .find_and_reset_proxy("socket")
    .unwrap()
    .with_down(|| {
        /* For example:
        let result = MyService::Server.call();
        assert!(result.is_ok());
        */
    });

Setting up a more advanced test

use toxiproxy_rust::{TOXIPROXY, proxy::ProxyPack};

TOXIPROXY.populate(vec![ProxyPack::new(
    "socket".into(),
    "localhost:2001".into(),
    "localhost:2000".into(),
)]);

TOXIPROXY
    .find_and_reset_proxy("socket")
    .unwrap()
    .with_slicer("downstream".into(), 2048, 128, 0, 0.8)
    .with_bandwidth("downstream".into(), 32, 0.5)
    .apply(|| {
        /* For example:
        let result = MyService::Server.call();
        assert!(result.is_ok());
        */
    });

Modules

client

Main client for communicating with the Toxiproxy server.

proxy

Represents a Proxy - a connection to a service. Connection reliability can be set by specifying a Toxic on it.

toxic

Represents a Toxic - an effect on the network connection.

Structs

TOXIPROXY

Pre-built client using the default connection address.