This reference describes unreleased code on main; no release documents it yet.

rlmesh::env::EnvServer

structPreviewuse rlmesh::env::EnvServer;[source]

Serves an env, a list of lane envs, or a vector env.

struct EnvServer

The server binds at construction, so address and env_contract are readable before serving. Then serve blocks with lane 0 (or the vector env) on the calling thread, or start serves from library threads and wait / shutdown observe the stop. Each lane runs on one thread for the server’s life.

Dropping a server runs shutdown and discards its error; call shutdown() to observe it. Inside an async runtime, Drop triggers the drain and leaves the rest to the server’s own threads.

Also available as rlmesh::EnvServer.

new

associated function[source]
fn new<E: Env + Send + 'static>(
    env: E,
    options: EnvServerOptions,
) -> Result<EnvServer>

Serve one env.

lanes

associated function[source]
fn lanes<E: Env + Send + 'static>(
    envs: Vec<E>,
    options: EnvServerOptions,
) -> Result<EnvServer>

Serve envs as the lanes of one num_envs = N endpoint, each on its own thread. Use Box<dyn Env + Send> to mix env types.

vector

associated function[source]
fn vector<V: VectorEnv + Send + 'static>(
    env: V,
    options: EnvServerOptions,
) -> Result<EnvServer>

Serve a vector env. A vector env with num_envs == 1 is served as a single scalar lane.

address

method[source]
fn address(&self) -> &str

The bound address (tcp://127.0.0.1:<port> for port 0).

env_contract

method[source]
fn env_contract(&self) -> &EnvContract

The contract this endpoint serves.

serve

method[source]
fn serve(&self) -> Result<()>

Serve in the foreground until the server stops: lane 0 (or the vector env) runs on this thread, every other lane on its own. SIGINT stops the server and this returns the cancellation class after the drain and close; SIGTERM stops it and this returns Ok.

start

method[source]
fn start(&self) -> Result<()>

Serve from library threads and return at once.

wait

method[source]
fn wait(&self, timeout: Option<Duration>) -> Result<bool>

Wait for a started server to stop: Ok(false) when timeout passes first, Ok(true) once it has stopped. The call that observes the stop returns the serve error, once. timeout may be zero.

shutdown

method[source]
fn shutdown(&self) -> Result<()>

Stop the server: release a never-served listener (closing the envs if close_env_on_shutdown), or trigger the drain and join a started one, returning its serve error unless a wait() already returned it. Called from one of this server’s own env callbacks, it only triggers the drain.

serve_async

method[source]
async fn serve_async(&self) -> Result<()>

The async twin of serve: every lane, lane 0 included, runs on library threads and no signal handler is installed; resolves with the serve error when the server stops. Dropping it stops the server (the drain and close finish detached).

wait_async

method[source]
async fn wait_async(&self, timeout: Option<Duration>) -> Result<bool>

The async twin of wait. Dropping it leaves the server as it was.

shutdown_async

method[source]
async fn shutdown_async(&self) -> Result<()>

The async twin of shutdown. Dropping it leaves the drain it triggered to finish detached.

Trait implementations

  • impl Drop for EnvServer
  • impl Display for EnvServer
  • impl Debug for EnvServer
  • impl<'a> From<&'a EnvServer> for EnvTarget<'a>