pub struct FailureConfig {
pub latency_ms: Option<u64>,
pub corrupt_body: Option<bool>,
pub truncate_after_frames: Option<u32>,
pub disconnect_after_ms: Option<u64>,
pub latency_jitter_ms: Option<u64>,
pub duplicate_frames: Option<bool>,
pub probability: Option<f32>,
pub chaos_seed: Option<u64>,
}Expand description
Failure simulation — network/streaming problems.
Two flavors of failure:
- Classical (
latency_ms,corrupt_body,truncate_after_frames,disconnect_after_ms): deterministic, always fire when set. - Chaos (
latency_jitter_ms,duplicate_frames,probability,chaos_seed): randomized but seeded, so runs are reproducible. Chaos fields are gated byprobability— rolling above the probability on a given request leaves chaos inactive for that request. Classical failures ignoreprobabilityand always apply.
Fields§
§latency_ms: Option<u64>Inject latency (in milliseconds) before sending the response.
corrupt_body: Option<bool>If true, corrupt the response body (invalid JSON/SSE).
truncate_after_frames: Option<u32>Truncate SSE stream after N frames (including preamble events).
Alias: truncate_after_chunks (deprecated, use truncate_after_frames).
Interaction with duplicate_frames: this count is applied to the
stream AFTER duplication. If duplicate_frames: true doubles the
source frames, truncate_after_frames: 2 sends the first two
doubled entries (i.e. the first source frame emitted twice). Set
truncate_after_frames to 2 * N if you want to cut after N of
the original frames.
disconnect_after_ms: Option<u64>Abruptly close the connection after this many milliseconds.
latency_jitter_ms: Option<u64>Add random ±jitter (milliseconds) to the per-frame streaming latency.
Requires a base streaming.latency to act on. Jitter is symmetric:
a jitter of 10 adds a value in the range [-10, +10] to each frame
delay. The effective delay is clamped at zero — a jittered negative
value becomes an immediate frame.
duplicate_frames: Option<bool>If true, emit each streaming frame twice back-to-back. Useful for
testing idempotent-consumer logic that must tolerate repeated events.
Interaction with truncate_after_frames: duplication happens
before truncation counting, so duplicate_frames: true +
truncate_after_frames: N cuts after N doubled frames. See the
truncate_after_frames doc for the full explanation.
probability: Option<f32>Probability in [0.0, 1.0] that the chaos fields activate for a
given request. None or 1.0 = always. 0.0 = never. Classical
failures (latency_ms, corrupt_body, truncate, disconnect) are NOT
affected by this — only the chaos fields above.
chaos_seed: Option<u64>Override the chaos PRNG seed. When unset, the seed is derived from
an internal per-server request counter, so successive requests from
the same test produce a deterministic but distinct sequence of chaos
outcomes. Setting chaos_seed to a fixed value reproduces the same
jitter/duplicate pattern across server instances.
Trait Implementations§
Source§impl Clone for FailureConfig
impl Clone for FailureConfig
Source§fn clone(&self) -> FailureConfig
fn clone(&self) -> FailureConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more