pub struct RateLimitState {
pub weight: f64,
pub last_limited_at: Option<Instant>,
pub recovery_jitter: Duration,
pub consecutive_hits: u32,
pub base_weight: f64,
}Expand description
Rate limit state for a single agent.
Fields§
§weight: f64Current routing weight (0.0..=1.0). Higher = more tasks.
last_limited_at: Option<Instant>When the last rate limit error was recorded.
recovery_jitter: DurationJitter added to recovery delay to stagger recoveries (avoid thundering herd).
consecutive_hits: u32How many consecutive rate limit hits.
base_weight: f64The configured base weight this agent should recover toward.
Implementations§
Source§impl RateLimitState
impl RateLimitState
Sourcepub fn record_rate_limit(&mut self)
pub fn record_rate_limit(&mut self)
Record a rate limit event — decay the weight. Note: Jitter is set at the AgentWeights level using the agent name.
Sourcepub fn record_success(&mut self)
pub fn record_success(&mut self)
Record a successful completion — bump weight back toward base_weight.
Sourcepub fn maybe_recover(&mut self)
pub fn maybe_recover(&mut self)
Tick recovery: if enough time has passed since the last limit (plus jitter), gradually restore.
Sourcepub fn is_limited(&self) -> bool
pub fn is_limited(&self) -> bool
Is this agent currently rate-limited (weight below its base weight)?
Trait Implementations§
Source§impl Clone for RateLimitState
impl Clone for RateLimitState
Source§impl Debug for RateLimitState
impl Debug for RateLimitState
Auto Trait Implementations§
impl Freeze for RateLimitState
impl RefUnwindSafe for RateLimitState
impl Send for RateLimitState
impl Sync for RateLimitState
impl Unpin for RateLimitState
impl UnsafeUnpin for RateLimitState
impl UnwindSafe for RateLimitState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
Converts
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> ⓘ
Converts
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