pub struct RuntimeHealth { /* private fields */ }Expand description
Shared record of background-loop state. Cheap to read from a handler.
Implementations§
Source§impl RuntimeHealth
impl RuntimeHealth
pub fn new() -> Self
Sourcepub fn set_started_at(&self, now_unix: i64)
pub fn set_started_at(&self, now_unix: i64)
Stamp the process start time. Called once, from main.
Sourcepub fn uptime_secs(&self, now_unix: i64) -> Option<i64>
pub fn uptime_secs(&self, now_unix: i64) -> Option<i64>
Seconds this process has been alive, or None before it was stamped.
Sourcepub fn begin_db_probe(self: &Arc<Self>) -> Result<DbProbeGuard, DbProbe>
pub fn begin_db_probe(self: &Arc<Self>) -> Result<DbProbeGuard, DbProbe>
Claim the right to run a database probe, or borrow the last verdict.
/health is exempt from the Cloudflare origin lock and is not in the rate
limiter’s path list, so it answers unauthenticated requests at whatever
rate they arrive. Once it started touching the database, that became a way
to spend the 5-connection pool from outside — and the handler’s own
timeout then returns the 503 that Fly’s check reads.
This deduplicates CONCURRENT probes rather than caching by time. A time
cache would also bound the cost, but it makes a genuinely dead database
invisible for the length of the window; this bounds in-flight database
work to exactly one probe while leaving every sequential request — Fly’s
own, and any operator’s curl — a fresh answer. It is also a better fix
than rate-limiting /health, which would risk refusing Fly’s probe.
Returns Err(verdict) when a probe is already running: the caller reports
that instead of starting another. Ok(guard) means the caller owns the
probe and must report it via the returned guard.
Sourcepub fn set_schedulers_enabled(&self, enabled: bool)
pub fn set_schedulers_enabled(&self, enabled: bool)
Record that the background loops were (or were not) spawned.
pub fn schedulers_enabled(&self) -> bool
Sourcepub fn poll_tick_completed(&self, now_unix: i64)
pub fn poll_tick_completed(&self, now_unix: i64)
Stamp a completed poll tick at now_unix.
Sourcepub fn secs_since_poll_tick(&self, now_unix: i64) -> Option<i64>
pub fn secs_since_poll_tick(&self, now_unix: i64) -> Option<i64>
Seconds since the last completed poll tick, or None if there has not
been one yet.
Sourcepub fn set_watermark(&self, paused: bool)
pub fn set_watermark(&self, paused: bool)
Record the outcome of a watermark check.
Deliberately just the verdict, not the measured size. The size is already
in the log line that accompanies a pause, and the two surfaces that read
this — /health and /stats — are both reachable without the Cloudflare
origin lock or a session, so neither publishes precise internal numbers.
Sourcepub fn watermark_paused(&self) -> bool
pub fn watermark_paused(&self) -> bool
Whether the watermark is currently pausing new fetches. This is the
state in which polled_last_hour falls and overdue climbs for a reason
that has nothing to do with the poller being too slow.
Trait Implementations§
Source§impl Debug for RuntimeHealth
impl Debug for RuntimeHealth
Source§impl Default for RuntimeHealth
impl Default for RuntimeHealth
Source§fn default() -> RuntimeHealth
fn default() -> RuntimeHealth
Auto Trait Implementations§
impl !Freeze for RuntimeHealth
impl RefUnwindSafe for RuntimeHealth
impl Send for RuntimeHealth
impl Sync for RuntimeHealth
impl Unpin for RuntimeHealth
impl UnsafeUnpin for RuntimeHealth
impl UnwindSafe for RuntimeHealth
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 more