pub struct AdaptiveTimeoutManager { /* private fields */ }Expand description
Thread-safe, per-model adaptive timeout manager.
Uses a [DashMap] so that multiple tokio tasks can record outcomes and
query timeouts concurrently without a global lock.
Implementations§
Source§impl AdaptiveTimeoutManager
impl AdaptiveTimeoutManager
Sourcepub fn record_outcome(&self, model: &str, duration_ms: u64, success: bool)
pub fn record_outcome(&self, model: &str, duration_ms: u64, success: bool)
Record the outcome of one request for model.
This updates the rolling sample window and the EMA.
Sourcepub fn get_timeout(&self, model: &str) -> Duration
pub fn get_timeout(&self, model: &str) -> Duration
Compute the recommended timeout for model.
Returns p95 * 1.5, clamped to [5 s, 120 s]. Falls back to 30 s
when fewer than two samples have been collected.
Sourcepub fn adjust_for_load(&self, model: &str, queue_depth: usize) -> Duration
pub fn adjust_for_load(&self, model: &str, queue_depth: usize) -> Duration
Adjust the base timeout by the current queue depth.
Scales get_timeout by sqrt(queue_depth / 10).max(1.0) so that a
backlogged queue gets proportionally more time.
Sourcepub fn model_summary(&self, model: &str) -> Option<TimeoutSummary>
pub fn model_summary(&self, model: &str) -> Option<TimeoutSummary>
Return a TimeoutSummary snapshot for model, or None if the
model has never been seen.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AdaptiveTimeoutManager
impl Freeze for AdaptiveTimeoutManager
impl Send for AdaptiveTimeoutManager
impl Sync for AdaptiveTimeoutManager
impl Unpin for AdaptiveTimeoutManager
impl UnsafeUnpin for AdaptiveTimeoutManager
impl UnwindSafe for AdaptiveTimeoutManager
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request