pub trait Supervisable: Send + Sync {
// Required methods
fn name(&self) -> &str;
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;
// Provided methods
fn shutdown_strategy(&self) -> ShutdownStrategy { ... }
fn wants_shutdown_signal(&self) -> bool { ... }
}Expand description
A supervisable process.
Required Methods§
Sourcefn 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,
Initializes the process asynchronously.
During initialization, any resources or configuration for the process can be created asynchronously, and the
same runtime that’s used for running the process is used for initialization. The resulting future is expected to
complete as soon as reasonably possible after shutdown resolves.
Important: The process_shutdown signal must be moved into the returned SupervisorFuture so the worker
can respond to supervisor-initiated shutdown. If process_shutdown is dropped during initialization, the worker
will be unable to shut down gracefully and will be forcefully aborted after the shutdown timeout.
§Errors
If the process can’t be initialized, an error is returned.
Provided Methods§
Sourcefn shutdown_strategy(&self) -> ShutdownStrategy
fn shutdown_strategy(&self) -> ShutdownStrategy
Returns the shutdown strategy for the process.
Sourcefn wants_shutdown_signal(&self) -> bool
fn wants_shutdown_signal(&self) -> bool
Returns whether this process observes the shutdown signal it is given.
Shutting a subtree down is a trigger, not an enforcement: many workers ignore the signal entirely and stop
only when they reach their own terminal condition, such as an input channel closing. Reporting false lets the
supervisor skip creating a shutdown coordinator it would never usefully fire, and hand the process a
[ShutdownHandle::noop] instead.
This says nothing about whether the supervisor waits for the process – that’s
shutdown_strategy. A process that ignores the signal is still waited for, up to
whatever deadline applies to it.
Defaults to true.