pub struct TimeoutManager {
global_deadline: Option<Instant>,
operation_timeout: Duration,
}Expand description
Timeout manager with optional cascading global deadline.
Fields§
§global_deadline: Option<Instant>§operation_timeout: DurationImplementations§
Source§impl TimeoutManager
impl TimeoutManager
Sourcepub fn new(operation_timeout: Duration) -> Self
pub fn new(operation_timeout: Duration) -> Self
Create with an operation-scoped timeout and no global deadline.
Sourcepub fn with_deadline(
global_deadline: Instant,
operation_timeout: Duration,
) -> Self
pub fn with_deadline( global_deadline: Instant, operation_timeout: Duration, ) -> Self
Create with both a global deadline and an operation timeout.
Sourcepub fn ValidateTimeout(timeout: Duration) -> Result<(), String>
pub fn ValidateTimeout(timeout: Duration) -> Result<(), String>
Return an error if timeout is zero or exceeds one hour.
Sourcepub fn ValidateTimeoutResult(timeout: Duration) -> Result<Duration, String>
pub fn ValidateTimeoutResult(timeout: Duration) -> Result<Duration, String>
Return Ok(timeout) or an error string; used by fallback paths.
Sourcepub fn remaining(&self) -> Option<Duration>
pub fn remaining(&self) -> Option<Duration>
Time remaining until the global deadline, or None if none is set.
Sourcepub fn Remaining(&self) -> Option<Duration>
pub fn Remaining(&self) -> Option<Duration>
Panic-safe remaining(). Returns None on panic (fail-open).
Sourcepub fn effective_timeout(&self) -> Duration
pub fn effective_timeout(&self) -> Duration
Minimum of operation_timeout and remaining deadline time.
Sourcepub fn EffectiveTimeout(&self) -> Duration
pub fn EffectiveTimeout(&self) -> Duration
Panic-safe effective_timeout(). Falls back to 30 s on invalid/panic.
Sourcepub fn is_exceeded(&self) -> bool
pub fn is_exceeded(&self) -> bool
true when the global deadline has passed.
Sourcepub fn IsExceeded(&self) -> bool
pub fn IsExceeded(&self) -> bool
Panic-safe is_exceeded(). Returns true on panic (fail-safe).
pub fn GetGlobalDeadline(&self) -> Option<Instant>
pub fn GetOperationTimeout(&self) -> Duration
Auto Trait Implementations§
impl Freeze for TimeoutManager
impl RefUnwindSafe for TimeoutManager
impl Send for TimeoutManager
impl Sync for TimeoutManager
impl Unpin for TimeoutManager
impl UnsafeUnpin for TimeoutManager
impl UnwindSafe for TimeoutManager
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<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>
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].