pub struct AdaptiveRateLimit {
pub enabled: bool,
pub ewma_window_secs: u64,
pub min_factor: f64,
pub max_factor: f64,
pub error_threshold: f64,
pub latency_threshold_ms: u64,
pub origin_signals: Vec<OriginSignal>,
}Expand description
Adaptive + origin-driven rate-limit tuning (DW-089,
policies[].adaptive): an EWMA of upstream error rate and latency
dynamically scales this policy’s rate-limit quotas at check time
(the factor multiplies the effective cost of each request against
the GCRA bucket), and upstream-originated signals trigger an
immediate backoff. The factor is bounded [min_factor, max_factor]
(never 0, never unbounded); tightening under stress is faster than
relaxing when healthy (asymmetric, so the gateway errs toward
protecting upstreams). origin_signals selects which upstream
response signals the controller honors (currently retry_after).
Fields§
§enabled: boolWhether adaptive tuning is enabled (default true). A
policies[].adaptive block with enabled: false is a no-op
(the controller is not compiled for that policy).
ewma_window_secs: u64EWMA decay window in seconds for error-rate and latency tracking (default 60). A larger window smooths transient spikes; a smaller window reacts faster. Must be > 0.
min_factor: f64Minimum adaptive factor (default 0.1): the tightest the quotas
can shrink to (10% of the configured rate). Must be > 0 and <=
max_factor. The factor is never 0.
max_factor: f64Maximum adaptive factor (default 2.0): the loosest the quotas
can grow to (200% of the configured rate). Must be > 0 and >=
min_factor. The factor is never unbounded.
error_threshold: f64Error-rate EWMA threshold that triggers tightening (default 0.05
= 5% 5xx rate). When the error EWMA exceeds this, the factor
decreases toward min_factor. Must be in (0, 1].
latency_threshold_ms: u64Latency EWMA threshold in milliseconds that triggers tightening
(default 500). When the latency EWMA exceeds this, the factor
decreases toward min_factor. Must be > 0.
origin_signals: Vec<OriginSignal>Upstream-originated signals the controller honors (default
empty: EWMA-only tuning). Currently supported: retry_after
(parse the upstream Retry-After header and back off for the
advertised window).
Trait Implementations§
Source§impl Clone for AdaptiveRateLimit
impl Clone for AdaptiveRateLimit
Source§fn clone(&self) -> AdaptiveRateLimit
fn clone(&self) -> AdaptiveRateLimit
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AdaptiveRateLimit
impl Debug for AdaptiveRateLimit
Source§impl<'de> Deserialize<'de> for AdaptiveRateLimit
impl<'de> Deserialize<'de> for AdaptiveRateLimit
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>,
Source§impl JsonSchema for AdaptiveRateLimit
impl JsonSchema for AdaptiveRateLimit
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for AdaptiveRateLimit
impl PartialEq for AdaptiveRateLimit
Source§impl Serialize for AdaptiveRateLimit
impl Serialize for AdaptiveRateLimit
impl StructuralPartialEq for AdaptiveRateLimit
Auto Trait Implementations§
impl Freeze for AdaptiveRateLimit
impl RefUnwindSafe for AdaptiveRateLimit
impl Send for AdaptiveRateLimit
impl Sync for AdaptiveRateLimit
impl Unpin for AdaptiveRateLimit
impl UnwindSafe for AdaptiveRateLimit
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Self to T,
useful only in generic context as a workaround for specializationSource§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,
§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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