pub struct ShutdownProbe { /* private fields */ }Expand description
Polls a set of ShutdownComponents until they all drain or the
deadline elapses.
§Example
use dev_async::shutdown::{ShutdownComponent, ShutdownProbe};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
let drained = Arc::new(AtomicBool::new(true));
let comp = {
let drained = drained.clone();
ShutdownComponent::new("worker", move || {
let d = drained.clone();
async move { d.load(Ordering::Relaxed) }
})
};
let probe = ShutdownProbe::new("system")
.deadline(Duration::from_millis(200))
.poll_interval(Duration::from_millis(10))
.with_component(comp);
let checks = probe.run().await;
assert!(!checks.is_empty());Implementations§
Source§impl ShutdownProbe
impl ShutdownProbe
Sourcepub fn poll_interval(self, d: Duration) -> Self
pub fn poll_interval(self, d: Duration) -> Self
How often to re-evaluate each component’s drain predicate.
Sourcepub fn with_component(self, component: ShutdownComponent) -> Self
pub fn with_component(self, component: ShutdownComponent) -> Self
Add a component to the probe.
Sourcepub async fn run(self) -> Vec<CheckResult>
pub async fn run(self) -> Vec<CheckResult>
Run the probe and return one CheckResult per component plus
an aggregate.
Per-component verdicts:
- Drained before deadline ->
Passwithelapsed_msevidence. - Did not drain in time ->
Fail (Error)withnot_drainedtag.
The aggregate verdict is Fail if any component failed,
otherwise Pass. It is the last entry in the returned vector
and tagged aggregate.
Auto Trait Implementations§
impl Freeze for ShutdownProbe
impl !RefUnwindSafe for ShutdownProbe
impl Send for ShutdownProbe
impl Sync for ShutdownProbe
impl Unpin for ShutdownProbe
impl UnsafeUnpin for ShutdownProbe
impl !UnwindSafe for ShutdownProbe
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