pub struct NestedSupervisorBuilder<'a> { /* private fields */ }Expand description
Builder for a yet-to-be-started nested supervisor.
The counterpart to ChildBuilder for a child that is itself a Supervisor, and deliberately a much smaller
surface. A nested supervisor has no placement of its own, because it runs where its parent runs and its children
carry their own placement. It also has no shutdown deadline of its own, because it limits its own drain through its
children. Thus, the settings that remain are whether it is needed or hosted, and whether it stops with its owner.
Implementations§
Source§impl<'a> NestedSupervisorBuilder<'a>
impl<'a> NestedSupervisorBuilder<'a>
Sourcepub fn needed(self) -> Self
pub fn needed(self) -> Self
Marks this subtree as one that its owner cannot work without.
See ChildBuilder::needed, which this method mirrors.
Sourcepub fn hosted(self) -> Self
pub fn hosted(self) -> Self
Marks this subtree as one that its owner runs but does not need.
See ChildBuilder::hosted, which this method mirrors.
Sourcepub fn stops_with_owner(self) -> Self
pub fn stops_with_owner(self) -> Self
Tells this subtree to stop as soon as its owner is told to stop, instead of when the owner’s scope closes.
Use this for ingress whose output the owner’s body consumes, such as a server whose handlers feed a channel that the body drains. The server stops accepting work and finishes what it accepted while the body keeps draining.
This takes effect only in the scope of a worker that takes the shutdown signal (see
Supervisable::wants_shutdown_signal). A supervisor tells all of its children to stop at once anyway, and a
worker that takes no signal has nothing to stop the subtree with.
The scope keeps the subtree’s specification until the subtree exits, and the specification holds whatever the subtree was built with, such as the sender in a request handler. Thus, the channel closes once the subtree exits. The body MUST NOT hold a sender of that channel itself, or the channel never closes. See the scope documentation.
Sourcepub fn transient(self) -> Self
👎Deprecated: mark the subtree hosted instead, which restarts it only if it fails
pub fn transient(self) -> Self
mark the subtree hosted instead, which restarts it only if it fails
Restarts this subtree only when it terminates abnormally.
Sourcepub fn temporary(self) -> Self
👎Deprecated: a supervisor can always be started again; mark it hosted or needed instead
pub fn temporary(self) -> Self
a supervisor can always be started again; mark it hosted or needed instead
Never restarts this subtree.
Sourcepub fn with_significant(self, significant: bool) -> Self
👎Deprecated: mark the subtree needed instead, which stops its owner when it terminates for good
pub fn with_significant(self, significant: bool) -> Self
mark the subtree needed instead, which stops its owner when it terminates for good
Sets whether the parent supervisor stops when this subtree terminates.
Sourcepub fn build(self) -> ChildSpecification<SupervisorSpec>
pub fn build(self) -> ChildSpecification<SupervisorSpec>
Finishes describing the child without starting it, for Supervisor::add_worker.
Use this method to register a configured subtree on a supervisor that has not started yet. To start the subtree
now, use spawn.
Whichever supervisor this builder was created against is irrelevant here – the child belongs to whichever one it is handed to.
Sourcepub fn spawn(self) -> ChildId
pub fn spawn(self) -> ChildId
Spawns the nested supervisor.
This method works as ChildBuilder::spawn does. It spawns onto the target supervisor if the builder has one.
If not, it spawns the nested supervisor as a child of the current process.
§Panics
Panics if this builder does not target a specific supervisor and code outside supervision calls this method. See
spawn.
Sourcepub fn spawn_sibling(self) -> ChildId
pub fn spawn_sibling(self) -> ChildId
Spawns the nested supervisor onto the ambient supervisor, the nearest supervisor above the current process.
This method works as ChildBuilder::spawn_sibling does.
§Panics
Panics if this builder does not target a specific supervisor and there is no ambient supervisor.
Auto Trait Implementations§
impl<'a> Freeze for NestedSupervisorBuilder<'a>
impl<'a> !RefUnwindSafe for NestedSupervisorBuilder<'a>
impl<'a> Send for NestedSupervisorBuilder<'a>
impl<'a> Sync for NestedSupervisorBuilder<'a>
impl<'a> Unpin for NestedSupervisorBuilder<'a>
impl<'a> UnsafeUnpin for NestedSupervisorBuilder<'a>
impl<'a> !UnwindSafe for NestedSupervisorBuilder<'a>
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