pub struct ChaosMiddleware { /* private fields */ }Expand description
Chaos middleware state
This middleware reads configuration from a shared Arc<RwLock<ChaosConfig>>
to support hot-reload of chaos settings at runtime.
Implementations§
Source§impl ChaosMiddleware
impl ChaosMiddleware
Sourcepub fn new(
config: Arc<RwLock<ChaosConfig>>,
latency_tracker: Arc<LatencyMetricsTracker>,
) -> Self
pub fn new( config: Arc<RwLock<ChaosConfig>>, latency_tracker: Arc<LatencyMetricsTracker>, ) -> Self
Create new chaos middleware from shared config
§Arguments
config- Shared chaos configuration (Arc<RwLock>) latency_tracker- Latency metrics tracker for recording injected latencies
The middleware will read from the shared config on each request, allowing hot-reload of chaos settings without restarting the server.
Sourcepub async fn init_from_config(&self)
pub async fn init_from_config(&self)
Initialize middleware from config (async version)
This should be called after creation to sync injectors with the actual config.
This is a convenience method that calls update_from_config().
Sourcepub async fn update_from_config(&self)
pub async fn update_from_config(&self)
Update injectors from current config
This method should be called when the config is updated to refresh the cached injectors. For hot-reload support, this is called automatically when processing requests if the config has changed.
Sourcepub fn latency_injector(&self) -> Arc<RwLock<LatencyInjector>>
pub fn latency_injector(&self) -> Arc<RwLock<LatencyInjector>>
Get latency injector (read-only access)
Sourcepub fn fault_injector(&self) -> Arc<RwLock<FaultInjector>>
pub fn fault_injector(&self) -> Arc<RwLock<FaultInjector>>
Get fault injector (read-only access) Note: FaultInjector doesn’t support hot-reload, so we read from config directly
Sourcepub fn rate_limiter(&self) -> Arc<RwLock<RateLimiter>>
pub fn rate_limiter(&self) -> Arc<RwLock<RateLimiter>>
Get rate limiter (read-only access)
Sourcepub fn traffic_shaper(&self) -> Arc<RwLock<TrafficShaper>>
pub fn traffic_shaper(&self) -> Arc<RwLock<TrafficShaper>>
Get traffic shaper (read-only access)
Sourcepub fn circuit_breaker(&self) -> Arc<RwLock<CircuitBreaker>>
pub fn circuit_breaker(&self) -> Arc<RwLock<CircuitBreaker>>
Get circuit breaker (read-only access)
Sourcepub fn config(&self) -> Arc<RwLock<ChaosConfig>>
pub fn config(&self) -> Arc<RwLock<ChaosConfig>>
Get shared config (for direct access if needed)
Sourcepub fn latency_tracker(&self) -> &Arc<LatencyMetricsTracker>
pub fn latency_tracker(&self) -> &Arc<LatencyMetricsTracker>
Get latency tracker
Trait Implementations§
Source§impl Clone for ChaosMiddleware
impl Clone for ChaosMiddleware
Source§fn clone(&self) -> ChaosMiddleware
fn clone(&self) -> ChaosMiddleware
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ChaosMiddleware
impl !RefUnwindSafe for ChaosMiddleware
impl Send for ChaosMiddleware
impl Sync for ChaosMiddleware
impl Unpin for ChaosMiddleware
impl !UnwindSafe for ChaosMiddleware
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request