Skip to main content

host

Function host 

Source
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_agent is the HostAgent actor handle. To obtain the local proc, use GetLocalProc on this agent, then GetProc on the returned proc mesh agent.

  • shutdown_handle joins the host’s accept loop and runs the drain protocol; see HostShutdownHandle.

  • 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::join will call process::exit after draining.

  • listener: when Some, it is used as the frontend listening socket instead of binding a new one.

  • gateway: the gateway this host will multiplex traffic through.

  • via: when Some, attach gateway to this remote duplex address with serve_via during bootstrap — after the local serves but before any ref is minted — so refs advertise the routable Via location (used by out-of-cluster clients).