pub struct Health { /* private fields */ }Expand description
A registry of health checks.
Implementations§
Source§impl Health
impl Health
Sourcepub fn register<F, Fut>(self, name: impl Into<String>, check: F) -> Self
pub fn register<F, Fut>(self, name: impl Into<String>, check: F) -> Self
Add a check.
It receives the application, so it can resolve whatever it needs to prove — which is the point: a check that does not touch the dependency is a check that reports the dependency is fine when it is not.
Sourcepub fn timeout(self, timeout: Option<Duration>) -> Self
pub fn timeout(self, timeout: Option<Duration>) -> Self
How long a single check may take before it counts as failed.
None removes the deadline, which is almost always wrong: a probe that
hangs leaves the replica in an unknown state, and an orchestrator that
cannot decide does nothing at all.
Sourcepub fn describing_build(self, build: impl Serialize) -> Self
pub fn describing_build(self, build: impl Serialize) -> Self
Include this build description in the report.
Pass build_info!() — the version and
commit belong in the same document as the health, because the first two
questions of an incident are “is it up” and “which one is it”.
Sourcepub async fn run(&self, app: Arc<Application>) -> Report
pub async fn run(&self, app: Arc<Application>) -> Report
Run every check.
Concurrently: a report of six checks that take a second each should take a second, not six, because a probe has a deadline of its own and a slow report is a failed one.
Sourcepub async fn render(&self, app: Arc<Application>) -> Response
pub async fn render(&self, app: Arc<Application>) -> Response
Run every check and render the document a probe reads.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Health
impl !UnwindSafe for Health
impl Freeze for Health
impl Send for Health
impl Sync for Health
impl Unpin for Health
impl UnsafeUnpin for Health
Blanket Implementations§
impl<T> Actor 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
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