pub struct LatencyInjector { /* private fields */ }Expand description
Latency and fault injector
Implementations§
Source§impl LatencyInjector
impl LatencyInjector
Sourcepub fn new(latency_profile: LatencyProfile, fault_config: FaultConfig) -> Self
pub fn new(latency_profile: LatencyProfile, fault_config: FaultConfig) -> Self
Create a new latency injector
Sourcepub fn set_enabled(&mut self, enabled: bool)
pub fn set_enabled(&mut self, enabled: bool)
Enable or disable injection
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if injection is enabled
Sourcepub async fn inject_latency(&self, tags: &[String]) -> Result<()>
pub async fn inject_latency(&self, tags: &[String]) -> Result<()>
Inject latency for a request
Sourcepub fn should_inject_failure(&self) -> bool
pub fn should_inject_failure(&self) -> bool
Check if a failure should be injected
Sourcepub fn get_failure_response(&self) -> (u16, Option<Value>)
pub fn get_failure_response(&self) -> (u16, Option<Value>)
Get failure response details
Sourcepub async fn process_request(
&self,
tags: &[String],
) -> Result<Option<(u16, Option<Value>)>>
pub async fn process_request( &self, tags: &[String], ) -> Result<Option<(u16, Option<Value>)>>
Process a request with latency and potential fault injection
Sourcepub fn profile(&self) -> &LatencyProfile
pub fn profile(&self) -> &LatencyProfile
Borrow the current latency profile (read-only).
Mostly useful from tests and the admin UI for verifying that hot-reload calls actually mutated the injector.
Sourcepub fn update_profile(&mut self, profile: LatencyProfile)
pub fn update_profile(&mut self, profile: LatencyProfile)
Update latency profile at runtime
This allows changing the latency profile without recreating the injector. Useful for hot-reloading reality level configurations.
Sourcepub async fn update_profile_async(
this: &Arc<RwLock<Self>>,
profile: LatencyProfile,
) -> Result<()>
pub async fn update_profile_async( this: &Arc<RwLock<Self>>, profile: LatencyProfile, ) -> Result<()>
Update latency profile (async version for Arc
Convenience method for updating a latency injector wrapped in Arc
§Returns
Ok(()) on success, or an error if the update fails.
Trait Implementations§
Source§impl Clone for LatencyInjector
impl Clone for LatencyInjector
Source§fn clone(&self) -> LatencyInjector
fn clone(&self) -> LatencyInjector
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more