pub struct FaultConfig {
pub failure_rate: f64,
pub status_codes: Vec<u16>,
pub error_responses: HashMap<String, Value>,
}
Expand description
Fault injection configuration
Fields§
§failure_rate: f64
Probability of failure (0.0 to 1.0)
status_codes: Vec<u16>
HTTP status codes to return on failure
error_responses: HashMap<String, Value>
Custom error responses
Implementations§
Source§impl FaultConfig
impl FaultConfig
Sourcepub fn with_status_code(self, code: u16) -> Self
pub fn with_status_code(self, code: u16) -> Self
Add a status code to the failure responses
Sourcepub fn with_error_response(self, key: String, response: Value) -> Self
pub fn with_error_response(self, key: String, response: Value) -> Self
Add a custom error response
Sourcepub fn should_fail(&self) -> bool
pub fn should_fail(&self) -> bool
Determine if a failure should occur
Sourcepub fn get_failure_response(&self) -> (u16, Option<Value>)
pub fn get_failure_response(&self) -> (u16, Option<Value>)
Get a random failure response
Trait Implementations§
Source§impl Clone for FaultConfig
impl Clone for FaultConfig
Source§fn clone(&self) -> FaultConfig
fn clone(&self) -> FaultConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for FaultConfig
impl Debug for FaultConfig
Source§impl Default for FaultConfig
impl Default for FaultConfig
Source§impl<'de> Deserialize<'de> for FaultConfig
impl<'de> Deserialize<'de> for FaultConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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§
impl Freeze for FaultConfig
impl RefUnwindSafe for FaultConfig
impl Send for FaultConfig
impl Sync for FaultConfig
impl Unpin for FaultConfig
impl UnwindSafe for FaultConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more