pub struct RuntimeStatusHandle { /* private fields */ }Expand description
Cloneable handle used by apps and background tasks to report health and readiness.
Implementations§
Source§impl RuntimeStatusHandle
impl RuntimeStatusHandle
Sourcepub fn report_health(&self, state: HealthState)
pub fn report_health(&self, state: HealthState)
Report a new health state.
Sourcepub fn report_readiness(&self, state: ReadinessState)
pub fn report_readiness(&self, state: ReadinessState)
Report a new readiness state.
Examples found in repository?
examples/systemd_daemon.rs (line 66)
54 async fn setup(
55 &mut self,
56 wora: &Wora<DaemonEvent, ()>,
57 _exec: impl AsyncExecutor<DaemonEvent, ()>,
58 _fs: impl WFS + 'static,
59 _metrics: Sender<O11yEvent<()>>,
60 _is_first_boot: bool,
61 ) -> Result<Self::Setup, Box<dyn std::error::Error>> {
62 let sender = wora.sender.clone();
63 let status = wora.status_handle();
64 let interval = Duration::from_millis(self.config.interval_ms.max(100));
65 tokio::spawn(async move {
66 status.report_readiness(ReadinessState::Ready);
67 let mut ticker = tokio::time::interval(interval);
68 loop {
69 ticker.tick().await;
70 if sender.send(Event::App(DaemonEvent::Tick)).await.is_err() {
71 break;
72 }
73 }
74 });
75 Ok(())
76 }Sourcepub fn begin_draining(&self)
pub fn begin_draining(&self)
Transition the runtime into a draining state.
Sourcepub fn begin_stopping(&self)
pub fn begin_stopping(&self)
Transition the runtime into a stopping state.
Sourcepub fn subscribe_health(&self) -> Receiver<HealthState>
pub fn subscribe_health(&self) -> Receiver<HealthState>
Subscribe to health state changes.
Sourcepub fn subscribe_readiness(&self) -> Receiver<ReadinessState>
pub fn subscribe_readiness(&self) -> Receiver<ReadinessState>
Subscribe to readiness state changes.
Sourcepub fn health_state(&self) -> HealthState
pub fn health_state(&self) -> HealthState
Return the latest reported health state.
Sourcepub fn readiness_state(&self) -> ReadinessState
pub fn readiness_state(&self) -> ReadinessState
Return the latest reported readiness state.
Trait Implementations§
Source§impl Clone for RuntimeStatusHandle
impl Clone for RuntimeStatusHandle
Source§fn clone(&self) -> RuntimeStatusHandle
fn clone(&self) -> RuntimeStatusHandle
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 moreAuto Trait Implementations§
impl !RefUnwindSafe for RuntimeStatusHandle
impl !UnwindSafe for RuntimeStatusHandle
impl Freeze for RuntimeStatusHandle
impl Send for RuntimeStatusHandle
impl Sync for RuntimeStatusHandle
impl Unpin for RuntimeStatusHandle
impl UnsafeUnpin for RuntimeStatusHandle
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