pub struct FaultInjector { /* private fields */ }Expand description
Fault injector for testing resilience scenarios.
Thread-safe structure that can be shared across provider and tests to inject faults dynamically during test execution.
Implementations§
Source§impl FaultInjector
impl FaultInjector
Sourcepub fn disable_notifier(&self)
pub fn disable_notifier(&self)
Disable the notifier - prevents it from being spawned.
When called before provider creation, the notifier thread will not start, simulating a notifier failure scenario.
Sourcepub fn is_notifier_disabled(&self) -> bool
pub fn is_notifier_disabled(&self) -> bool
Check if the notifier is disabled.
Sourcepub fn set_notifier_should_panic(&self, should_panic: bool)
pub fn set_notifier_should_panic(&self, should_panic: bool)
Set whether the notifier should panic on next iteration.
Sourcepub fn should_notifier_panic(&self) -> bool
pub fn should_notifier_panic(&self) -> bool
Check if the notifier should panic.
Sourcepub fn set_refresh_delay(&self, delay: Duration)
pub fn set_refresh_delay(&self, delay: Duration)
Set artificial delay for refresh queries (simulates slow database).
Sourcepub fn get_refresh_delay(&self) -> Duration
pub fn get_refresh_delay(&self) -> Duration
Get the current refresh delay.
Sourcepub fn set_refresh_should_error(&self, should_error: bool)
pub fn set_refresh_should_error(&self, should_error: bool)
Set whether the next refresh query should return an error.
Sourcepub fn should_refresh_error(&self) -> bool
pub fn should_refresh_error(&self) -> bool
Check and consume the refresh error flag.
Sourcepub fn trigger_reconnect(&self)
pub fn trigger_reconnect(&self)
Force the notifier to reconnect (simulates connection drop).
Sourcepub fn should_reconnect(&self) -> bool
pub fn should_reconnect(&self) -> bool
Check and consume the reconnect flag.
Sourcepub fn set_clock_skew(&self, skew: Duration)
pub fn set_clock_skew(&self, skew: Duration)
Set clock skew offset in milliseconds.
Positive values simulate a clock that is ahead (future timestamps). Negative values simulate a clock that is behind (past timestamps).
This offset is added to all now_millis() calculations in the provider,
allowing simulation of clock drift between nodes.
§Example
use duroxide_pg_opt::FaultInjector;
use std::time::Duration;
let fi = FaultInjector::new();
// Simulate clock 500ms ahead
fi.set_clock_skew(Duration::from_millis(500));
// Simulate clock 200ms behind
fi.set_clock_skew_signed(-200);Sourcepub fn set_clock_skew_signed(&self, skew_ms: i64)
pub fn set_clock_skew_signed(&self, skew_ms: i64)
Set clock skew offset in milliseconds (signed).
Positive values simulate a clock that is ahead. Negative values simulate a clock that is behind.
Sourcepub fn get_clock_skew_ms(&self) -> i64
pub fn get_clock_skew_ms(&self) -> i64
Get the current clock skew offset in milliseconds.
Sourcepub fn clear_clock_skew(&self)
pub fn clear_clock_skew(&self)
Clear the clock skew (reset to 0).
Trait Implementations§
Source§impl Debug for FaultInjector
impl Debug for FaultInjector
Source§impl Default for FaultInjector
impl Default for FaultInjector
Source§fn default() -> FaultInjector
fn default() -> FaultInjector
Auto Trait Implementations§
impl !Freeze for FaultInjector
impl RefUnwindSafe for FaultInjector
impl Send for FaultInjector
impl Sync for FaultInjector
impl Unpin for FaultInjector
impl UnsafeUnpin for FaultInjector
impl UnwindSafe for FaultInjector
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more