pub struct OrderedShutdown { /* private fields */ }Expand description
The shutdown coordinator. Clones share one shutdown.
Implementations§
Source§impl OrderedShutdown
impl OrderedShutdown
pub fn new() -> Self
Sourcepub fn phase(
self,
name: impl Into<String>,
deadline: Duration,
run: impl FnOnce() -> Result<(), String> + Send + 'static,
) -> Self
pub fn phase( self, name: impl Into<String>, deadline: Duration, run: impl FnOnce() -> Result<(), String> + Send + 'static, ) -> Self
Append a phase. Phases run in the order added. deadline bounds this phase (a zero
deadline is raised to 1 ms). Ignored once the shutdown has started.
Sourcepub fn watchdog(self, hard_deadline: Duration, exit_code: i32) -> Self
pub fn watchdog(self, hard_deadline: Duration, exit_code: i32) -> Self
End the process with exit_code when the whole shutdown has not finished hard_deadline
after it started. Without it there is no watchdog.
Sourcepub fn on_watchdog(self, exit: impl Fn(i32) + Send + Sync + 'static) -> Self
pub fn on_watchdog(self, exit: impl Fn(i32) + Send + Sync + 'static) -> Self
Replace what the watchdog does (default: std::process::exit(code)), for a host that must
do its own last write first.
Sourcepub fn run(&self) -> ShutdownReport
pub fn run(&self) -> ShutdownReport
Run the shutdown, or wait for the run already in flight and return its report.
Trait Implementations§
Source§impl Clone for OrderedShutdown
impl Clone for OrderedShutdown
Auto Trait Implementations§
impl Freeze for OrderedShutdown
impl RefUnwindSafe for OrderedShutdown
impl Send for OrderedShutdown
impl Sync for OrderedShutdown
impl Unpin for OrderedShutdown
impl UnsafeUnpin for OrderedShutdown
impl UnwindSafe for OrderedShutdown
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