Skip to main content

FailureConfig

Struct FailureConfig 

Source
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 by probability — rolling above the probability on a given request leaves chaos inactive for that request. Classical failures ignore probability and 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

Source§

fn clone(&self) -> FailureConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FailureConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FailureConfig

Source§

fn default() -> FailureConfig

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for FailureConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,