pub struct ChildSpecification<S = WorkerSpec> { /* private fields */ }Expand description
A specification for a process to be added to a Supervisor.
A child specification describes how the supervisor should create and manage a child: the underlying future that
represents the process, along with metadata such as its name and shutdown strategy. All processes in a supervisor,
whether a worker or a (nested) supervisor, are represented by a ChildSpecification.
Generally, callers should prefer to use add_worker directly, which can accept either
Supervisor or any value that implements Supervisable, without needing to explicitly create a
ChildSpecification. This is preferred as it is more concise but also will ensure that relevant settings are
configured properly for the given worker type, such as using the proper shutdown strategy for supervisors to allow
for complete, graceful shutdown.
If more control is needed, ChildSpecification::worker can be used to create a specification directly, allowing
access to configuring those more advanced settings. This is currently only valid for worker processes, as
supervisors have no additional user-configurable settings.
Implementations§
Source§impl ChildSpecification<WorkerSpec>
impl ChildSpecification<WorkerSpec>
Sourcepub fn worker<T: Supervisable + 'static>(worker: T) -> Self
pub fn worker<T: Supervisable + 'static>(worker: T) -> Self
Creates a specification for the given worker.
Sourcepub fn with_restart_type(self, restart_type: RestartType) -> Self
pub fn with_restart_type(self, restart_type: RestartType) -> Self
Sets the restart policy for this worker.
Defaults to RestartType::Permanent.
Trait Implementations§
Source§impl From<Supervisor> for ChildSpecification<SupervisorSpec>
impl From<Supervisor> for ChildSpecification<SupervisorSpec>
Source§fn from(supervisor: Supervisor) -> Self
fn from(supervisor: Supervisor) -> Self
Source§impl<T> From<T> for ChildSpecification<WorkerSpec>where
T: Supervisable + 'static,
impl<T> From<T> for ChildSpecification<WorkerSpec>where
T: Supervisable + 'static,
Auto Trait Implementations§
impl<S> Freeze for ChildSpecification<S>where
S: Freeze,
impl<S> RefUnwindSafe for ChildSpecification<S>where
S: RefUnwindSafe,
impl<S> Send for ChildSpecification<S>where
S: Send,
impl<S> Sync for ChildSpecification<S>where
S: Sync,
impl<S> Unpin for ChildSpecification<S>where
S: Unpin,
impl<S> UnsafeUnpin for ChildSpecification<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for ChildSpecification<S>where
S: UnwindSafe,
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