pub enum Toxic {
Latency {
latency: u64,
jitter: u64,
},
Bandwidth {
rate: u64,
},
Timeout {
timeout: u64,
},
Slicer {
average_size: u64,
size_variation: u64,
delay: u64,
},
LimitData {
bytes: u64,
},
}Expand description
A typed Toxiproxy toxic.
Each variant maps to a Toxiproxy toxic type and carries its attributes. Use
the associated constructors (Toxic::latency, Toxic::bandwidth, …) to
build a toxic, then pass it to ToxiproxyTemplate::add_toxic.
See the Toxiproxy toxics reference for the full semantics of each type.
Variants§
Latency
Add a delay to all data, with optional random jitter.
latency and jitter are in milliseconds.
Fields
Bandwidth
Limit the connection to a maximum throughput.
rate is in kilobytes per second.
Timeout
Stop all data and close the connection after timeout milliseconds.
A timeout of 0 holds the connection open indefinitely without passing
data, which is useful for simulating a hung upstream.
Slicer
Slice data into smaller packets to simulate fragmentation.
Fields
LimitData
Close the connection after a fixed number of bytes have been transmitted.
Implementations§
Source§impl Toxic
impl Toxic
Sourcepub fn latency(latency: u64) -> Self
pub fn latency(latency: u64) -> Self
Create a latency toxic with no jitter.
latency is in milliseconds.
Sourcepub fn jitter(latency: u64, jitter: u64) -> Self
pub fn jitter(latency: u64, jitter: u64) -> Self
Create a latency toxic with random jitter.
Both latency and jitter are in milliseconds.
Sourcepub fn bandwidth(rate: u64) -> Self
pub fn bandwidth(rate: u64) -> Self
Create a bandwidth toxic limiting throughput to rate kilobytes per second.
Sourcepub fn timeout(timeout: u64) -> Self
pub fn timeout(timeout: u64) -> Self
Create a timeout toxic that closes the connection after timeout milliseconds.
A timeout of 0 holds the connection open indefinitely.
Sourcepub fn slicer(average_size: u64, size_variation: u64, delay: u64) -> Self
pub fn slicer(average_size: u64, size_variation: u64, delay: u64) -> Self
Create a slicer toxic that fragments data into smaller packets.
average_size and size_variation are in bytes; delay is in microseconds.
Sourcepub fn limit_data(bytes: u64) -> Self
pub fn limit_data(bytes: u64) -> Self
Create a limit_data toxic that closes the connection after bytes bytes.