pub struct IdleTracker { /* private fields */ }Expand description
Tracks daemon activity so an unused daemon shuts itself down, and so background work only runs while nobody is asking for anything.
Two different questions are asked of the same clock:
- quiet — no connection is open and the last request is older than some period. Background extraction waits for this.
- idle — quiet for the configured shutdown timeout, and no background batch in flight. The accept loop exits on this.
A background batch therefore cannot be cut in half by the idle timeout, and
a hot request always makes the daemon un-quiet immediately. None disables
idle shutdown entirely (--foreground, or idle_timeout_secs = 0) without
disabling quiet, which is what keeps a supervised daemon extracting.
Implementations§
Source§impl IdleTracker
impl IdleTracker
pub fn new(timeout: Option<Duration>) -> Self
Sourcepub fn new_at(timeout: Option<Duration>, start: Instant) -> Self
pub fn new_at(timeout: Option<Duration>, start: Instant) -> Self
Construct with an explicit start instant (used by tests).
Sourcepub fn begin_background(&self)
pub fn begin_background(&self)
Register a background batch as running. Holds off idle shutdown until it finishes, without pretending the daemon is being used.
Sourcepub fn end_background(&self)
pub fn end_background(&self)
Register a background batch as finished.
Sourcepub fn has_connections(&self) -> bool
pub fn has_connections(&self) -> bool
True while at least one client connection is open.
Sourcepub fn is_quiet_at(&self, now: Instant, quiet: Duration) -> bool
pub fn is_quiet_at(&self, now: Instant, quiet: Duration) -> bool
True when no connection is open and nothing has been asked of the
daemon for quiet.
Sourcepub fn is_idle_at(&self, now: Instant) -> bool
pub fn is_idle_at(&self, now: Instant) -> bool
True when the daemon has been unused for longer than the timeout and no background batch is in flight.
Sourcepub fn poll_interval(&self) -> Duration
pub fn poll_interval(&self) -> Duration
How often the accept loop should re-check idleness.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for IdleTracker
impl RefUnwindSafe for IdleTracker
impl Send for IdleTracker
impl Sync for IdleTracker
impl Unpin for IdleTracker
impl UnsafeUnpin for IdleTracker
impl UnwindSafe for IdleTracker
Blanket Implementations§
impl<T> AsyncFriendly for T
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
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>
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 moreSource§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>
T in a tonic::Request