pub struct AcceptBackoff { /* private fields */ }Expand description
Exponential backoff state for listener.accept() retry loops.
Accept errors (typically EMFILE/ENFILE when the process has run out of
file descriptors, or transient ConnectionAborted under load) are not fatal
to the listener. Servers should log, sleep, and re-poll. Use AcceptBackoff
to keep the sleep schedule consistent across transports without duplicating
the constants in every serve_* implementation.
Implementations§
Source§impl AcceptBackoff
impl AcceptBackoff
Sourcepub async fn sleep_and_grow(&mut self)
pub async fn sleep_and_grow(&mut self)
Sleep for the current backoff and double it (capped at max).
Use the tokio sleep so this is cooperative on the runtime that runs
the accept loop.
Sourcepub fn current_and_grow(&mut self) -> Duration
pub fn current_and_grow(&mut self) -> Duration
Returns the current backoff duration and doubles the internal counter
(capped at max). Use this when you need to drive the sleep with a
non-tokio timer (e.g. compio::time::sleep).
Trait Implementations§
Source§impl Clone for AcceptBackoff
impl Clone for AcceptBackoff
Source§fn clone(&self) -> AcceptBackoff
fn clone(&self) -> AcceptBackoff
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AcceptBackoff
impl Debug for AcceptBackoff
Source§impl Default for AcceptBackoff
impl Default for AcceptBackoff
impl Copy for AcceptBackoff
Auto Trait Implementations§
impl Freeze for AcceptBackoff
impl RefUnwindSafe for AcceptBackoff
impl Send for AcceptBackoff
impl Sync for AcceptBackoff
impl Unpin for AcceptBackoff
impl UnsafeUnpin for AcceptBackoff
impl UnwindSafe for AcceptBackoff
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