pub struct HostMeshShutdownGuard(pub HostMesh);Expand description
Wrapper around HostMesh that runs shutdown on Drop.
Tuple Fields§
§0: HostMeshMethods from Deref<Target = HostMesh>§
Sourcepub async fn shutdown(&mut self, cx: &impl Actor) -> Result<()>
pub async fn shutdown(&mut self, cx: &impl Actor) -> Result<()>
Request a clean shutdown of all hosts owned by this
HostMesh.
Uses a two-phase approach:
- Cast
DrainHostand wait for every host to finish draining its user procs while networking stays alive. - Cast
ShutdownHostand wait for every host to acknowledge that its local shutdown handler has completed.
Sourcepub async fn stop(&mut self, cx: &impl Actor) -> Result<()>
pub async fn stop(&mut self, cx: &impl Actor) -> Result<()>
Stop all hosts owned by this HostMesh, draining user procs
but keeping worker processes and their sockets alive for
reconnection.
After stop, the same worker addresses can be passed to
HostMesh::attach to create a new mesh.
Sourcepub fn set_bootstrap(&mut self, cmd: BootstrapCommand)
pub fn set_bootstrap(&mut self, cmd: BootstrapCommand)
Set the bootstrap command on the underlying HostMeshRef,
so that future spawn calls use it. Unlike
HostMeshRef::with_bootstrap this mutates in place,
preserving ownership.
Methods from Deref<Target = HostMeshRef>§
Sourcepub async fn spawn<C: Actor>(
&self,
cx: &C,
name: &str,
per_host: Extent,
proc_bind: Option<Vec<ProcBind>>,
per_rank_bootstrap: Option<Box<PerRankBootstrapFn>>,
) -> Result<ProcMesh>
pub async fn spawn<C: Actor>( &self, cx: &C, name: &str, per_host: Extent, proc_bind: Option<Vec<ProcBind>>, per_rank_bootstrap: Option<Box<PerRankBootstrapFn>>, ) -> Result<ProcMesh>
Spawn a ProcMesh onto this host mesh. The per_host extent specifies the shape of the procs to spawn on each host.
proc_bind, when provided, is a per-process CPU/NUMA binding
configuration. Its length must equal the number of ranks in
per_host. Each entry maps binding keys (cpunodebind,
membind, physcpubind, cpus) to their values.
Only takes effect when running on Linux.
per_rank_bootstrap, when provided, is a function called once
per proc to produce that proc’s BootstrapCommand. The
function receives a view::Point over the combined
host_extent ⊕ per_host extent. Its return value takes
precedence over self.bootstrap_command for that proc only.
Spawn is issued as a single SpawnProcs cast — each HostAgent spawns all
of its per-host proc slots — then fenced with an accumulated status
barrier so returned procs are addressable and ready.
Sourcepub fn id(&self) -> &HostMeshId
pub fn id(&self) -> &HostMeshId
The identity of the referenced host mesh.
Sourcepub fn host_addrs(&self) -> Vec<ChannelAddr>
pub fn host_addrs(&self) -> Vec<ChannelAddr>
The host channel addresses in rank order.
Trait Implementations§
Source§impl Deref for HostMeshShutdownGuard
impl Deref for HostMeshShutdownGuard
Source§impl DerefMut for HostMeshShutdownGuard
impl DerefMut for HostMeshShutdownGuard
Source§impl Drop for HostMeshShutdownGuard
impl Drop for HostMeshShutdownGuard
Source§fn drop(&mut self)
fn drop(&mut self)
Best-effort cleanup for owned host meshes on drop.
When a HostMesh is dropped, it attempts to shut down all
hosts it owns:
- If a Tokio runtime is available, we spawn an ephemeral
Proc+Instanceand best-effort castShutdownHostthrough the owned hosts. This ensures that the embeddedBootstrapProcManagers are dropped, and all child procs they spawned are killed when the cast succeeds. - If no runtime is available, we cannot perform async cleanup
here; in that case we log a warning and rely on kernel-level
PDEATHSIG or the individual
BootstrapProcManager’sDropas the final safeguard.
This path is last resort: callers should prefer explicit
HostMesh::shutdown to guarantee orderly teardown. Drop
only provides opportunistic cleanup to prevent process leaks
if shutdown is skipped.
Auto Trait Implementations§
impl !Freeze for HostMeshShutdownGuard
impl RefUnwindSafe for HostMeshShutdownGuard
impl Send for HostMeshShutdownGuard
impl Sync for HostMeshShutdownGuard
impl Unpin for HostMeshShutdownGuard
impl UnsafeUnpin for HostMeshShutdownGuard
impl UnwindSafe for HostMeshShutdownGuard
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].