pub struct FnWorker { /* private fields */ }Expand description
A Supervisable worker built from a plain future.
This is the ordinary kind of supervised child: a piece of asynchronous work that runs until it reaches its own terminal condition – an input channel closing, a loop finishing, a request completing.
§Shutdown
An FnWorker is never handed a shutdown signal, and reports as much through
wants_shutdown_signal. Shutdown of a subtree is a trigger, not an
enforcement: the workers within it keep running until their terminal conditions are reached, which is what lets a
set of tasks connected by channels drain in dependency order without any of them having to know that order. The
supervisor’s shutdown budget is the backstop for work that
takes too long, and ShutdownStrategy::Brutal is the answer for work that has no terminal condition at all.
A worker that genuinely needs to observe shutdown – to run cleanup, or because it has no other way to know it
should stop – should implement Supervisable directly, which does receive the signal.
This worker cannot be restarted, as the future is consumed during initialization.
Implementations§
Source§impl FnWorker
impl FnWorker
Sourcepub fn new<N, Fut>(name: N, fut: Fut) -> Self
pub fn new<N, Fut>(name: N, fut: Fut) -> Self
Creates a worker that runs fut to completion.
Workers may return either () or Result<(), GenericError>.
Prefer worker and its counterparts on
SupervisorHandle, which wrap this up with the defaults appropriate to a
dynamically spawned child.
§Examples
let worker = FnWorker::new("queue_drainer", drain_queue());Trait Implementations§
Source§impl Supervisable for FnWorker
impl Supervisable for FnWorker
Source§fn shutdown_strategy(&self) -> ShutdownStrategy
fn shutdown_strategy(&self) -> ShutdownStrategy
Source§fn wants_shutdown_signal(&self) -> bool
fn wants_shutdown_signal(&self) -> bool
Source§fn initialize<'life0, 'async_trait>(
&'life0 self,
_process_shutdown: ShutdownHandle,
) -> Pin<Box<dyn Future<Output = Result<SupervisorFuture, InitializationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn initialize<'life0, 'async_trait>(
&'life0 self,
_process_shutdown: ShutdownHandle,
) -> Pin<Box<dyn Future<Output = Result<SupervisorFuture, InitializationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !Freeze for FnWorker
impl RefUnwindSafe for FnWorker
impl Send for FnWorker
impl Sync for FnWorker
impl Unpin for FnWorker
impl UnwindSafe for FnWorker
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> 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> 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> Pointable for T
impl<T> Pointable for T
§impl<T> Track for T
impl<T> Track for T
§fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
Tracked wrapper. Read more§fn in_current_resource_group(self) -> Tracked<Self>
fn in_current_resource_group(self) -> Tracked<Self>
Tracked wrapper. Read more