Skip to main content

NestedSupervisorBuilder

Struct NestedSupervisorBuilder 

Source
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>

Source

pub fn needed(self) -> Self

Marks this subtree as one that its owner cannot work without.

See ChildBuilder::needed, which this method mirrors.

Source

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.

Source

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.

Source

pub fn transient(self) -> Self

👎Deprecated:

mark the subtree hosted instead, which restarts it only if it fails

Restarts this subtree only when it terminates abnormally.

Source

pub fn temporary(self) -> Self

👎Deprecated:

a supervisor can always be started again; mark it hosted or needed instead

Never restarts this subtree.

Source

pub fn with_significant(self, significant: bool) -> Self

👎Deprecated:

mark the subtree needed instead, which stops its owner when it terminates for good

Sets whether the parent supervisor stops when this subtree terminates.

Source

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.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> Track for T

§

fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>

Instruments this type by attaching the given resource group token, returning a Tracked wrapper. Read more
§

fn in_current_resource_group(self) -> Tracked<Self>

Instruments this type by attaching the current resource group, returning a Tracked wrapper. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more