pub async fn host(
addr: ChannelAddr,
command: Option<BootstrapCommand>,
config: Option<Attrs>,
exit_on_shutdown: bool,
listener: Option<TcpListener>,
gateway: Gateway,
via: Option<ChannelAddr>,
) -> Result<(ActorHandle<HostAgent>, HostShutdownHandle)>Expand description
Bootstrap a host in this process using a caller-provided gateway.
The caller passes the Gateway in — typically Gateway::new,
but it may have been pre-configured (e.g., via
Gateway::serve_via or [Gateway::attach] to connect to
another gateway) before this call. Host construction serves the
gateway’s backend and frontend endpoints, so the host’s
system_proc, local_proc, HostAgent, and handler ports
snapshot the frontend location when minted. Any preconfigured
serve_via session remains active as an outbound route and local
delivery location.
Returns (host_mesh_agent, shutdown_handle):
-
host_mesh_agentis theHostAgentactor handle. To obtain the local proc, useGetLocalProcon this agent, thenGetProcon the returned proc mesh agent. -
shutdown_handlejoins the host’s accept loop and runs the drain protocol; seeHostShutdownHandle. -
addr: the listening address of the host; this is used for the frontend server. -
command: optional bootstrap command to spawn procs, otherwise [BootstrapProcManager::current]. -
config: optional runtime config overlay. -
exit_on_shutdown: if true,HostShutdownHandle::joinwill callprocess::exitafter draining. -
listener: whenSome, it is used as the frontend listening socket instead of binding a new one. -
gateway: the gateway this host will multiplex traffic through. -
via: whenSome, attachgatewayto this remote duplex address withserve_viaduring bootstrap — after the local serves but before any ref is minted — so refs advertise the routableVialocation (used by out-of-cluster clients).