pub fn noninterruptible_worker<N, F, Fut>(name: N, f: F) -> FnWorkerExpand description
Creates a one-shot Supervisable worker that is never interrupted mid-operation.
The future that is created is solely responsible for handling the shutdown signal exposed to it via
ShutdownHandle. Callers should ensure that they respond to shutdown signals in a timely manner otherwise they risk
failing to run to completion when the supervisor forcefully exits. Use this for workers that need to drain in
response to shutdown; for workers that are safe to stop at an arbitrary await point, interruptible_worker is
simpler.
Workers may return either () or Result<(), GenericError>.
The worker cannot be restarted as the given closure is consumed during initialization.
ยงExamples
let worker = noninterruptible_worker("queue_drainer", |shutdown| async move {
tokio::select! {
_ = shutdown => {},
_ = drain_queue() => {},
}
});