pub struct ReadinessState { /* private fields */ }Expand description
Shared, framework-owned readiness state for an OoP gear instance.
Created by the OoP bootstrap with the gear’s critical dependency names and
a shared RestHealthcheckRegistry (populated from each gear’s
RestApiCapability::healthcheck).
Cloned as an Arc into the probe router and the dependency-resolution task.
Implementations§
Source§impl ReadinessState
impl ReadinessState
Sourcepub fn new<I, S>(
critical_deps: I,
healthchecks: Arc<RestHealthcheckRegistry>,
) -> Arc<Self> ⓘ
pub fn new<I, S>( critical_deps: I, healthchecks: Arc<RestHealthcheckRegistry>, ) -> Arc<Self> ⓘ
Create a new readiness state seeded with the gear’s critical dependency
names and the shared healthcheck registry. All listed deps start
unresolved; the gear is not ready until startup is complete, each dep is
marked resolved via mark_dep_resolved, and
the healthchecks pass. Uses DEFAULT_HEALTHCHECK_TIMEOUT as the
per-check timeout.
Sourcepub fn with_check_timeout<I, S>(
critical_deps: I,
healthchecks: Arc<RestHealthcheckRegistry>,
check_timeout: Duration,
) -> Arc<Self> ⓘ
pub fn with_check_timeout<I, S>( critical_deps: I, healthchecks: Arc<RestHealthcheckRegistry>, check_timeout: Duration, ) -> Arc<Self> ⓘ
Like new but with an explicit per-check timeout.
Sourcepub fn from_checker(
deps: Arc<DependencyChecker>,
healthchecks: Arc<RestHealthcheckRegistry>,
check_timeout: Duration,
) -> Arc<Self> ⓘ
pub fn from_checker( deps: Arc<DependencyChecker>, healthchecks: Arc<RestHealthcheckRegistry>, check_timeout: Duration, ) -> Arc<Self> ⓘ
Build an aggregator around an existing DependencyChecker, so the
in-process consumer-wiring path and the OoP /readyz aggregator share
one dependency-resolution core (the checker is fed once, read by both).
Sourcepub fn dependency_checker(&self) -> Arc<DependencyChecker> ⓘ
pub fn dependency_checker(&self) -> Arc<DependencyChecker> ⓘ
The shared dependency-resolution core, e.g. to feed it from consumer
wiring or to back an in-process ReadinessHealthcheck leaf.
Sourcepub fn register_dep(&self, dep_gear: impl Into<String>)
pub fn register_dep(&self, dep_gear: impl Into<String>)
Declare a critical dependency dynamically (idempotent; preserves an
already-resolved entry). Complements the up-front critical_deps seed for
deps discovered during consumer wiring.
Sourcepub fn mark_startup_complete(&self)
pub fn mark_startup_complete(&self)
Mark startup as complete. Idempotent; subsequent calls are ignored.
/readyz will not report Ready or Degraded until this is called.
Sourcepub fn is_startup_complete(&self) -> bool
pub fn is_startup_complete(&self) -> bool
Whether startup is complete.
Sourcepub fn mark_dep_resolved(&self, name: &str)
pub fn mark_dep_resolved(&self, name: &str)
Mark a critical dependency as resolved. Idempotent; unknown names are ignored.
Sourcepub fn all_deps_resolved(&self) -> bool
pub fn all_deps_resolved(&self) -> bool
Whether all critical dependencies have been resolved.
Sourcepub fn set_draining(&self, draining: bool)
pub fn set_draining(&self, draining: bool)
Set (or clear) the draining flag. Setting it flips /readyz to 503
immediately so upstreams pull the instance out of rotation while
in-flight requests drain.
Sourcepub fn is_draining(&self) -> bool
pub fn is_draining(&self) -> bool
Whether the gear is currently draining.
Sourcepub async fn health_report(&self) -> HealthcheckReport
pub async fn health_report(&self) -> HealthcheckReport
Run the registered healthchecks and return the aggregated report.
Used by /health to expose full per-component detail and by
Self::evaluate to decide readiness state. The registry caches the
report, so repeated calls within the cache window do not re-run checks.
Sourcepub async fn evaluate(&self) -> ReadinessReport
pub async fn evaluate(&self) -> ReadinessReport
Evaluate the aggregate readiness.
The gear is ready when it is not draining, startup is complete, all
critical deps are resolved, and the aggregated healthcheck report is not
Unhealthy. Degraded healthchecks keep the gear ready (state = degraded, ready = true) but the detailed per-component messages belong
on /health, not /readyz. The healthcheck fan-out is cached inside the
registry, so repeated probe traffic does not re-run checks; dependency and
draining state are read live so transitions take effect immediately.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ReadinessState
impl !RefUnwindSafe for ReadinessState
impl !UnwindSafe for ReadinessState
impl Send for ReadinessState
impl Sync for ReadinessState
impl Unpin for ReadinessState
impl UnsafeUnpin for ReadinessState
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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::RequestSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Source§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read moreSource§fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
500 Internal Server responses. Read moreSource§fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
413 Payload Too Large responses. Read moreSource§impl<T> WithSecurityContext for T
impl<T> WithSecurityContext for T
Source§fn security_ctx<'a>(&'a self, ctx: &'a SecurityContext) -> Secured<'a, T>where
T: Sized,
fn security_ctx<'a>(&'a self, ctx: &'a SecurityContext) -> Secured<'a, T>where
T: Sized,
Secured wrapper. Read more